/* Look and feel: a light gray canvas, white tiles without borders, pill
   buttons, the system font, and Nadaa orange as the one action colour
   (adapted from the Apple DESIGN.md in VoltAgent/awesome-design-md).
   See "Design" in README.md. */

:root {
  --canvas: #FFFFFF;       /* customer page and the top bars */
  --bg: #F5F5F7;           /* behind dashboard tiles */
  --surface: #FFFFFF;
  --surface-2: #F5F5F7;    /* inputs, stat tiles, quiet buttons */
  --fg: #1D1D1F;
  --body: #1D1D1F;
  --muted: #6E6E73;
  --line: #E0E0E0;
  --line-soft: #F0F0F0;
  --line-strong: #D2D2D7;
  --accent: #C2410C;
  --accent-hover: #9A3412;
  --accent-fg: #FFFFFF;
  --accent-soft: #FFF1E8;
  --ok: #1D7F3A;
  --ok-soft: #E7F5EC;
  --warn: #B25E00;
  --warn-soft: #FFF3E0;
  --bad: #D70015;
  --bad-soft: #FDEBEC;
  --shadow: 0 4px 24px rgba(0, 0, 0, .08);
  --r-sm: 11px;
  --r-md: 18px;
  --r-lg: 22px;
  --font: system-ui, -apple-system, "SF Arabic", "SF Pro Text", "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #000000; --bg: #000000; --surface: #1C1C1E; --surface-2: #2C2C2E;
    --fg: #F5F5F7; --body: #F5F5F7; --muted: #A1A1A6;
    --line: #38383A; --line-soft: #2C2C2E; --line-strong: #48484A;
    --accent: #FF8A4C; --accent-hover: #FFA472; --accent-fg: #1A0E07; --accent-soft: #3A2117;
    --ok: #5FCB8F; --ok-soft: #15301F; --warn: #F5B454; --warn-soft: #3A2A12; --bad: #FF6961; --bad-soft: #3A1714;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 4px 24px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.6;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 20px; line-height: 1.4; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { color: var(--body); }
.muted, p.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
/* One action colour; secondary buttons are quiet gray pills with orange text. */
button, .btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 999px; padding: 11px 22px; min-height: 44px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); text-decoration: none; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
button:hover:not(:disabled), .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active:not(:disabled), .btn:active { transform: scale(.98); }
button.ghost, .btn.ghost { background: var(--surface-2); color: var(--accent); border-color: transparent; }
button.ghost:hover:not(:disabled), .btn.ghost:hover { background: var(--line-soft); border-color: transparent; }
button.small, .btn.small { padding: 5px 14px; min-height: 32px; font-size: 13px; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, .btn:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button.bad, button.bad:hover:not(:disabled) { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ---------- inputs ---------- */
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--surface-2); border: 1px solid transparent;
  border-radius: var(--r-sm); padding: 11px 14px; min-width: 0; min-height: 44px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; color: var(--fg); }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; color: var(--body); }
label.check input { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); }
input[type="color"] { width: 48px; height: 44px; padding: 3px; cursor: pointer; }
code { font-family: var(--mono); font-size: 13px; direction: ltr; unicode-bidi: isolate; word-break: break-all; }
.err { color: var(--bad); font-size: 14px; min-height: 1.4em; }
.small { font-size: 13px; }

.danger-zone { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line-soft); display: grid; gap: 10px; }
.danger-zone .row { flex-wrap: wrap; align-items: center; }
.danger-zone input { flex: 1 1 180px; }

#toast {
  position: fixed; inset-inline: 16px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); margin: auto; max-width: 420px;
  background: var(--fg); color: var(--canvas); padding: 12px 18px; border-radius: 999px; text-align: center; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 10;
}
#toast.show { opacity: 1; transform: none; }

/* ---------- customer ---------- */
body.customer { background: var(--canvas); }
.customer main { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; }
.panel { width: 100%; max-width: 400px; display: grid; gap: 18px; text-align: center; }
.panel h1 { font-size: 34px; }
.panel form { display: grid; gap: 12px; }
.panel input { font-size: 34px; font-weight: 600; text-align: center; padding: 14px; min-height: 72px; border-radius: var(--r-md); font-variant-numeric: tabular-nums; }
.panel button { padding: 15px; min-height: 56px; font-size: 18px; font-weight: 600; }
.panel button.small { padding: 5px 14px; min-height: 32px; font-size: 13px; font-weight: 500; }
.ticket-big {
  font-size: clamp(88px, 30vw, 150px); line-height: 1; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  padding: 8px;
}
.ticket-big.name { font-size: clamp(44px, 15vw, 80px); letter-spacing: 0; }
.shop-name { justify-self: center; color: var(--muted); font-size: 15px; font-weight: 500; }
.hint { font-size: 14px; color: var(--muted); }
.ok-note { color: var(--ok); font-weight: 600; font-size: 15px; }
.conn { font-size: 13px; color: var(--ok); }
.conn.off { color: var(--bad); }
.banner { background: var(--accent-soft); border: 0; color: var(--fg); border-radius: var(--r-md); padding: 14px 16px; font-size: 15px; }
button.banner { color: var(--fg); background: var(--accent-soft); }
.banner b { font-weight: 600; }
.dots::after { content: '...'; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

body.is-ready { background: var(--accent); color: var(--accent-fg); }
body.is-ready p, body.is-ready .muted, body.is-ready .hint, body.is-ready .shop-name { color: var(--accent-fg); opacity: .88; }
body.is-ready button, body.is-ready button:hover:not(:disabled) { background: var(--accent-fg); color: var(--accent); border-color: var(--accent-fg); }
body.is-ready .conn { color: var(--accent-fg); }
@keyframes pulse { 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: no-preference) {
  body.is-ringing .ticket-big { animation: pulse 1s ease-in-out infinite; }
  .dots::after { animation: dots 1.5s steps(4) infinite; }
}

/* ---------- staff ---------- */
.staff { min-height: 100dvh; }
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 2; background: var(--canvas); border-bottom: 1px solid var(--line-soft);
  padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
}
.bar .title { display: grid; line-height: 1.35; margin-inline-end: auto; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button, .seg button {
  background: var(--surface-2); color: var(--fg); border-color: transparent; padding: 6px 16px; min-height: 36px; font-size: 14px;
}
.tabs button:hover:not(:disabled), .seg button:hover:not(:disabled) { background: var(--line); border-color: transparent; }
.tabs button[aria-pressed="true"], .seg button[aria-pressed="true"],
.tabs button[aria-pressed="true"]:hover, .seg button[aria-pressed="true"]:hover { background: var(--fg); border-color: var(--fg); color: var(--canvas); }
.tabs .count { font-variant-numeric: tabular-nums; opacity: .75; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.tools form { display: flex; gap: 6px; flex: 1 1 240px; }
.tools input { flex: 1; min-width: 0; padding: 8px 12px; }
.tools input[type="search"] { flex: 1 1 160px; }
.offline { background: var(--bad-soft); color: var(--bad); padding: 10px 16px; font-weight: 600; text-align: center; }
.tiles { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; align-content: start; }
.tiles.locked button[data-act] { pointer-events: none; opacity: .4; }
.tile {
  background: var(--surface); border: 0; border-radius: var(--r-md); padding: 14px; display: grid; gap: 6px; align-content: start;
  box-shadow: inset 0 4px 0 var(--line);
}
.tile .no { font-size: 34px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .no.name { font-size: 24px; font-weight: 600; letter-spacing: 0; }
.tile .st { font-size: 14px; color: var(--muted); }
.tile .st .late { color: var(--bad); font-weight: 600; }
.tile .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tile .acts button { flex: 1; min-width: 0; padding: 10px 8px; }
.tile .acts button:first-child { flex: 1 1 100%; }
.tile .acts button.small { flex: 1 1 0; padding: 8px; }
.tile .st + .st { color: var(--muted); font-weight: 400; }
.tile.sending { box-shadow: inset 0 4px 0 var(--accent); }
.tile.sending .st { color: var(--accent); font-weight: 600; }
.tile.ok { box-shadow: inset 0 4px 0 var(--ok); }
.tile.ok .st { color: var(--ok); font-weight: 600; }
.tile.bad { box-shadow: inset 0 4px 0 var(--bad); background: var(--bad-soft); }
.tile.bad .st { color: var(--bad); font-weight: 600; }
.tile.done { opacity: .65; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- owner & admin pages ---------- */
.owner .wrap { max-width: 960px; margin: 0 auto; padding: 0 16px 72px; display: grid; gap: 20px; }
.owner header.top {
  position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between;
  margin: 0 -16px; padding: 14px 16px; --bar: rgba(255, 255, 255, .8); background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  /* The bar runs the full window width while its content stays in the column. */
  box-shadow: 0 0 0 100vmax var(--bar), 0 1px 0 100vmax var(--line-soft); clip-path: inset(0 -100vmax -1px);
}
@media (prefers-color-scheme: dark) { .owner header.top { --bar: rgba(0, 0, 0, .72); } }
.owner header.top h1 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.owner header.top p { font-size: 14px; overflow-wrap: anywhere; }
.owner header.top .row :is(button, .btn) { min-height: 36px; padding: 6px 16px; font-size: 14px; }
.owner header.top h1::before, .auth h1::before {
  content: ''; flex: none; width: 34px; height: 34px; border-radius: 9px; background: url(/assets/icon.svg) center / cover;
}
.card { background: var(--surface); border: 0; border-radius: var(--r-lg); padding: 28px; display: grid; gap: 16px; min-width: 0; }
.card .head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.pill {
  font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--body);
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: var(--r-md); padding: 14px 16px; display: grid; gap: 2px; align-content: start; }
.stat strong { font-size: 24px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.pair-code { font-family: var(--mono); font-size: 32px; letter-spacing: .2em; font-weight: 600; direction: ltr; }
.devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.devices li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--surface-2); border-radius: var(--r-sm); font-size: 14px;
}
.auth { max-width: 420px; margin: 10vh auto 0; padding: 32px; box-shadow: var(--shadow); }
.auth form { display: grid; gap: 14px; }
.auth h1 { display: flex; align-items: center; gap: 10px; }
.auth form > button:not(.ghost) { min-height: 48px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg:not(.filters) button { flex: 1; }
.steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; font-size: 15px; color: var(--body); }
.steps li::marker { color: var(--accent); font-weight: 600; }

/* ---------- staff keypad ---------- */
.desk { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 0; align-items: start; }
@media (max-width: 760px) { .desk { grid-template-columns: minmax(0, 1fr); } }
.caller {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 58px); padding: 16px; display: grid; gap: 12px;
  border-inline-end: 1px solid var(--line-soft); background: var(--canvas); min-height: calc(100dvh - 58px); align-content: start;
}
@media (max-width: 760px) { .caller { position: static; min-height: 0; border-inline-end: 0; border-bottom: 1px solid var(--line-soft); } }
.caller.locked button { pointer-events: none; opacity: .4; }
.display {
  font-size: 52px; font-weight: 700; line-height: 1.2; text-align: center; direction: ltr; letter-spacing: -.02em;
  padding: 8px 12px; border: 0; border-radius: var(--r-md); background: var(--surface-2); min-height: 82px;
  font-variant-numeric: tabular-nums;
}
.display .muted { font-size: 22px; font-weight: 400; line-height: 62px; letter-spacing: 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; direction: ltr; }
.keypad button, .keypad button:hover:not(:disabled) {
  font-size: 28px; font-weight: 500; padding: 14px 0; min-height: 64px; touch-action: manipulation;
  background: var(--surface-2); color: var(--fg); border-color: transparent; font-variant-numeric: tabular-nums;
}
.keypad button:active { background: var(--line); }
.call-btn { font-size: 22px; font-weight: 600; padding: 16px; min-height: 64px; touch-action: manipulation; }
.name-call { display: grid; gap: 10px; }
.name-call input { font-size: 24px; padding: 14px; text-align: center; }
.pending-call {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px;
  border-radius: var(--r-md); background: var(--accent-soft); color: var(--fg); font-size: 15px;
}
#pending { display: grid; gap: 8px; }
.choices { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: 15px; }
.choices button { justify-content: flex-start; text-align: start; font-weight: 400; }
.board { min-width: 0; }
.board-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 0; }
.board-head input { flex: 0 1 220px; padding: 8px 12px; border-radius: 999px; }

/* ---------- admin ---------- */
.admin-wrap { max-width: 1200px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpis .stat { background: var(--surface); border-radius: var(--r-lg); padding: 18px 20px; }
.kpis .stat strong { font-size: 28px; letter-spacing: -.02em; white-space: nowrap; }
.stat.warn strong { color: var(--warn); }
.stat.bad strong { color: var(--bad); }
.filters { flex-wrap: wrap; }
.filters button { flex: 0 0 auto; }
.head > .row:has(input[type="search"]) { flex: 1 1 420px; justify-content: flex-end; }
.head > .row input[type="search"] { flex: 1 1 220px; max-width: 360px; border-radius: 999px; padding-inline: 18px; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.admin-table th, .admin-table td { text-align: start; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.admin-table th { font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; border-bottom-color: var(--line); }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-table tbody tr[data-open] { cursor: pointer; transition: background-color .12s; }
.admin-table tbody tr[data-open]:hover { background: var(--surface-2); }
.admin-table tbody tr.open { background: var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; align-items: end; min-width: 0; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid h3 { margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.plan-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin: 0; }
.plan-row legend { padding: 0 6px; font-weight: 600; }
.invite { background: var(--ok-soft); border-radius: var(--r-md); padding: 14px 16px; display: grid; gap: 8px; }
.sub-card .stat strong { font-size: 18px; }

/* ---------- branding & rating ---------- */
.shop-logo { max-width: 160px; max-height: 72px; object-fit: contain; justify-self: center; }
.rate { display: grid; gap: 12px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
.stars { display: flex; justify-content: center; gap: 6px; direction: ltr; }
.panel .star, .panel .star:hover:not(:disabled) {
  font-size: 30px; line-height: 1; padding: 6px; min-height: 52px; min-width: 52px;
  background: var(--surface-2); color: var(--line-strong); border-color: transparent;
}
.panel .star:hover, .panel .star:focus-visible { color: var(--accent); }
.stars-done { font-size: 28px; color: var(--accent); letter-spacing: 4px; direction: ltr; margin: 0; }
.accent-link { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); padding: 13px 22px; }
.comment { display: grid; gap: 8px; text-align: start; }
.comment textarea { resize: vertical; }
.brand-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(200px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 700px) { .brand-grid { grid-template-columns: minmax(0, 1fr); } }
.logo-box { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 18px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); }
.logo-box img { max-width: 160px; max-height: 100px; object-fit: contain; }
.comments summary { cursor: pointer; font-size: 14px; font-weight: 500; }
.comments ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.comments li { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 14px; font-size: 14px; }
.comments li p { margin: 4px 0 0; }
label .small { color: var(--muted); font-weight: 400; }
/* On the brand-coloured "ready" screen the logo sits on a white chip so it never disappears. */
body.is-ready .shop-logo { background: #fff; border-radius: var(--r-md); padding: 8px; }

/* ---------- language ---------- */
.lang-line { text-align: center; margin: 0; }
.lang-toggle { font-weight: 500; }
.panel .lang-toggle { padding: 4px 14px; font-size: 13px; }
