/* ═══════════════════════════════════════════════════════════════════
   Meliora eCommerce Admin Portal — admin.css
   ═══════════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
    --sidebar-w:    240px;
    --sidebar-bg:   #1a2332;
    --sidebar-text: #c8d3e0;
    --sidebar-hover:#243447;
    --sidebar-active:#2563eb;
    --header-h:     60px;
    --accent:       #2563eb;
    --accent-dark:  #1d4ed8;
    --sage:         #5a7a5a;
    --bg:           #f4f6f9;
    --card-bg:      #ffffff;
    --border:       #e2e8f0;
    --text:         #1e293b;
    --muted:        #64748b;
    --radius:       8px;

    /* Status colours */
    --status-pending:       #f59e0b;
    --status-processing:    #3b82f6;
    --status-ready:         #8b5cf6;
    --status-outdelivery:   #f97316;
    --status-delivered:     #10b981;
    --status-cancelled:     #ef4444;
}

/* ── Reset / Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif;
       background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }

/* ── Layout ─────────────────────────────────────────────────────── */
.admin-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .6rem;
}
.sidebar-brand small {
    font-size: .65rem;
    font-weight: 400;
    color: var(--sidebar-text);
    display: block;
    line-height: 1;
}

.sidebar-section {
    padding: .75rem 1rem .25rem;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #647a94;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.25rem;
    border-radius: 6px;
    margin: 1px .5rem;
    font-size: .875rem;
    transition: background .15s, color .15s;
    cursor: pointer;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar-link .badge-pill {
    margin-left: auto;
    background: rgba(255,255,255,.15);
    border-radius: 12px;
    padding: 1px 8px;
    font-size: .72rem;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .82rem;
    color: var(--sidebar-text);
}
.sidebar-footer .user-name { font-weight: 600; color: #fff; }

/* ── Main Content ───────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--card-bg);
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title { font-size: 1.15rem; font-weight: 600; }
.topbar-spacer { flex: 1; }

.page-body { padding: 1.75rem; flex: 1; }

/* ── Stat Cards ─────────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
    text-decoration: none;
    display: block;
}
.stat-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.07); border-color: var(--accent); }
.stat-card.active { border-color: var(--accent); background: #eff6ff; }
.stat-label { font-size: .75rem; color: var(--muted); font-weight: 500; margin-bottom: .4rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; }

/* ── Table Card ─────────────────────────────────────────────────── */
.table-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.table-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.table-card-title { font-size: 1rem; font-weight: 600; margin: 0; }
.table-responsive { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.admin-table th {
    background: #f8fafc;
    padding: .65rem 1rem;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
table.admin-table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table tr:hover td { background: #f8fafc; }

/* ── Status Badges ──────────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .03em;
    white-space: nowrap;
}
.status-Pending        { background: #fef3c7; color: #92400e; }
.status-Processing     { background: #dbeafe; color: #1e40af; }
.status-ReadyForDispatch { background: #ede9fe; color: #5b21b6; }
.status-OutForDelivery { background: #ffedd5; color: #9a3412; }
.status-Delivered      { background: #d1fae5; color: #065f46; }
.status-Cancelled      { background: #fee2e2; color: #991b1b; }

.pay-badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
}
.pay-Pending                { background: #fef9c3; color: #713f12; }
.pay-Paid                   { background: #d1fae5; color: #065f46; }
.pay-AwaitingVerification   { background: #fde68a; color: #92400e; }
.pay-Failed                 { background: #fee2e2; color: #991b1b; }

/* ── Detail Card ────────────────────────────────────────────────── */
.detail-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.detail-card-header {
    padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.detail-card-body { padding: 1.25rem; }

/* ── Info Grid ──────────────────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.info-item { }
.info-label { font-size: .72rem; font-weight: 600; text-transform: uppercase;
              letter-spacing: .05em; color: var(--muted); margin-bottom: .2rem; }
.info-value { font-size: .9rem; color: var(--text); }

/* ── Action Panel ───────────────────────────────────────────────── */
.action-panel {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.action-panel-title {
    font-weight: 600;
    font-size: .95rem;
    margin-bottom: 1rem;
    color: #1e40af;
}
.action-form-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

/* ── Workflow Timeline ───────────────────────────────────────────── */
.timeline {
    display: flex;
    gap: 0;
    margin: 1rem 0;
    overflow-x: auto;
    padding-bottom: .5rem;
}
.tl-step {
    flex: 1;
    text-align: center;
    position: relative;
    min-width: 100px;
}
.tl-step::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}
.tl-step:last-child::before { display: none; }
.tl-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--border);
    border: 3px solid var(--card-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    position: relative;
    z-index: 1;
    transition: background .2s;
}
.tl-step.done .tl-dot    { background: #10b981; color: #fff; }
.tl-step.active .tl-dot  { background: var(--accent); color: #fff; }
.tl-step.done::before    { background: #10b981; }
.tl-label { font-size: .7rem; color: var(--muted); margin-top: .35rem; }
.tl-step.active .tl-label { color: var(--accent); font-weight: 600; }
.tl-step.done .tl-label  { color: #10b981; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert-admin {
    padding: .85rem 1.1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-admin {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem 1.1rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity .15s, box-shadow .15s;
}
.btn-admin:hover { opacity: .88; }
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-success  { background: #10b981; color: #fff; }
.btn-warning  { background: #f59e0b; color: #fff; }
.btn-danger   { background: #ef4444; color: #fff; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-sm { padding: .3rem .8rem; font-size: .8rem; }

/* ── Select / Input ─────────────────────────────────────────────── */
.form-select-admin, .form-input-admin {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .48rem .75rem;
    font-size: .875rem;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}
.form-select-admin:focus, .form-input-admin:focus { border-color: var(--accent); }

/* ── Order items table ───────────────────────────────────────────── */
.items-row {
    display: flex;
    justify-content: space-between;
    padding: .5rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: .875rem;
}
.items-row:last-child { border-bottom: none; }
.osb { margin-top: 1rem; }
.osb-row { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .875rem; }
.osb-total { display: flex; justify-content: space-between; padding: .5rem 0;
             font-size: 1rem; font-weight: 700; border-top: 2px solid var(--border); margin-top: .25rem; }

/* ── Login page ─────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--sidebar-bg); margin: .5rem 0 .2rem; }
.login-logo p  { font-size: .85rem; color: var(--muted); margin: 0; }

/* ── Form Label ─────────────────────────────────────────────────── */
.form-label-admin {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: .3rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── PO Status Badges ───────────────────────────────────────────── */
.po-badge {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .03em;
    white-space: nowrap;
}
.po-Draft           { background: #f1f5f9; color: #475569; }
.po-Dispatched      { background: #dbeafe; color: #1e40af; }
.po-InvoiceReceived { background: #fef3c7; color: #92400e; }
.po-Received        { background: #d1fae5; color: #065f46; }
.po-Cancelled       { background: #fee2e2; color: #991b1b; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-240px); transition: transform .25s; }
    .sidebar.open { transform: translateX(0); width: 240px; }
    .main-content { margin-left: 0; }
}
