/* TableTap waiter tablet: a live board of table requests and orders, with big touch targets. */
:root {
  color-scheme: light;
  --ink: #1f2420;
  --muted: #6c7068;
  --paper: #faf7f1;
  --panel: #fffdf9;
  --white: #fff;
  --line: #ebe5d9;
  --green: #1f4d33;
  --green-hover: #163a26;
  --green-soft: #e6eedf;
  --on-green: #fff;
  --tomato: #c4361f;
  --tomato-soft: #fbe4df;
  --amber: #a75a12;
  --amber-soft: #fcebd6;
  --blue-soft: #e4ebf7;
  --blue: #3d5a99;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31,36,32,.05), 0 8px 22px rgba(31,36,32,.05);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f5f3f0;
  --muted: #a8a099;
  --paper: #1a1815;
  --panel: #252220;
  --white: #2a2520;
  --line: #3a3530;
  --green: #5fb87f;
  --green-hover: #70d494;
  --green-soft: #1f3a2a;
  --on-green: #10221a;
  --tomato: #ff6b54;
  --tomato-soft: #4a1d16;
  --amber: #e0a85a;
  --amber-soft: #3d2b1a;
  --blue-soft: #1f2a40;
  --blue: #9db4e8;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 22px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin-top: 0; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.tt-logo { display: inline-block; flex: none; aspect-ratio: 488 / 482; background: url("brand/tabletap-logo-light.png") center / contain no-repeat; }
html[data-theme="dark"] .tt-logo { background-image: url("brand/tabletap-logo-dark.png"); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--tomato); outline-offset: 2px; }

/* Buttons */
.primary-button, .secondary-button, .danger-button, .accept-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 11px; font-size: 15px; font-weight: 700; white-space: nowrap;
}
.primary-button { border: 0; color: var(--on-green); background: var(--green); }
.primary-button:hover { background: var(--green-hover); }
.primary-button:disabled { opacity: .55; cursor: default; }
.secondary-button { border: 1px solid var(--line); background: var(--white); }
.secondary-button:hover { border-color: var(--green); color: var(--green); }
.danger-button { border: 1px solid transparent; color: var(--tomato); background: var(--tomato-soft); }
.accept-button { border: 0; color: var(--on-green); background: var(--green); }
.primary-button.wide { width: 100%; }
.icon-button { display: inline-grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 11px; background: var(--white); }
.icon-button[aria-pressed="true"] { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.close-button { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; font-size: 20px; color: var(--muted); }
.close-button:hover { background: var(--paper); color: var(--ink); }

/* Start and setup screens */
.screen.center { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px 16px; text-align: center; }
.start-logo { width: 84px; }
#start-text { margin: 0; color: var(--muted); max-width: 420px; }
.panel { width: min(460px, 100%); padding: 32px 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: var(--shadow); text-align: left; }
.panel-logo { width: 56px; margin-bottom: 14px; }
.panel h1 { margin-bottom: 10px; font-family: var(--serif); font-size: 28px; }
.panel p { color: var(--muted); }
.stack { display: grid; gap: 16px; }
label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.code-input { width: 100%; min-height: 60px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 26px; font-weight: 700; letter-spacing: .16em; text-align: center; text-transform: uppercase; }
.form-error { min-height: 22px; margin: 12px 0 0; color: var(--tomato); font-size: 14px; font-weight: 600; }

/* Board */
.app { max-width: 1500px; margin: 0 auto; padding: 0 20px 40px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; margin: 0 -20px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .tt-logo { width: 42px; }
.brand-text { display: grid; min-width: 0; }
.brand-text strong { overflow: hidden; font-family: var(--serif); font-size: 21px; white-space: nowrap; text-overflow: ellipsis; }
.brand-text span { color: var(--muted); font-size: 13px; }
.clock { margin-left: auto; color: var(--muted); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.waiter-chip { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 6px; border: 1px solid var(--green); border-radius: 14px; background: var(--green-soft); }
.avatar { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 700; }
.waiter-chip-text { display: grid; line-height: 1.2; }
.waiter-chip-text span { color: var(--muted); font-size: 12px; }
.lock-countdown { min-width: 44px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.locked-banner { margin: 16px 0 0; padding: 12px 16px; border-radius: 12px; color: var(--blue); background: var(--blue-soft); font-size: 14px; }

h2 { display: flex; align-items: center; gap: 10px; margin: 24px 0 12px; font-size: 19px; }
h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.count { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px; color: var(--muted); background: var(--line); font-size: 13px; font-weight: 700; letter-spacing: 0; }
.connection-note { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.connection-note:empty { display: none; }
.empty { margin: 0; padding: 18px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 14px; text-align: center; }

/* Table requests */
.request-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.request-card { display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px; border: 1px solid var(--amber); border-radius: var(--radius); background: var(--amber-soft); }
.request-card.is-new { animation: pulse 1.2s ease-in-out 3; }
.request-icon { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 12px; color: var(--amber); background: var(--white); font-size: 22px; }
.request-body { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.request-body strong { font-size: 18px; }
.request-body span { color: var(--muted); font-size: 13px; }
.request-card .accept-button { padding: 0 16px; }
/* One-time guests asking to order: green, with Attend table and Decline, and the code their phone shows. */
.guest-card { flex-wrap: wrap; border-color: var(--green); background: var(--green-soft); }
.guest-card .request-icon { color: var(--green); }
.guest-card .request-body { min-width: 160px; }
.guest-code { color: var(--ink); font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .08em; }
.request-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.request-actions .secondary-button { padding: 0 14px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--amber) 30%, transparent); } }
@media (prefers-reduced-motion: reduce) { .request-card.is-new, .order-card.is-new, .ticket-card.is-new { animation: none; } }

/* Orders */
.orders-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.orders-head h2 { margin-bottom: 12px; }
.segmented { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.segmented button { min-height: 42px; padding: 0 18px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 700; }
.segmented button[aria-pressed="true"] { color: var(--on-green); background: var(--green); }
.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.order-list { display: grid; gap: 12px; }
.order-card { padding: 16px; border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.order-card.status-incoming { border-left-color: var(--tomato); }
.order-card.status-accepted { border-left-color: var(--green); }
.order-card.status-done { opacity: .78; box-shadow: none; }
.order-card.is-mine { box-shadow: 0 0 0 2px var(--green-soft), var(--shadow); }
.order-card.is-new { animation: pulse 1.2s ease-in-out 3; }
.order-top { display: flex; align-items: baseline; gap: 10px; }
.order-top strong { font-size: 20px; }
.order-ref { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.order-age { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.order-age.is-late { color: var(--tomato); font-weight: 700; }
.order-who { margin: 4px 0 10px; color: var(--muted); font-size: 14px; }
.order-who strong { color: var(--ink); }
.order-items { margin: 0 0 12px; padding: 0; list-style: none; display: grid; gap: 6px; }
.order-items li { display: grid; grid-template-columns: 34px 1fr; font-size: 15px; }
.order-items .qty { font-weight: 700; }
.order-items .options { grid-column: 2; color: var(--muted); font-size: 13px; }
.order-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.order-total { margin-right: auto; font-weight: 700; }
.order-status { color: var(--muted); font-size: 13px; font-weight: 600; }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Items a diner asked to add, waiting for the order's waiter. */
.order-card.has-addition { border-color: var(--amber); }
.order-addition { margin: 0 0 12px; padding: 12px 14px; border: 1px dashed var(--amber); border-radius: 12px; background: var(--amber-soft); }
.order-addition .order-items { margin-bottom: 8px; }
.addition-head { display: flex; justify-content: space-between; gap: 10px; margin: 0 0 8px; color: var(--amber); font-size: 14px; }
.addition-head span { color: var(--muted); font-size: 13px; }
.addition-total { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.addition-total span { color: var(--muted); font-weight: 500; }
.order-actions button { min-height: 46px; padding: 0 16px; font-size: 14px; }
.order-actions button:disabled { opacity: .5; cursor: default; }

/* Where the kitchen and bar are with an order, and changes not yet sent */
.order-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.station-chip, .pending-chip { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 13px; font-size: 12px; font-weight: 700; }
.station-chip { color: var(--amber); background: var(--amber-soft); }
.station-chip.is-ready { color: var(--green); background: var(--green-soft); }
.pending-chip { color: var(--blue); background: var(--blue-soft); }
.offline-banner { margin: 16px 0 0; padding: 12px 16px; border: 1px solid var(--amber); border-radius: 12px; color: var(--ink); background: var(--amber-soft); font-size: 14px; font-weight: 600; }

/* Kitchen and bar tickets: read from across the pass */
.ticket-columns { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.ticket-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; }
.ticket-card { padding: 16px; border: 1px solid var(--line); border-top: 6px solid var(--green); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.ticket-card.is-late { border-top-color: var(--tomato); }
.ticket-card.is-ready { border-top-color: var(--line); opacity: .8; box-shadow: none; }
.ticket-card.is-new { animation: pulse 1.2s ease-in-out 3; }
.ticket-card .order-top strong { font-size: 24px; }
.ticket-items li { grid-template-columns: 44px 1fr; font-size: 19px; font-weight: 600; }
.ticket-items .options { font-size: 15px; font-weight: 500; }
.ticket-items li.is-made { color: var(--muted); font-weight: 500; text-decoration: line-through; }
.added-flag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; color: var(--amber); background: var(--amber-soft); font-size: 12px; font-weight: 700; vertical-align: middle; }
.ticket-note { margin: 0 0 10px; color: var(--amber); font-size: 14px; font-weight: 600; }
.ticket-card .order-actions button { flex: 1; }
.ticket-ready { min-height: 60px !important; font-size: 18px !important; }

/* Dialogs */
dialog { width: min(520px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 22px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--white); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,22,20,.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-head h2, dialog > h2 { margin: 0; font-size: 22px; }
dialog > h2 { margin-bottom: 10px; }
.dialog-note { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.name-button { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); text-align: left; }
.name-button:hover:not(:disabled) { border-color: var(--green); }
.name-button:disabled { opacity: .55; cursor: default; }
.name-button span:last-child { display: grid; line-height: 1.2; font-weight: 700; }
.name-button small { color: var(--muted); font-size: 12px; font-weight: 500; }
.pin-input { width: 100%; min-height: 64px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 32px; letter-spacing: .4em; text-align: center; }
.pin-input::placeholder { letter-spacing: .3em; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 14px; }
.keypad button { min-height: 64px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 24px; font-weight: 700; }
.keypad button:active { background: var(--green-soft); }
.keypad .key-quiet { color: var(--muted); font-size: 15px; display: grid; place-items: center; }

/* Toast */
.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; max-width: min(560px, calc(100% - 32px)); transform: translateX(-50%); padding: 14px 18px; border-radius: 12px; color: #fff; background: #1f2420; box-shadow: 0 12px 32px rgba(0,0,0,.25); font-size: 15px; }
.toast.error { background: #8f2b1a; }

/* Tablets in portrait and phones */
@media (max-width: 1000px) {
  .columns { grid-template-columns: 1fr 1fr; }
  .columns.ticket-columns { grid-template-columns: 1fr; }
  .columns .column:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .app { padding: 0 16px 32px; }
  .topbar { flex-wrap: wrap; gap: 10px; margin: 0 -16px; padding: 10px 16px; }
  .clock { display: none; }
  .topbar-actions { width: 100%; }
  #sign-in-button, .waiter-chip { flex: 1; }
  .waiter-chip { min-width: 0; }
  .waiter-chip-text { min-width: 0; flex: 1; }
  .waiter-chip-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lock-countdown { display: none; }
  .columns { grid-template-columns: 1fr; }
  .request-list { grid-template-columns: 1fr; }
  .panel { padding: 26px 20px; }
}
