/* ============ ZuriPOS Admin ============ */
:root {
    --navy: #0f2a47;
    --navy-2: #163558;
    --teal: #149a96;
    --teal-dark: #0f7f7c;
    --teal-50: #eaf7f5;
    --blue: #3ea6f2;
    --blue-50: #eaf3fd;
    --purple: #9b7cf0;
    --purple-50: #f1edfd;
    --orange: #f5901e;
    --orange-50: #fff4e6;
    --green: #1fae5b;
    --green-50: #e3f6ec;
    --red: #e53935;
    --red-50: #fdecec;

    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #e4e9ef;
    --text: #172033;
    --text-2: #3b4658;
    --muted: #6b7686;

    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 32, 56, .04), 0 2px 8px rgba(16, 32, 56, .04);
    --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.icon { flex-shrink: 0; }

.text-teal { color: var(--teal); }
.text-blue { color: var(--blue); }
.text-orange { color: var(--orange); }
.text-green { color: var(--green); }
.text-red { color: var(--red) !important; }
.text-muted { color: var(--muted); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--navy);
    color: #dbe4ef;
    display: flex; flex-direction: column;
    z-index: 40;
    transition: transform .25s ease;
}
.brand { position: relative; padding: 22px 30px 30px; }
.brand-name { font-size: 32px; color: #fff; letter-spacing: .5px; font-weight: 400; line-height: 1.1; }
.brand-name strong { font-weight: 800; }
.brand-sub { color: #9fb0c4; font-size: 17px; margin-top: 4px; }
.icon-btn.sidebar-close { display: none; position: absolute; top: 18px; right: 14px; color: #fff; }

.nav { display: flex; flex-direction: column; gap: 6px; padding: 0 12px; flex: 1; overflow-y: auto; }
.nav-link {
    display: flex; align-items: center; gap: 18px;
    padding: 15px 16px;
    border-radius: 8px;
    font-size: 16px; color: #e3eaf3;
    transition: background .15s;
}
.nav-link .icon { color: #c5d2e1; }
.nav-link:hover { background: var(--navy-2); }
.nav-link.active { background: var(--teal); color: #fff; font-weight: 500; }
.nav-link.active .icon { color: #fff; }

.user-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    color: #c9d5e3;
}
.user-card:hover { background: var(--navy-2); }
.user-meta { flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.user-name { color: #fff; font-weight: 600; }
.user-role { font-size: 14px; color: #9fb0c4; }

.sidebar-backdrop { display: none; }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 14px 18px 24px 22px;
    min-width: 0;
}

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-title { display: flex; align-items: center; gap: 12px; }
.page-title h1 { font-size: 32px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
.page-title p { font-size: 19px; color: var(--text-2); margin-top: 2px; }
.icon-btn.menu-toggle { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }

.picker {
    position: relative;
    display: flex; align-items: center; gap: 14px;
    min-width: 210px;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-2);
}
.picker:hover { border-color: #c9d3de; }
.picker-body { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.picker-label { font-size: 13px; color: var(--muted); }
.picker-value, .picker select { font: inherit; font-size: 16px; color: var(--text); font-weight: 500; }
.picker select {
    appearance: none; -webkit-appearance: none;
    border: 0; background: transparent; padding: 0; margin: 0;
    cursor: pointer; outline: none;
    padding-right: 28px; margin-right: -28px; /* let the chevron overlay the select */
}
.picker input[type=date] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.picker-chevron { color: var(--text-2); pointer-events: none; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 0; background: transparent; color: var(--text-2);
    border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,.05); }
.bell { position: relative; }
.bell .dot { position: absolute; top: 6px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid var(--bg); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px 18px;
    border-radius: 6px;
    font: inherit; font-weight: 500; font-size: 15px;
    border: 1px solid transparent;
    cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.btn-lg { padding: 16px 22px; font-size: 16px; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-soft { background: #eef4f7; color: var(--navy); border-color: #dfe8ee; }
.btn-soft:hover { background: #e3edf2; }
.btn-blue-soft { background: var(--blue-50); color: var(--navy); border-color: #d6e6f8; }
.btn-blue-soft .icon { color: #2f6fd6; }
.btn-blue-soft:hover { background: #dfecfb; }
.btn-outline { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-outline:hover { background: #f7f9fb; }

/* ---------- Status bar ---------- */
.status-bar {
    display: grid; grid-template-columns: repeat(4, auto);
    justify-content: space-between;
    background: #f0f3f6;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 14px;
}
.status-item { display: flex; align-items: center; gap: 12px; color: var(--text-2); padding: 0 28px; border-left: 1px solid #d7dee6; }
.status-item:first-child { border-left: 0; padding-left: 0; }
.status-item strong { font-weight: 600; }

.state { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin-left: 12px; }
.state i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.state-green { color: var(--green); }
.state-orange { color: var(--orange); }
.state-red { color: var(--red); }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: 1.05fr .95fr 1fr 1.05fr; gap: 16px; margin-bottom: 16px; }
.stat {
    position: relative;
    display: flex; align-items: center; gap: 22px;
    padding: 22px 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    min-height: 118px;
}
.stat-icon { width: 58px; height: 62px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.stat-label { font-size: 16px; color: var(--text-2); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.3px; margin-top: 4px; white-space: nowrap; }
.stat-note { font-size: 15px; color: var(--muted); margin-top: 4px; }
.stat-alert {
    position: absolute; top: 20px; right: 16px;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--orange); color: #fff;
    font-weight: 800; display: grid; place-items: center; font-size: 15px;
}
.stat-teal   { background: #f2faf9; border-color: #dcefec; } .stat-teal .stat-icon   { background: #d8f0ec; color: var(--teal); }
.stat-blue   { background: #f1f7fd; border-color: #dce9f6; } .stat-blue .stat-icon   { background: #d9ebfb; color: #2a8be0; }
.stat-purple { background: #f6f3fd; border-color: #e6e0f6; } .stat-purple .stat-icon { background: #e6defb; color: #7c5ce6; }
.stat-orange { background: #fef8f0; border-color: #f6e6d2; } .stat-orange .stat-icon { background: #fde4c4; color: var(--orange); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 18px;
    box-shadow: var(--shadow);
    min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { display: flex; align-items: center; gap: 14px; font-size: 19px; font-weight: 600; }
.card-flush { padding-left: 0; padding-right: 0; padding-bottom: 6px; }
.card-flush .card-head { padding: 0 18px; }
.link { display: inline-flex; align-items: center; gap: 8px; color: #1f5fbf; font-size: 14px; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---------- Bar chart ---------- */
.bar-chart { display: flex; gap: 12px; height: 210px; }
.y-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 13px; color: var(--text-2); text-align: right; padding-bottom: 28px; margin-top: -8px; width: 38px; }
.y-axis span { line-height: 16px; }
.plot { position: relative; flex: 1; border-left: 1px solid #cfd7e0; }
.gridlines { position: absolute; inset: 0 0 28px 0; display: flex; flex-direction: column; justify-content: space-between; }
.gridlines i { border-top: 1px dashed #e3e8ee; }
.gridlines i:last-child { border-top: 1px solid #cfd7e0; }
.bars { position: absolute; inset: 0; display: flex; gap: 4px; padding: 0 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar {
    width: 60%; max-width: 30px;
    background: var(--teal);
    border-radius: 2px 2px 0 0;
    transition: opacity .15s;
    cursor: pointer;
}
.bar:hover { opacity: .8; }
.bar-label { height: 28px; padding-top: 10px; font-size: 12px; color: var(--text-2); white-space: nowrap; }

.chart-tip {
    position: fixed; z-index: 60; pointer-events: none;
    background: var(--navy); color: #fff;
    padding: 6px 10px; border-radius: 6px; font-size: 13px; font-weight: 500;
    transform: translate(-50%, calc(-100% - 10px));
    white-space: nowrap;
}

/* ---------- Donut ---------- */
.donut-wrap { display: flex; align-items: center; gap: 22px; padding: 4px 4px 0 10px; }
.donut { position: relative; width: 200px; height: 200px; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { transition: stroke-width .15s; cursor: pointer; }
.donut circle:hover { stroke-width: 7.5; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; color: var(--text-2); line-height: 1.5; }
.donut-center strong { font-size: 18px; color: var(--text); font-weight: 700; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; gap: 22px; }
.legend li { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: start; }
.legend i { width: 18px; height: 18px; border-radius: 50%; margin-top: 2px; }
.legend div { display: flex; flex-direction: column; line-height: 1.35; }
.legend span { font-size: 16px; }
.legend strong { font-size: 19px; font-weight: 500; }
.legend em { font-style: normal; color: var(--text-2); font-size: 15px; padding-top: 10px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-weight: 500; color: var(--text-2); background: #f5f7fa; padding: 10px 18px; font-size: 14px; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 28px; }
.table td { padding: 12px 18px; border-top: 1px solid #edf0f4; white-space: nowrap; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover td { background: #fafbfc; }

.pill { display: inline-block; padding: 5px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; }
.pill-green { background: var(--green-50); color: #138a47; }
.pill-orange { background: #fde7cf; color: #d86a00; }

/* ---------- Printers ---------- */
.printers { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 6px; }
.printers li { display: grid; grid-template-columns: 1.1fr 1fr auto; align-items: center; padding: 10px 16px; font-size: 16px; }
.printers li + li { border-top: 1px solid #edf0f4; }
.printers .state { margin-left: 0; font-weight: 500; font-size: 15px; }
.printer-pending { font-size: 15px; color: var(--text-2); }
.printer-footer { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.alert {
    flex: 1; min-width: 220px;
    display: flex; align-items: center; gap: 12px;
    background: var(--red-50); color: #c62828;
    border-radius: 6px; padding: 12px 16px; font-size: 15px;
}
.alert .icon { background: var(--red); color: #fff; border-radius: 50%; padding: 1px; stroke-width: 2.6; }

/* ---------- Attendants ---------- */
.attendants { display: grid; grid-template-columns: repeat(3, 1fr); }
.attendant { display: flex; align-items: center; gap: 20px; padding: 4px 22px; border-left: 1px solid var(--border); }
.attendant:first-child { border-left: 0; padding-left: 4px; }
.attendant div { display: flex; flex-direction: column; line-height: 1.5; }
.attendant strong { font-weight: 600; font-size: 15px; }
.attendant span { font-size: 16px; }
.attendant em { font-style: normal; font-size: 16px; }

.avatar { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; font-weight: 600; flex-shrink: 0; }
.avatar-light { width: 48px; height: 48px; background: #e9eef4; color: var(--navy); font-size: 20px; }
.avatar-blue { background: var(--blue-50); color: #1f5fbf; }
.avatar-purple { background: var(--purple-50); color: #6a4fd1; }
.avatar-teal { background: var(--teal-50); color: var(--teal-dark); }

/* ---------- Quick actions ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.quick-actions .btn { padding: 16px 12px; }

/* ---------- Placeholder pages ---------- */
.empty-state { text-align: center; padding: 64px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-icon { width: 72px; height: 72px; border-radius: 16px; background: var(--teal-50); color: var(--teal); display: grid; place-items: center; margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin-bottom: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1400px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .status-bar { grid-template-columns: repeat(2, auto); row-gap: 10px; justify-content: start; }
    .status-item:nth-child(3) { border-left: 0; padding-left: 0; }
}

@media (max-width: 1200px) {
    .grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .sidebar.open + .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 30, 50, .45); z-index: 30; }
    .icon-btn.sidebar-close, .icon-btn.menu-toggle { display: inline-flex; }
    .main { margin-left: 0; }
}

@media (max-width: 720px) {
    .main { padding: 12px 16px 20px; }
    .page-title h1 { font-size: 26px; }
    .page-title p { font-size: 16px; }
    .topbar-actions { gap: 10px; width: 100%; }
    .picker { flex: 1 1 150px; min-width: 0; gap: 10px; padding: 8px 12px; }
    .bars { gap: 2px; padding: 0 2px; }
    .bar { width: 70%; }
    .bar-label { font-size: 10px; }
    .bar-col:nth-child(even) .bar-label { visibility: hidden; }
    .topbar-actions .btn-lg { flex: 1; }
    .stats { grid-template-columns: 1fr; }
    .stat-value { font-size: 26px; }
    .status-bar { grid-template-columns: 1fr; }
    .status-item { border-left: 0; padding: 0; }
    .donut-wrap { flex-direction: column; align-items: stretch; }
    .donut { align-self: center; }
    .attendants { grid-template-columns: 1fr; gap: 14px; }
    .attendant { border-left: 0; padding: 0; }
    .quick-actions { grid-template-columns: 1fr; }
}

/* ---------- Dashboard: live data additions ---------- */
.state-muted { color: var(--muted); }
.mini-delta { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.mini-delta.up { background: var(--green-50); color: #138a47; }
.mini-delta.down { background: var(--red-50); color: #c62828; }
.chart-empty { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 12px 14px; border-radius: 10px; background: #f5f7fa; color: var(--muted); font-size: 14px; }
.pill-purple { background: #efeafd; color: #6a4fd1; }
a.bell { color: var(--text-2); }
.legend strong { white-space: nowrap; font-size: 17px; }

/* ---------- WhatsApp orders ---------- */
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: #f57c00; color: #fff; font-size: 12px; font-style: normal; font-weight: 700; text-align: center; }
.wa-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; padding: 14px; margin-bottom: 16px; }

/* ---------- Pop-up alerts (SweetAlert2) ---------- */
.app-swal { font-family: inherit; border-radius: 14px; padding: 24px 22px 22px; }
.app-swal .swal2-title { color: var(--navy); font-size: 22px; font-weight: 700; }
.app-swal .swal2-html-container { color: var(--text-2); font-size: 15px; line-height: 1.5; }
.app-swal .swal2-actions { gap: 10px; margin-top: 22px; }
.app-swal .swal2-timer-progress-bar { background: var(--teal); }
.app-swal .pay-summary { display: grid; gap: 8px; margin: 4px auto 0; max-width: 300px; text-align: left; }
.app-swal .pay-summary div { display: flex; justify-content: space-between; gap: 16px; }
.app-swal .pay-summary dt { color: var(--muted); }
.app-swal .pay-summary dd { margin: 0; font-weight: 600; color: var(--text); }
.app-swal .pay-summary .is-change { padding-top: 8px; border-top: 1px dashed var(--border); }
.app-swal .pay-summary .is-change dd { color: #138a47; font-size: 20px; }
