@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Neutral surfaces — true grayscale (not blue-tinted) for an authentic Geist feel */
    --bg: #0a0a0a;
    --surface: #141414;
    --border: #262626;
    --text: #fafafa;
    --text-muted: #a1a1a1;

    /* Accent — tuned teal, ties to "fresh food" without reading as generic neon */
    --primary: #1fceb8;
    --primary-hover: #4ee2ce;
    --primary-light: rgba(31, 206, 184, 0.14);
    /* Darker teal shades — used wherever WHITE text sits directly on the accent
       (buttons, gradient headers). var(--primary) itself is too light for white
       text to hit 4.5:1, but reads great as text/icons/links on dark surfaces. */
    --primary-strong: #117165;
    --primary-strong-hover: #137c6e;

    /* Status colors */
    --danger: #f2555f;
    --danger-light: rgba(242, 85, 95, 0.12);
    --success: #22c58f;
    --success-light: rgba(34, 197, 143, 0.12);
    --warning: #f2ae2e;
    --warning-light: rgba(242, 174, 46, 0.14);

    /* Shadow — minimal, border-led separation over heavy glow */
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.35);

    /* Radius — small, consistent scale */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    /* Stronger border — form controls need this for their boundary to meet
       3:1 contrast, since an input's fill is identical to its parent card's fill. */
    --border-strong: #666666;

    /* Type scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;

    color-scheme: dark;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Keyboard-only focus rings (mouse clicks stay clean) */
a:focus-visible,
button:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ── Navbar ── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--space-4);
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--text);
}

.navbar-brand svg { flex-shrink: 0; }

.navbar-actions { display: flex; align-items: center; gap: var(--space-3); }

.role-badge {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
}

.role-badge.admin {
    background: rgba(139, 92, 246, 0.18);
    color: #a78bfa;
}

body.role-customer .admin-only { display: none !important; }
body.role-admin .customer-only { display: none !important; }
html.role-customer .admin-only { display: none !important; }
html.role-admin .customer-only { display: none !important; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: var(--space-3) var(--space-4);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--primary-strong);
    color: #ffffff;
    width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-strong-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    width: auto;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-success {
    background: var(--success-light);
    color: var(--success);
}
.btn-success:hover:not(:disabled) { background: rgba(34, 197, 143, 0.22); }

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: rgba(242, 85, 95, 0.22); }

.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }

.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: 1.0625rem;
    margin-top: var(--space-6);
}

/* ── Layout (mobile-first: base = small screens) ── */
.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.page-header p {
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-size: 0.9375rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 1.25rem;
}

.grid-full { grid-column: 1 / -1; }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-6);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: var(--text-base);
    font-weight: 600;
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    flex-shrink: 0;
}

.card-icon.purple { background: rgba(139, 92, 246, 0.18); color: #a78bfa; }
.card-icon.amber { background: rgba(217, 119, 6, 0.18); color: #fbbf24; }
.card-icon.blue { background: rgba(37, 99, 235, 0.2); color: #60a5fa; }

/* ── Forms ── */
.form-group { margin-bottom: var(--space-4); }

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
}

input, select, textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: inherit;
    font-size: var(--text-sm);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 206, 184, 0.5);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ── Alerts / Results ── */
.alert {
    margin-top: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
}

.alert-success { background: var(--success-light); color: var(--success); }
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-info { background: var(--primary-light); color: var(--primary); }

/* ── Customer ID banner ── */
.customer-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #0d5c52 0%, var(--primary-strong) 100%);
    color: #ffffff;
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
}

.customer-banner-label {
    font-size: 0.8125rem;
    opacity: 0.85;
    font-weight: 500;
}

.customer-banner-id {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* ── Bill stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
    text-align: center;
}

.stat-card.highlight {
    background: var(--primary-light);
    border-color: rgba(31, 206, 184, 0.35);
}

.stat-card.danger {
    background: var(--danger-light);
    border-color: rgba(242, 85, 95, 0.3);
}

.stat-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.highlight .stat-value { color: var(--primary); }

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    margin-top: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

thead { background: var(--bg); }

th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

.empty {
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-style: italic;
    padding: var(--space-6);
    text-align: center;
}

.subsection-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 1.25rem 0 0.5rem;
}

.subsection-title:first-of-type { margin-top: 0; }

/* ── Auth pages ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: linear-gradient(160deg, #050505 0%, var(--surface) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-card-header {
    background: linear-gradient(135deg, #0d5c52 0%, var(--primary-strong) 100%);
    color: #ffffff;
    padding: var(--space-8) var(--space-8) var(--space-6);
    text-align: center;
}

.auth-logo {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.auth-card-header h1 {
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.auth-card-header p {
    font-size: var(--text-sm);
    opacity: 0.85;
    margin-top: 0.25rem;
}

.auth-card-body { padding: var(--space-8); }

.auth-footer {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: 1.25rem;
}

/* ── Today's Meals (Customer) ── */
.meals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: var(--space-4);
    margin-top: var(--space-2);
}

.meal-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.meal-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.meal-card-head h3 {
    font-size: var(--text-base);
    font-weight: 700;
}

.meal-time {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}

.meal-menu {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
    flex-grow: 1;
}

.meal-status {
    text-align: center;
    padding: 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
}

.meal-status.pending  { background: var(--warning-light); color: var(--warning); }
.meal-status.approved { background: var(--success-light); color: var(--success); }
.meal-status.rejected { background: var(--danger-light); color: var(--danger); }

/* ── Today's Menu Manager (Admin, simple mode) ── */
.menu-selector-label {
    font-size: var(--text-sm) !important;
}

.menu-day-selector {
    font-size: var(--text-lg);
    font-weight: 600;
    padding: 0.875rem 1rem;
    border-width: 2px;
    cursor: pointer;
}

.menu-simple-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-top: 1.25rem;
}

.menu-simple-block h3 {
    font-size: 1.0625rem;
    font-weight: 700;
    margin-bottom: var(--space-4);
}

.menu-simple-block .form-group:last-child { margin-bottom: 0; }

.menu-simple-block label {
    font-size: var(--text-sm) !important;
    font-weight: 600 !important;
}

.menu-simple-block textarea {
    font-size: var(--text-base);
    resize: vertical;
}

.menu-simple-block input[type="time"] {
    font-size: 1.0625rem;
    padding: 0.75rem 1rem;
}

/* ── Larger screens: restore roomier spacing ── */
@media (min-width: 640px) {
    .form-row { grid-template-columns: 1fr 1fr; }
    .page { padding: var(--space-8) var(--space-6) 3rem; }
    .navbar { padding: 0 var(--space-6); }
}

/* Narrowest phones (≤400px): recover a few px in the navbar so
   brand + role-badge + sign-out never crowd each other */
@media (max-width: 400px) {
    .navbar { padding: 0 var(--space-3); }
    .navbar-brand { font-size: var(--text-base); gap: 0.4rem; }
    .navbar-actions { gap: var(--space-2); }
    .role-badge { padding: 0.25rem 0.5rem; }
    .btn-ghost.btn-sm { padding: 0.375rem 0.625rem; }
}
