/* ============================================================
   Eatza — Main Stylesheet
   Clean, minimal — inspired by Stripe Dashboard
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Colours */
    --bg:           #f7f7fb;
    --surface:      #ffffff;
    --surface-2:    #f4f4f5;
    --border:       #e4e4e7;
    --border-light: #f4f4f5;
    --text:         #09090b;
    --text-2:       #52525b;
    --text-3:       #a1a1aa;
    --accent:       #635bff;
    --accent-light: #eeeeff;
    --accent-dark:  #4f46e5;
    --success:      #10b981;
    --success-light:#d1fae5;
    --warning:      #f59e0b;
    --warning-light:#fef3c7;
    --danger:       #ef4444;
    --danger-light: #fee2e2;

    /* Layout */
    --sidebar-w:    248px;
    --header-h:     60px;
    --radius:       12px;
    --radius-sm:    8px;
    --radius-lg:    18px;

    /* Shadows */
    --shadow-xs:    0 1px 3px rgba(0,0,0,.06);
    --shadow-sm:    0 2px 8px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.03);
    --shadow-md:    0 8px 24px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);

    /* Type */
    --font:         'DM Sans', sans-serif;
    --font-mono:    'DM Mono', monospace;
}

/* ── Base ─────────────────────────────────────────────────── */
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

/* ── Restaurant context bar ──────────────────────────────── */

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border-light);
}

.brand-mark { display: flex; align-items: center; }
.brand-name { font-weight: 600; font-size: .95rem; letter-spacing: -.01em; color: var(--text); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 2px; }

.nav-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-3);
    padding: 10px 10px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: .875rem;
    font-weight: 400;
    transition: background .12s, color .12s;
    position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.nav-item:visited { color: var(--text-2); }
.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
    background: var(--accent-light);
    color: var(--accent-dark);
    font-weight: 500;
}
.nav-item.active svg { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: .65rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 20px;
    font-family: var(--font-mono);
}

.nav-item-locked { opacity: .55; }
.nav-item-locked:hover { opacity: .75; }
.nav-lock { font-size: .65rem; margin-left: auto; }

/* Collapsible nav groups */
.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    border-top: 1px solid var(--border-light);
    cursor: pointer;
    padding: 14px 10px 6px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    transition: color .12s;
    line-height: 1;
    margin-top: 4px;
}
.nav-group-header:hover { color: var(--text-2); }
.nav-group-header:focus { outline: none; }
.nav-group-header:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.nav-group:not(.is-collapsed) > .nav-group-header { color: var(--accent); }
.nav-group-chevron { width: 12px; height: 12px; flex-shrink: 0; transition: transform .2s ease; }
.nav-group.is-collapsed .nav-group-chevron { transform: rotate(-90deg); }
.nav-group-body { overflow: hidden; max-height: 600px; transition: max-height .22s ease; display: flex; flex-direction: column; gap: 1px; padding-left: 20px; }
.nav-group.is-collapsed .nav-group-body { max-height: 0; }
.nav-group.nav-init .nav-group-body { transition: none !important; }
/* First collapsible group sits immediately after Dashboard — no top border needed */
.nav-group-no-top-border > .nav-group-header { border-top: none; margin-top: 8px; }

/* Divider shown in sidebar between admin-level nav and the restaurant being managed */
/* Restaurant context bar — shown when superadmin/reseller is managing a restaurant */
.nav-rest-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 10px 0 2px;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    border-left: 3px solid var(--accent);
    text-decoration: none;
}
.nav-rest-bar-logo {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-rest-bar-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.nav-rest-bar-logo-init {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    border-radius: 8px;
}
.nav-rest-bar-info {
    flex: 1;
    min-width: 0;
}
.nav-rest-bar-label {
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 3px;
}
.nav-rest-bar-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.nav-rest-bar-close {
    flex-shrink: 0;
    color: var(--text-3);
    opacity: .55;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    transition: opacity .15s, background .15s;
    text-decoration: none;
}
.nav-rest-bar-close:hover {
    opacity: 1;
    background: rgba(0,0,0,.07);
    color: var(--text);
}

/* Admin notices banner */
.admin-notices-bar { display:flex; flex-direction:column; }
.admin-notice {
    display:flex; align-items:flex-start; gap:10px;
    padding:11px 16px; font-size:.82rem; line-height:1.5;
    border-left:4px solid #d97706;
}
.admin-notice--info     { background:#eeeeff; border-left-color:#635bff; color:#3730a3; }
.admin-notice--warning  { background:#fef3c7; border-left-color:#d97706; color:#92400e; }
.admin-notice--critical { background:#fee2e2; border-left-color:#ef4444; color:#991b1b; }
.admin-notice-icon { font-size:.9rem; flex-shrink:0; margin-top:1px; }
.admin-notice-body { flex:1; }
.admin-notice-body strong { font-weight:600; }
.admin-notice-dismiss {
    background:none; border:none; cursor:pointer; font-size:1.2rem; line-height:1;
    color:currentColor; opacity:.5; padding:0 4px; flex-shrink:0; align-self:center;
}
.admin-notice-dismiss:hover { opacity:1; }

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border-light);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 6px;
    border-radius: var(--radius-sm);
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .8rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: var(--text-3); }
.logout-btn { color: var(--text-3); display: flex; padding: 4px; border-radius: 4px; transition: color .12s, background .12s; }
.logout-btn:hover { color: var(--danger); background: var(--danger-light); text-decoration: none; }
.logout-btn svg { width: 15px; height: 15px; }

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

.page-header {
    height: var(--header-h);
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 50;
    white-space: nowrap;
    overflow: hidden;
}

.page-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -.01em;
    flex: 1;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.page-body { padding: 28px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title { font-size: .9rem; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: .8rem; color: var(--text-3); margin-top: 2px; }

/* ── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.stat-label { font-size: .6875rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-value { font-size: 1.875rem; font-weight: 300; color: var(--text); margin: 6px 0 2px; letter-spacing: -.03em; }
.stat-meta { font-size: .75rem; color: var(--text-3); }
.stat-meta.up { color: var(--success); }
.stat-meta.down { color: var(--danger); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .12s, color .12s, box-shadow .12s, transform .1s;
    line-height: 1.4;
    white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 1px 4px rgba(99,91,255,.25); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; text-decoration: none; transform: translateY(-1px); box-shadow: 0 3px 10px rgba(99,91,255,.3); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--bg); color: var(--text); text-decoration: none; border-color: var(--text-3); }
.btn-danger { background: var(--danger-light); color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: var(--danger); color: #fff; text-decoration: none; border-color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: .8125rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .8125rem; font-weight: 500; color: var(--text-2); margin-bottom: 5px; letter-spacing: -.01em; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    font-family: var(--font);
    font-size: .875rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
    box-shadow: var(--shadow-xs);
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,91,255,.14);
}
.form-control::placeholder { color: var(--text-3); }
.form-hint { font-size: .75rem; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: .75rem; color: var(--danger); margin-top: 4px; }

/* ── Alerts / Flash ─────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    margin-bottom: 16px;
}
.alert-error   { background: var(--danger-light);  color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #6ee7b7; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
    text-align: left;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-2);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-green  { background: var(--success-light); color: #065f46; }
.badge-yellow { background: var(--warning-light); color: #92400e; }
.badge-red    { background: var(--danger-light);  color: #b91c1c; }
.badge-purple { background: var(--accent-light);  color: var(--accent-dark); }
.badge-grey   { background: var(--surface-2);     color: var(--text-3); }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-3);
}
.empty-state svg { width: 40px; height: 40px; opacity: .3; margin: 0 auto 12px; display: block; }
.empty-state h3 { font-size: .95rem; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.empty-state p  { font-size: .85rem; }

/* ── Login page ─────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 44px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}
.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    text-decoration: none;
}
.login-logo .brand-name { font-size: 1.1rem; font-weight: 600; }
.login-heading { font-size: 1.2rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.login-sub     { font-size: .85rem; color: var(--text-3); margin-bottom: 24px; }
.login-footer  { text-align: center; margin-top: 20px; font-size: .8rem; color: var(--text-3); }

/* ── Page Heading ────────────────────────────────────────── */
.page-heading {
    margin-bottom: 24px;
}
.page-heading-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -.025em;
    line-height: 1.25;
}
.page-heading-sub {
    font-size: .85rem;
    color: var(--text-3);
    margin-top: 3px;
}

/* ── Divider ─────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    color: var(--text-3);
}
.breadcrumb a { color: var(--text-3); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { opacity: .4; }
.breadcrumb-current { color: var(--text-2); font-weight: 500; }

/* ── Utilities ──────────────────────────────────────────── */
.flex   { display: flex; }
.items-center { align-items: center; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.ml-auto { margin-left: auto; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.mb-4   { margin-bottom: 16px; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--text-3); }
.text-danger { color: var(--danger); }
.font-mono  { font-family: var(--font-mono); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ═══════════════════════════════════════════════════════════
   Mobile Responsive — ≤ 768px
   ═══════════════════════════════════════════════════════════ */

/* ── Hamburger button (mobile only) ───────────────────────── */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 52px;
    height: var(--header-h);
    background: transparent;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 300;
    color: var(--text-2);
    padding: 0;
    flex-shrink: 0;
}
.hamburger-btn:hover { color: var(--text); }
.hamburger-btn svg { width: 20px; height: 20px; display: block; }

/* ── Sidebar slide-over overlay ───────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 249;
}

@media (max-width: 768px) {

    /* Show hamburger */
    .hamburger-btn { display: flex; }

    /* Sidebar: off-screen left, slides in */
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-w)));
        transition: transform .25s cubic-bezier(.4,0,.2,1);
        z-index: 250;
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0,0,0,.18);
    }
    .sidebar-overlay.sidebar-open { display: block; }

    /* Main content: full width, no sidebar offset */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Page header: indent past hamburger */
    .page-header { padding-left: 56px; }

    /* Body: tighter padding on mobile */
    .page-body { padding: 16px; }

    /* Stats grid: 2 col */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* Generic grids stack to 1 col */
    .grid-2,
    .grid-3 { grid-template-columns: 1fr; }

    /* Tables scroll horizontally */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap table { min-width: 520px; }

}

@media (max-width: 480px) {
    .page-body { padding: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Toggle switch ─────────────────────────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 26px; transition: background .2s; }
.toggle-slider::after { content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle-switch input:checked + .toggle-slider { background: var(--accent, #635bff); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(18px); }
