/* Restaurant QR — shared base: tokens, buttons, forms, dialogs, toasts */
:root {
  --accent: #c4512b;
  --accent-ink: #ffffff;
  --accent-soft: rgba(196, 81, 43, .13);
  --ok: #2f8a57;
  --warn: #d0901a;
  --danger: #c93a32;
  --info: #3a78c9;
  --radius: 16px;
  --radius-sm: 10px;
  --f-display: 'Fraunces', 'Tajawal', Georgia, serif;
  --f-body: 'Manrope', 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-ar: 'Tajawal', 'Manrope', system-ui, sans-serif;

  /* light (customer) defaults */
  --bg: #f6f0e6;
  --surface: #fffcf7;
  --surface2: #f1e9dc;
  --text: #231b15;
  --muted: #7d6f62;
  --line: #e6dccd;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 28px rgba(60, 40, 20, .08);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { font-family: var(--f-ar); }
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 42px; padding: 0 18px;
  border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; font-size: .95rem; letter-spacing: .01em;
  transition: transform .12s ease, background .15s ease, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface2); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 1.02rem; padding: 0 22px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: background .15s, transform .12s;
}
.icon-btn:hover { background: var(--surface2); }
.icon-btn:active { transform: scale(.94); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, .label { font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 84px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 520px) { .row2, .row3 { grid-template-columns: 1fr; } }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; transition: background .18s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }
html[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Dialogs ---------- */
.dlg-back {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 16px;
  background: rgba(20, 14, 10, .5); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .2s ease;
}
.dlg-back.in { opacity: 1; }
.dlg {
  width: min(460px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border-radius: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.35);
  transform: translateY(14px) scale(.98); transition: transform .22s cubic-bezier(.2,.9,.3,1.2);
  overflow: hidden;
}
.dlg-wide { width: min(720px, 100%); }
.dlg-back.in .dlg { transform: none; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.dlg-head h3 { margin: 0; font-family: var(--f-display); font-size: 1.3rem; font-weight: 650; }
.dlg-body { padding: 10px 20px 8px; overflow: auto; }
.dlg-msg { margin: 4px 0 8px; color: var(--muted); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px 18px; flex-wrap: wrap; }
.dlg-actions .btn { min-width: 110px; }

/* bottom sheet on phones */
@media (max-width: 640px) {
  .dlg-back.is-sheet { place-items: end center; padding: 0; }
  .is-sheet .dlg { width: 100%; max-height: 92dvh; border-radius: 24px 24px 0 0; transform: translateY(100%); }
  .is-sheet.in .dlg { transform: none; }
  .is-sheet .dlg-actions { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .is-sheet .dlg-actions .btn { flex: 1; }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; top: 14px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast {
  padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: .92rem;
  background: #231b15; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(-10px); transition: all .25s ease; text-align: center;
}
.toast.in { opacity: 1; transform: none; }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast-warn { background: var(--warn); color: #1b1410; }

/* ---------- Status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-new { color: #3a78c9; background: rgba(58,120,201,.14); }
.st-preparing { color: #d0901a; background: rgba(208,144,26,.15); }
.st-ready { color: #2f8a57; background: rgba(47,138,87,.15); }
.st-served { color: #8a7a6a; background: rgba(138,122,106,.16); }
.st-paid { color: #7b5cc9; background: rgba(123,92,201,.15); }
.st-cancelled { color: #c93a32; background: rgba(201,58,50,.13); }

.muted { color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { min-height: 100dvh; display: grid; place-items: center; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
