/* Kledi dashboard — olive/cream brand palette */

:root {
    --c-primary: #2D5238;
    --c-primary-dark: #1F3A28;
    --c-primary-light: #4A7A55;
    --c-accent: #D4A84B;
    --c-accent-soft: #F0DFAA;
    --c-bg: #FAF6EE;
    --c-card: #FFFFFF;
    --c-text: #1F2A24;
    --c-text-soft: #5A6660;
    --c-border: #E5DECB;
    --c-border-strong: #B8AC8A;

    --c-status-new: #E0E9F4;
    --c-status-new-text: #1A4480;
    --c-status-approved: #FBE7C6;
    --c-status-approved-text: #8A5A00;
    --c-status-dispatched: #D1EAD9;
    --c-status-dispatched-text: #1E5934;
    --c-status-cancelled: #F5D8D2;
    --c-status-cancelled-text: #7E2A1F;

    --shadow: 0 1px 2px rgba(20, 30, 25, 0.04), 0 2px 8px rgba(20, 30, 25, 0.06);
    --r-md: 10px;
    --r-lg: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--c-primary-dark);
    color: #DDE7DF;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    gap: 6px;
}
.brand {
    color: #FFFFFF;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    padding: 6px 8px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-decoration: none;
}
.brand-mark { font-size: 24px; }

.rest-pill {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-md);
    padding: 10px 12px;
    margin: 14px 0 4px;
}
.rest-pill-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.55; }
.rest-pill-name { font-weight: 600; color: #fff; margin-top: 2px; }
.rest-pill-switch {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--c-accent-soft);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 16px;
}
.nav-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.45);
    margin: 18px 8px 6px;
}
.nav a {
    color: #DDE7DF;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    text-decoration: none;
    transition: background .12s ease;
}
.nav a:hover { background: rgba(255,255,255,0.07); text-decoration: none; }
.nav a.active { background: var(--c-primary); color: #fff; font-weight: 600; }

.sidebar-foot {
    margin-top: auto;
    padding: 14px 8px 4px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.user-name { color: #fff; font-weight: 600; font-size: 14px; }
.user-meta { font-size: 12px; opacity: 0.65; margin-top: 2px; }
.logout {
    display: inline-block;
    margin-top: 10px;
    color: var(--c-accent-soft);
    font-size: 13px;
}

/* ---------- Main ---------- */
.main { padding: 0; overflow-x: hidden; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 32px 14px;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; }
.status-indicator {
    font-size: 12px;
    color: var(--c-text-soft);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.status-indicator::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #B8AC8A;
}
.status-indicator.live::before { background: #58B36E; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.content { padding: 24px 32px 80px; }

/* ---------- Cards & layouts ---------- */
.card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    padding: 20px;
}
.cards { display: grid; gap: 16px; }
.cards.two-col { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

.section-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--c-text-soft);
    margin: 6px 0 12px;
}

.row-flex { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-flex.between { justify-content: space-between; }

/* ---------- Order card ---------- */
.order {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-primary-light);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 10px;
}
.order.status-e_re { border-left-color: var(--c-status-new-text); }
.order.status-e_aprovuar { border-left-color: var(--c-status-approved-text); }
.order.status-e_derguar { border-left-color: var(--c-status-dispatched-text); opacity: 0.85; }
.order.status-e_anuluar { border-left-color: var(--c-status-cancelled-text); opacity: 0.75; }

.order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.order-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--c-text-soft); }
.order-customer { font-weight: 700; font-size: 16px; }
.order-meta { font-size: 12px; color: var(--c-text-soft); margin-top: 2px; }
.order-items {
    background: var(--c-bg);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    display: grid;
    gap: 4px;
}
.order-items .line { display: flex; justify-content: space-between; }
.order-items .line .qty { color: var(--c-text-soft); font-variant-numeric: tabular-nums; }
.order-totals { display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; }
.order-notes {
    font-size: 13px;
    background: var(--c-accent-soft);
    border-radius: 6px;
    padding: 8px 10px;
    color: #6B4F18;
}
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Status pills ---------- */
.pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.pill.e_re        { background: var(--c-status-new); color: var(--c-status-new-text); }
.pill.e_aprovuar  { background: var(--c-status-approved); color: var(--c-status-approved-text); }
.pill.e_derguar   { background: var(--c-status-dispatched); color: var(--c-status-dispatched-text); }
.pill.e_anuluar   { background: var(--c-status-cancelled); color: var(--c-status-cancelled-text); }

/* ---------- Buttons ---------- */
.btn {
    border: 1px solid var(--c-border-strong);
    background: var(--c-card);
    color: var(--c-text);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .12s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn:hover { background: #F4ECD9; }
.btn.primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn.primary:hover { background: var(--c-primary-dark); }
.btn.accent { background: var(--c-accent); color: #2A1E00; border-color: var(--c-accent); }
.btn.accent:hover { background: #C99A3F; }
.btn.danger { background: #B33A2C; color: #fff; border-color: #B33A2C; }
.btn.danger:hover { background: #962F23; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--c-text-soft); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 13px; }

/* ---------- Tables ---------- */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-card);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}
table.data th, table.data td { padding: 12px 14px; text-align: left; }
table.data th { background: #F1EADB; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--c-text-soft); }
table.data tr + tr td { border-top: 1px solid var(--c-border); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--c-text-soft); }
.field input, .field select, .field textarea {
    border: 1px solid var(--c-border-strong);
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--c-primary-light);
    outline-offset: 1px;
}
.field-hint { font-size: 12px; color: var(--c-text-soft); }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--c-primary-dark) 0%, var(--c-primary) 100%);
}
.login-card {
    background: var(--c-card);
    border-radius: 20px;
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-card h1 { text-align: center; margin: 0 0 6px; font-size: 24px; }
.login-card .sub { text-align: center; color: var(--c-text-soft); margin-bottom: 22px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }
.login-error { background: var(--c-status-cancelled); color: var(--c-status-cancelled-text); padding: 10px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 25, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--c-card);
    border-radius: var(--r-lg);
    padding: 24px;
    max-width: 500px;
    width: 92%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h3 { margin: 0 0 14px; font-size: 18px; }

.reason-chips { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.reason-chip {
    text-align: left;
    border: 1px solid var(--c-border-strong);
    background: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    cursor: pointer;
}
.reason-chip:hover { background: #F4ECD9; }
.reason-chip.selected { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

/* ---------- Flash messages ---------- */
.flash {
    background: var(--c-status-dispatched);
    color: var(--c-status-dispatched-text);
    padding: 10px 18px;
    border-bottom: 1px solid var(--c-border);
    font-size: 14px;
}
.flash.err { background: var(--c-status-cancelled); color: var(--c-status-cancelled-text); }

/* ---------- Empty state ---------- */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--c-text-soft);
}
.empty .icon { font-size: 56px; margin-bottom: 12px; }
.empty .title { font-size: 18px; font-weight: 600; color: var(--c-text); }
.empty .sub { font-size: 14px; margin-top: 4px; }

/* ---------- Drag & drop ---------- */
.drag-handle {
    cursor: grab;
    user-select: none;
    color: var(--c-border-strong);
    font-size: 18px;
    line-height: 1;
    width: 28px;
    text-align: center;
    transition: color 0.12s ease;
}
.drag-handle:hover { color: var(--c-primary); }
.drag-handle:active { cursor: grabbing; }

[draggable="true"] { transition: opacity 0.12s ease, transform 0.12s ease; }
.dragging { opacity: 0.4; }
.drag-over-top    { box-shadow: inset 0 3px 0 0 var(--c-primary); }
.drag-over-bottom { box-shadow: inset 0 -3px 0 0 var(--c-primary); }
tr.drag-over-top    { box-shadow: 0 -3px 0 0 var(--c-primary); }
tr.drag-over-bottom { box-shadow: 0 3px 0 0 var(--c-primary); }

.cat-card { transition: opacity 0.12s ease; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; flex-wrap: wrap; padding: 12px; gap: 10px; }
    .sidebar .nav, .sidebar .rest-pill, .sidebar .sidebar-foot { width: 100%; }
    .topbar { padding: 16px; }
    .content { padding: 16px; }
}
