/* DSRT Dining POS — dark register theme (booking-POS navy family + dining cyan accent) */

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

:root {
    --bg: #12121f;
    --surface: #1a1a2e;
    --surface-2: #16213e;
    --line: #0f3460;
    --line-soft: rgba(255, 255, 255, 0.08);
    --text: #e6edf3;
    --text-dim: #9aa4b2;
    --accent: #00d4ff;
    --accent-dark: #0097b8;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #e5484d;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100svh;
    height: 100dvh; /* iPad Safari chrome fix (booking-POS pattern) */
    overflow: hidden;
}

.hidden { display: none !important; }

button { font-family: inherit; }

/* ─── Login gate ───────────────────────────────────────────── */

.login-gate {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 380px;
    max-width: 92%;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 36px 40px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.login-card h1 {
    font-size: 24px;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 4px;
}

.login-card .subtitle {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 22px;
}

.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 11px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.login-error {
    display: none;
    background: rgba(229, 72, 77, 0.12);
    border: 1px solid rgba(229, 72, 77, 0.5);
    color: #ff8f92;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.login-error.visible { display: block; }

/* ─── Buttons ──────────────────────────────────────────────── */

.btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: filter 0.15s, background 0.15s;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(1.12); }

.btn-primary {
    background: var(--accent);
    color: #04222b;
    padding: 13px 18px;
    font-size: 16px;
}

.btn-success { background: var(--success); color: #fff; padding: 13px 18px; font-size: 16px; }
.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--line);
    padding: 10px 14px;
    font-size: 14px;
}
.btn-block { width: 100%; }

/* ─── Shell layout ─────────────────────────────────────────── */

.pos-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    max-width: 100vw;
    overflow: hidden;
}

.pos-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    white-space: nowrap;
}

.brand h1 { font-size: 19px; font-weight: 700; color: var(--accent); letter-spacing: 0.5px; }
.brand .brand-sub { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; }

.scan-wrap {
    flex: 1;
    max-width: 340px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 12px;
}

.scan-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    min-width: 0;
}

.scan-wrap .scan-icon { color: var(--accent); font-size: 15px; }

.header-right { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.server-badge { font-size: 13px; color: var(--text-dim); }
.server-badge strong { color: var(--text); font-weight: 600; }

.pos-main {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ─── Menu (left) ──────────────────────────────────────────── */

.menu-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.category-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px 4px;
    overflow-x: auto;
    flex: 0 0 auto;
    scrollbar-width: thin;
}

.category-tab {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text-dim);
    border-radius: 999px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.category-tab:hover { color: var(--text); }

.category-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #04222b;
}

.menu-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 14px 16px 20px;
    align-content: start;
}

.menu-tile {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    padding: 14px;
    min-height: 96px;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
}

.menu-tile:hover { border-color: var(--accent); }
.menu-tile:active { transform: scale(0.98); }

.tile-name { font-size: 15px; font-weight: 600; line-height: 1.25; }
.tile-sub { font-size: 11.5px; color: var(--text-dim); }
.tile-price { margin-top: auto; font-size: 14px; font-weight: 700; color: var(--accent); }

.menu-empty {
    grid-column: 1 / -1;
    color: var(--text-dim);
    font-size: 14px;
    padding: 30px 6px;
    text-align: center;
}

/* ─── Order rail (right) ───────────────────────────────────── */

.order-rail {
    flex: 0 0 390px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--line);
    min-height: 0;
}

.order-meta {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 0 0 auto;
}

.order-type-row { display: flex; gap: 8px; }

.order-type-btn {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text-dim);
    border-radius: 8px;
    padding: 9px 0;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.order-type-btn.active { background: var(--accent); border-color: var(--accent); color: #04222b; }
.order-type-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.meta-fields { display: flex; gap: 8px; }

.meta-fields > * { min-width: 0; }

.meta-field { flex: 1; display: flex; flex-direction: column; gap: 3px; }

.meta-field label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    font-weight: 600;
}

.meta-field input,
.meta-field select {
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    width: 100%;
}

.meta-field input:focus, .meta-field select:focus { outline: none; border-color: var(--accent); }

.customer-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.35);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
}

.chip-name { font-weight: 600; }
.chip-band { color: var(--accent); font-size: 12px; }
.chip-band-off { color: var(--text-dim); }

.chip-clear {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
}
.chip-clear:hover { color: var(--danger); }

.fired-banner {
    margin: 10px 14px 0;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.45);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    flex: 0 0 auto;
}

.fired-banner.warn {
    background: rgba(255, 152, 0, 0.1);
    border-color: rgba(255, 152, 0, 0.5);
}

.fired-banner strong { color: var(--accent); }
.fired-banner .fired-status { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.order-lines {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.order-empty { color: var(--text-dim); font-size: 13.5px; text-align: center; padding: 26px 8px; }

.order-line {
    display: flex;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 9px 11px;
}

.line-main { flex: 1; min-width: 0; }

.line-head { display: flex; justify-content: space-between; gap: 8px; }
.line-name { font-size: 14px; font-weight: 600; }
.line-total { font-size: 13.5px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.line-mod { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.line-note { font-size: 12px; color: var(--warning); margin-top: 2px; }

.line-controls { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.qty-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    line-height: 1;
}

.line-qty { font-size: 13.5px; font-weight: 700; min-width: 18px; text-align: center; }

.line-remove {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
}
.line-remove:hover { color: var(--danger); }

.order-totals {
    border-top: 1px solid var(--line-soft);
    padding: 10px 14px 6px;
    flex: 0 0 auto;
    font-size: 13.5px;
}

.totals-row { display: flex; justify-content: space-between; padding: 2.5px 0; color: var(--text-dim); }
.totals-row.grand { font-size: 18px; font-weight: 700; color: var(--text); padding-top: 6px; }
.totals-row.grand span:last-child { color: var(--accent); }
.totals-source { font-size: 10.5px; color: var(--text-dim); text-align: right; opacity: 0.8; }

.order-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px 14px;
    flex: 0 0 auto;
}

.order-actions .row { display: flex; gap: 8px; }
.order-actions .row .btn { flex: 1; }

/* ─── Modals ───────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(4, 8, 20, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    width: 560px;
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 10px;
    border-bottom: 1px solid var(--line-soft);
    flex: 0 0 auto;
}

.modal-title h2 { font-size: 19px; font-weight: 700; }
.modal-title .modal-desc { font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.modal-title .modal-allergens { font-size: 12px; color: var(--warning); margin-top: 3px; }

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 2px 6px;
}
.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 12px 18px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-foot {
    padding: 12px 18px 16px;
    border-top: 1px solid var(--line-soft);
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Item modal internals */

.qty-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.qty-row .qty-label { font-size: 13px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.stepper { display: flex; align-items: center; gap: 12px; }

.stepper button {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
}

.stepper .qty-value { font-size: 20px; font-weight: 700; min-width: 30px; text-align: center; }

.mod-group, .quick-options { margin-bottom: 14px; }

.group-title { font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.group-rule { font-size: 11px; font-weight: 500; color: var(--text-dim); margin-left: 6px; }

.option-row { display: flex; flex-wrap: wrap; gap: 8px; }

.opt-btn {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.12s;
}

.opt-btn:hover { border-color: var(--accent); }

.opt-btn.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #04222b;
    font-weight: 600;
}

.opt-btn.unavailable { opacity: 0.4; cursor: not-allowed; text-decoration: line-through; }
.opt-adj { font-size: 12px; opacity: 0.85; }

.note-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.note-field input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 6px;
    padding: 9px 11px;
    font-size: 14px;
}
.note-field input:focus { outline: none; border-color: var(--accent); }

/* Settle modal */

.settle-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 15px;
    margin-bottom: 12px;
}
.settle-total-row strong { font-size: 24px; color: var(--accent); }

.tender-tabs { display: flex; gap: 8px; margin-bottom: 14px; }

.tender-tab {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text-dim);
    border-radius: 8px;
    padding: 11px 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.tender-tab.active { background: var(--accent); border-color: var(--accent); color: #04222b; }

.tender-pane { display: flex; flex-direction: column; gap: 10px; }

.tender-pane .hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }

.cash-quick-row { display: flex; gap: 8px; flex-wrap: wrap; }

.cash-quick-row .btn-ghost { padding: 8px 12px; font-size: 13px; }

.cash-change { font-size: 15px; font-weight: 700; color: var(--success); min-height: 20px; }
.cash-change.short { color: var(--danger); }

.band-info { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 8px; padding: 10px 12px; }
.band-holder { font-size: 15px; font-weight: 700; }
.band-mode { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.settle-error {
    display: none;
    background: rgba(229, 72, 77, 0.12);
    border: 1px solid rgba(229, 72, 77, 0.5);
    color: #ff8f92;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
}
.settle-error.visible { display: block; }

/* Ticket modal */

.ticket-pre {
    font-family: 'Geist Mono', ui-monospace, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.4;
    background: #0b0f1c;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 14px;
    white-space: pre;
    overflow-x: auto;
    color: #d7e1ea;
}

/* Receipt */

.receipt {
    background: #fff;
    color: #111;
    border-radius: 10px;
    width: 380px;
    max-width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.receipt-body {
    padding: 22px 24px;
    overflow-y: auto;
    font-family: 'Geist Mono', ui-monospace, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.5;
}

.rcpt-brand { font-size: 18px; font-weight: 700; text-align: center; letter-spacing: 1px; }
.rcpt-sub { text-align: center; font-size: 11px; color: #555; margin-bottom: 12px; }
.rcpt-meta { border-top: 1px dashed #999; border-bottom: 1px dashed #999; padding: 8px 0; margin-bottom: 10px; color: #333; }
.rcpt-lines { margin-bottom: 10px; }
.rcpt-line { margin-bottom: 6px; }
.rcpt-line-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.rcpt-mod { color: #555; padding-left: 14px; font-size: 11.5px; }
.rcpt-totals { border-top: 1px dashed #999; padding-top: 8px; }
.rcpt-row { display: flex; justify-content: space-between; gap: 10px; padding: 1.5px 0; }
.rcpt-total { font-size: 15px; font-weight: 700; border-top: 1px solid #111; margin-top: 5px; padding-top: 6px; }
.rcpt-foot { text-align: center; color: #555; margin-top: 14px; font-size: 11px; }

.receipt-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e2e2e2;
    background: #f6f6f6;
}
.receipt-actions .btn { flex: 1; }
.receipt-actions .btn-ghost { color: #333; border-color: #bbb; }

/* ─── Toasts (booking-POS look) ────────────────────────────── */

.toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    color: var(--text);
    border-radius: 8px;
    padding: 11px 15px;
    font-size: 13.5px;
    min-width: 240px;
    max-width: 380px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transform: translateX(24px);
    transition: opacity 0.25s, transform 0.25s;
}

.toast.show { opacity: 1; transform: translateX(0); }

.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--accent); }

/* ─── Print ────────────────────────────────────────────────── */

@media print {
    /* Only the chosen overlay prints; overlays are direct children of body. */
    body.print-receipt > :not(#receiptOverlay),
    body.print-ticket > :not(#ticketModalOverlay) {
        display: none !important;
    }

    body.print-receipt, body.print-ticket {
        background: #fff !important;
        overflow: visible !important;
        height: auto !important;
    }

    body.print-receipt #receiptOverlay,
    body.print-ticket #ticketModalOverlay {
        position: static !important;
        background: none !important;
        padding: 0 !important;
        display: block !important;
    }

    body.print-receipt .receipt,
    body.print-ticket .modal {
        box-shadow: none !important;
        border: none !important;
        width: auto !important;
        max-height: none !important;
        background: #fff !important;
    }

    body.print-ticket .ticket-pre {
        background: #fff !important;
        color: #000 !important;
        border: none !important;
        font-size: 12px;
    }

    body.print-ticket .modal-head,
    .no-print {
        display: none !important;
    }

    .receipt-body { overflow: visible !important; color: #000; }
}

/* ─── Narrow screens ───────────────────────────────────────── */

@media (max-width: 900px) {
    .order-rail { flex-basis: 320px; }
    .scan-wrap { max-width: 210px; }
    .brand .brand-sub { display: none; }
}
