/* ------------------------------------------------------------------
   qrest - touch terminal styling

   Built for a wall-mounted or counter tablet: large targets, high
   contrast, no hover-dependent affordances, nothing that needs a mouse.
   Dark by default because these screens sit under service lighting all
   evening and a white screen is glare.
   ------------------------------------------------------------------ */

:root {
    --bg:        #12151c;
    --surface:   #1b202b;
    --surface-2: #232936;
    --line:      #2f3746;

    --text:      #eef1f6;
    --muted:     #93a0b4;

    --accent:    #2ec5d3;
    --accent-in: #06202a;

    --free:      #3ba55c;
    --busy:      #d98324;
    --danger:    #e5484d;

    --radius: 14px;
    --tap: 56px;                 /* minimum comfortable touch target */

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.4;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ---------------------------------------------------- app frame ---- */

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}

.brand {
    font-weight: 700;
    letter-spacing: .5px;
    font-size: 20px;
    color: var(--accent);
}
.brand i { font-style: italic; opacity: .8; }

.topbar .spacer { flex: 1; }

.who {
    text-align: right;
    line-height: 1.15;
}
.who b { display: block; font-size: 15px; }
.who span { font-size: 12px; color: var(--muted); }

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

/* --------------------------------------------------------- chips ---- */

.chips {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.chip[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-in);
}

/* ---------------------------------------------------- table grid ---- */

.scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 5px solid var(--free);
    border-radius: var(--radius);
    padding: 14px;
    min-height: 112px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
}
.tile:active { transform: scale(.985); }
.tile.busy { border-left-color: var(--busy); background: var(--surface-2); }

.tile .no    { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.tile .desc  { font-size: 13px; color: var(--muted); }
.tile .foot  { margin-top: auto; display: flex; justify-content: space-between;
               align-items: baseline; gap: 8px; }
.tile .total { font-size: 18px; font-weight: 700; }
.tile .state { font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
               color: var(--muted); font-weight: 700; }
.tile.busy .state { color: var(--busy); }

.badge {
    display: inline-block;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
}

/* ------------------------------------------------- order screen ---- */

.order {
    display: flex;
    width: 100%;
    min-height: 0;
}

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

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

.bill-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}
.bill-head h2 { margin: 0; font-size: 20px; }
.bill-head p  { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.bill-lines { flex: 1 1 auto; overflow-y: auto; padding: 8px 0; }

.line {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    align-items: baseline;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,.04);
    cursor: pointer;
}
.line .q  { font-weight: 700; color: var(--accent); }
.line .n  { min-width: 0; }
.line .n small { display: block; color: var(--muted); font-size: 12px; }
.line .a  { font-variant-numeric: tabular-nums; font-weight: 600; }
.line.fired .q::after { content: " ✓"; color: var(--free); font-size: 11px; }

.bill-total {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    font-size: 22px;
    font-weight: 700;
}

.bill-actions {
    padding: 12px 16px 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.item {
    min-height: 84px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
}
.item:active { transform: scale(.98); border-color: var(--accent); }
.item .nm { font-size: 15px; font-weight: 600; line-height: 1.25; }
.item .pr { font-size: 15px; color: var(--accent); font-weight: 700;
            font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------- buttons -- */

.btn {
    min-height: var(--tap);
    padding: 0 20px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn:active   { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-in); }
.btn-danger  { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-ghost   { background: transparent; }
.btn-sm      { min-height: 42px; font-size: 14px; padding: 0 14px; }

/* ---------------------------------------------------------- login -- */

.login-wrap {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 26px;
}
.login h1 { margin: 0 0 2px; font-size: 24px; }
.login .sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.pin-display {
    height: 60px;
    border-radius: var(--radius);
    background: var(--bg);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 28px;
    letter-spacing: 10px;
}
.pin-display.empty { color: var(--muted); font-size: 15px; letter-spacing: normal; }

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 14px;
}
.key {
    height: 64px;
    font-size: 24px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
}
.key:active { background: var(--accent); color: var(--accent-in); }

.field {
    width: 100%;
    height: 52px;
    padding: 0 14px;
    font-size: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    -webkit-user-select: text;
    user-select: text;
}
.field:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.feedback {
    min-height: 22px;
    color: var(--danger);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    margin-top: 10px;
}

/* --------------------------------------------------------- modal --- */

.modal-back {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}
.modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 22px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; font-size: 20px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

.hidden { display: none !important; }

.empty-note {
    color: var(--muted);
    text-align: center;
    padding: 50px 20px;
    font-size: 15px;
}

/* -------------------------------------------------------- toasts --- */

.toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}
.toast {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    max-width: 340px;
}
.toast.err { border-left-color: var(--danger); }

/* ------------------------------------------- narrow / portrait ----- */

@media (max-width: 820px) {
    .order { flex-direction: column; }
    .bill-pane {
        flex: 0 0 auto;
        max-height: 45%;
        border-left: 0;
        border-top: 1px solid var(--line);
    }
    .grid      { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
    .item-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ------------------------------------------------------- printing -- */

@media print {
    body { background: #fff; color: #000; }
    .no-print { display: none !important; }
}
