/* ============================================================
   Restaurant POS — "Ticket & Adire" design system
   Indigo (adire dye) as the dominant chrome color, parchment
   tickets as the working surface, gold for money, pepper for
   urgency, leaf for "ready/available".
   ============================================================ */

:root {
    color-scheme: light;
    /* --- palette --- */
    --indigo-900: #16233F;
    --indigo-700: #223764;
    --indigo-600: #2C4478;
    --parchment: #FBF3E4;
    --parchment-dim: #F1E7D2;
    --gold: #E2A63B;
    --gold-dark: #B9822A;
    --pepper: #C2451F;
    --pepper-dark: #9B3417;
    --leaf: #3D7A52;
    --leaf-dark: #2C5B3D;
    --ink: #241F19;
    --ink-soft: #6B6255;
    --line: #E4D6BC;
    /* --- type --- */
    --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
    --font-body: 'IBM Plex Sans', -apple-system, Segoe UI, Roboto, sans-serif;
    --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    --radius: 10px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    /* Reserve scrollbar space up front so a page growing past the viewport
       (e.g. a long order list) never shifts the whole layout sideways when
       the scrollbar appears. Falls back harmlessly on older browsers. */
    scrollbar-gutter: stable;
}

/* Slim, themed scrollbars everywhere (page, order/cart lists, kitchen board,
   admin tables, etc.) instead of the bulky OS-native ones - Firefox via
   scrollbar-width/scrollbar-color, Chromium/Safari via ::-webkit-scrollbar.
   .category-rail below still hides its scrollbar entirely (more specific
   selector wins), since that one scrolls horizontally by design and doesn't
   need a visible track. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dark) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--gold-dark);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

    ::-webkit-scrollbar-thumb:hover {
        background-color: var(--pepper-dark);
    }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--indigo-900);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* Page background is indigo, so headings default to parchment; anything
   inside a .card/.ticket (parchment surface) flips back to dark ink. */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 12px;
    color: var(--parchment);
}

.card h1, .card h2, .card h3, .card h4,
.ticket h1, .ticket h2, .ticket h3, .ticket h4 {
    color: var(--ink);
}

a {
    color: inherit;
}

:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

/* ---------------- POS Terminal layout ---------------- */

.pos-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    align-items: start;
}

.pos-menu-panel {
    background: var(--parchment);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}

/* Category rail */
.category-rail {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
}

    .category-rail::-webkit-scrollbar {
        display: none;
    }

.category-pill {
    flex-shrink: 0;
    border: 1px solid var(--line);
    background: var(--parchment-dim);
    color: var(--ink-soft);
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
}

    .category-pill:hover {
        background: var(--line);
        color: var(--ink);
    }

    .category-pill.active {
        background: var(--indigo-900);
        color: var(--parchment);
        border-color: var(--indigo-900);
    }

.dish-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 900px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }

    .dish-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---------------- Order ticket panel ---------------- */

.order-panel {
    position: sticky;
    top: 16px;
}

.order-type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: var(--parchment-dim);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 10px;
    font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
}

/* Payment method toggle reuses .order-type-toggle's look but has 3 buttons
   (Cash/Card/Transfer), not 2 - override the column count so the third
   button sits inline instead of wrapping onto its own row. */
#payment-method-toggle {
    grid-template-columns: repeat(2, 1fr);
}

.order-type-toggle button {
    border: none;
    background: transparent;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 8px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
}

    .order-type-toggle button.active {
        background: var(--indigo-900);
        color: var(--parchment);
    }

.order-fields {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

/* Receipt-style line items */
.receipt-line {
    margin-bottom: 10px;
}

    .receipt-line .receipt-row {
        display: flex;
        align-items: baseline;
        gap: 6px;
    }

    .receipt-line .receipt-name {
        font-weight: 600;
        font-size: 0.88rem;
        white-space: nowrap;
    }

    .receipt-line .receipt-leader {
        flex: 1;
        border-bottom: 1px dotted var(--line);
        transform: translateY(-3px);
    }

    .receipt-line .receipt-amount {
        font-family: var(--font-mono);
        font-variant-numeric: tabular-nums;
        font-size: 0.88rem;
        font-weight: 600;
    }

    .receipt-line .receipt-meta {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 4px;
    }

    .receipt-line .receipt-unit {
        color: var(--ink-soft);
        font-family: var(--font-mono);
        font-size: 0.78rem;
    }

.qty-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

    .qty-control button {
        width: 22px;
        height: 22px;
        padding: 0;
        line-height: 1;
        border-radius: 5px;
        font-size: 0.85rem;
    }

    .qty-control .qty-value {
        font-family: var(--font-mono);
        min-width: 16px;
        text-align: center;
        font-weight: 600;
    }

/* Totals block, same dotted-leader receipt language */
.total-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.88rem;
    margin-bottom: 4px;
}

    .total-row .fill {
        flex: 1;
        border-bottom: 1px dotted var(--line);
        transform: translateY(-3px);
    }

    .total-row.grand {
        font-size: 1.2rem;
        font-weight: 700;
        color: var(--gold-dark);
        margin-top: 8px;
    }

        .total-row.grand .fill {
            border-bottom-color: var(--gold-dark);
        }

.order-empty {
    color: var(--ink-soft);
    font-size: 0.88rem;
    text-align: center;
    padding: 24px 0;
}

/* The order/cart line list can grow long as items are added. Without a cap
   it pushes the whole ticket - and the whole page - taller than the
   viewport, which brings in a page-level scrollbar and shifts the entire
   layout sideways by its width. Capping the height and scrolling inside
   this element instead keeps the page height (and the totals/checkout
   button below it) stable regardless of how many items are in the order.
   scrollbar-gutter here does the same job for this element's own scrollbar
   that the one on <html> does for the page's. */
#order-lines, #cart-lines {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding-right: 2px;
}

/* ---------------- Navbar ---------------- */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: radial-gradient(circle at 14px 14px, rgba(226,166,59,0.16) 1.5px, transparent 1.6px), var(--indigo-900);
    background-size: 28px 28px, auto;
    color: var(--parchment);
    padding: 16px 28px;
    flex-wrap: wrap;
    border-bottom: 3px solid var(--gold);
}

    .navbar .brand {
        color: var(--parchment);
        font-family: var(--font-display);
        font-weight: 600;
        font-size: 1.3rem;
        text-decoration: none;
        letter-spacing: -0.01em;
        display: flex;
        align-items: center;
        gap: 8px;
    }

        .navbar .brand .brand-mark {
            color: var(--gold);
        }

.nav-links {
    display: flex;
    flex-wrap: wrap;
}

    .nav-links a {
        color: var(--parchment);
        text-decoration: none;
        margin-left: 22px;
        font-size: 0.88rem;
        font-weight: 500;
        letter-spacing: 0.01em;
        padding-bottom: 3px;
        border-bottom: 2px solid transparent;
        transition: border-color 0.15s ease, color 0.15s ease;
    }

        .nav-links a:hover {
            color: var(--gold);
            border-bottom-color: var(--gold);
        }

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(251,243,228,0.35);
    border-radius: 7px;
    color: var(--parchment);
    font-size: 1.2rem;
    line-height: 1;
    padding: 6px 12px;
    cursor: pointer;
}

.page-container {
    padding: 28px 24px 64px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ---------------- Ticket surface (the signature element) ----------------
   Every "card" in this app reads as an order ticket: parchment paper,
   a punched clip-circle at the top edge, and a dashed perforation line
   that separates the body from a totals/footer section. */

.card, .ticket {
    background: var(--parchment);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    position: relative;
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(22,35,63,0.06);
}

.ticket {
    padding-top: 26px;
}

    .ticket::before {
        content: "";
        position: absolute;
        top: -7px;
        left: 50%;
        transform: translateX(-50%);
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: var(--indigo-900);
        box-shadow: 0 0 0 3px var(--parchment);
    }

.perforation {
    border: none;
    border-top: 2px dashed var(--line);
    margin: 14px 0;
}

/* ---------------- Buttons ---------------- */

.btn {
    display: inline-block;
    border: none;
    border-radius: 7px;
    padding: 9px 18px;
    background: var(--gold);
    color: var(--indigo-900);
    cursor: pointer;
    /* font-family: var(--font-body);*/
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: 0.01em;
    transition: background 0.15s ease, transform 0.1s ease;
    font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
}

    .btn:hover {
        background: var(--gold-dark);
    }

    .btn:active {
        transform: translateY(1px);
    }

    .btn.secondary {
        background: var(--parchment-dim);
        color: var(--ink);
        border: 1px solid var(--line);
    }

        .btn.secondary:hover {
            background: var(--line);
        }

    .btn.danger {
        background: var(--pepper);
        color: #fff;
    }

        .btn.danger:hover {
            background: var(--pepper-dark);
        }

    .btn.success {
        background: var(--leaf);
        color: #fff;
    }

        .btn.success:hover {
            background: var(--leaf-dark);
        }

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* ---------------- Layout helpers ---------------- */

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.grid-3 {
    grid-template-columns: repeat(4, 1fr);
}

/* Two-pane working layouts (POS terminal, online storefront): main panel + a
   side ticket that stacks below the main panel and un-stickies on narrow
   screens so it doesn't eat the viewport on a phone. */
.split-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: 2fr 1fr;
    align-items: start;
}

.side-panel {
    position: sticky;
    top: 16px;
}

input, select, textarea {
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 0.9rem;
    font-family: var(--font-body);
    width: 100%;
    background: #fff;
    color: var(--ink);
}

    input:focus, select:focus, textarea:focus {
        border-color: var(--gold-dark);
    }

table {
    width: 100%;
    border-collapse: collapse;
}

    table th, table td {
        text-align: left;
        padding: 9px 10px;
        border-bottom: 1px solid var(--line);
        font-size: 0.9rem;
    }

    table th {
        color: var(--ink-soft);
        font-weight: 600;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

.money {
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Opaque codes (order numbers) - fine to use the mono/coding face since
   there's no currency symbol or zero/O ambiguity risk here. */
.ticket-code {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ---------------- Status badges ---------------- */

.badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

    .badge.pending {
        background: #FCEBD9;
        color: var(--gold-dark);
    }

    .badge.preparing {
        background: #DCE7F7;
        color: var(--indigo-700);
    }

    .badge.ready {
        background: #DCEEE1;
        color: var(--leaf-dark);
    }

    .badge.completed {
        background: #EAE3D3;
        color: var(--ink-soft);
    }

    .badge.cancelled {
        background: #F7DCD5;
        color: var(--pepper-dark);
    }

/* Left-edge urgency rail on kitchen tickets */
.ticket.status-pending {
    border-left: 4px solid var(--gold);
}

.ticket.status-preparing {
    border-left: 4px solid var(--indigo-700);
}

.ticket.status-ready {
    border-left: 4px solid var(--leaf);
}

/* ---------------- Toasts ---------------- */

#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999;
}

.toast {
    background: var(--indigo-900);
    color: var(--parchment);
    padding: 11px 18px;
    border-radius: 7px;
    font-size: 0.88rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    animation: fadein 0.2s ease-in;
    border-left: 3px solid var(--gold);
}

    .toast.success {
        border-left-color: var(--leaf);
    }

    .toast.error {
        border-left-color: var(--pepper);
    }

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spinner {
    text-align: center;
    /*padding: 48px;*/
    color: var(--ink-soft);
}

    .spinner.on-page {
        color: var(--parchment-dim);
    }

/* ---------------- Hub page ---------------- */

.hub-hero {
    text-align: center;
    padding: 56px 20px 36px;
    color: var(--parchment);
}

    .hub-hero h1 {
        color: var(--parchment);
        font-size: clamp(2rem, 4vw, 2.8rem);
    }

    .hub-hero p {
        color: var(--parchment-dim);
        font-size: 1.05rem;
        max-width: 480px;
        margin: 0 auto;
    }

.hub-card {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .hub-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 24px rgba(22,35,63,0.18);
    }

    .hub-card .icon {
        font-size: 1.8rem;
    }

    .hub-card h2 {
        font-size: 1.15rem;
        margin: 10px 0 4px;
    }

    .hub-card p {
        color: var(--ink-soft);
        font-size: 0.9rem;
        margin: 0;
    }

/* ---------------- Menu / POS item cards ---------------- */

.dish-card {
    cursor: pointer;
    text-align: left;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

    .dish-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(22,35,63,0.14);
        border-color: var(--gold-dark);
    }

    .dish-card .dish-name {
        font-weight: 600;
    }

    .dish-card .dish-price {
        color: var(--gold-dark);
        margin-top: 4px;
    }

.tab-btn {
    margin-right: 8px;
    margin-bottom: 8px;
}

/*.qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .qty-control button {
        padding: 2px 10px;
        line-height: 1.4;
    }*/

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .navbar {
        padding: 14px 18px;
    }

    .nav-links a {
        margin-left: 0;
        margin-right: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------------- Auth pages ---------------- */

.auth-shell {
    max-width: 400px;
    margin: 48px auto;
}

    .auth-shell .subtitle {
        color: var(--ink-soft);
        font-size: 0.88rem;
        margin: -6px 0 16px;
    }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 22px;
    font-size: 0.85rem;
    color: var(--parchment-dim);
}

.role-pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: rgba(226,166,59,0.18);
    color: var(--gold);
    border: 1px solid rgba(226,166,59,0.35);
}
