/* Kashi House: cobalt and turmeric from Lahore's kashi-kari tilework, on cool lime-washed plaster. */

:root {
  --plaster: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #e8ecf5;
  --line: #d9dfeb;
  --ink: #1b1f3b;
  --muted: #5d6482;
  --kashi: #2a4c9c;
  --kashi-deep: #1f3a7a;
  --kashi-soft: #e2e8f6;
  --haldi: #e0a526;
  --haldi-ink: #3b2a04;
  --chili: #b93a2b;
  --leaf: #2f7d5b;
  --on-kashi: #ffffff;
  --shadow: 0 10px 30px rgba(27, 31, 59, 0.14);
  --rail: 700px;
  --tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' fill='%23f3f5f9'/%3E%3Cpath d='M20 3l5 12 12 5-12 5-5 12-5-12-12-5 12-5z' fill='%232a4c9c'/%3E%3Crect x='11' y='11' width='18' height='18' fill='none' stroke='%232a4c9c' stroke-width='2'/%3E%3Ccircle cx='20' cy='20' r='3.5' fill='%23e0a526'/%3E%3Cpath d='M0 0l4 0-4 4zM40 0l0 4-4-4zM0 40l0-4 4 4zM40 40l-4 0 4-4z' fill='%23e0a526'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --plaster: #121530;
    --panel: #1b1f3f;
    --panel-2: #252a52;
    --line: #2d3360;
    --ink: #eceef7;
    --muted: #a0a6c4;
    --kashi: #7f9ce6;
    --kashi-deep: #6585d8;
    --kashi-soft: #252c58;
    --chili: #e5745f;
    --leaf: #5cbf92;
    --on-kashi: #0f1330;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  --plaster: #121530;
  --panel: #1b1f3f;
  --panel-2: #252a52;
  --line: #2d3360;
  --ink: #eceef7;
  --muted: #a0a6c4;
  --kashi: #7f9ce6;
  --kashi-deep: #6585d8;
  --kashi-soft: #252c58;
  --chili: #e5745f;
  --leaf: #5cbf92;
  --on-kashi: #0f1330;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--plaster);
  color: var(--ink);
  font: 400 15.5px/1.55 "Hanken Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

:focus-visible { outline: 2px solid var(--haldi); outline-offset: 2px; }

.wordmark, .display {
  font-family: "Rozha One", Georgia, serif;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.005em;
}

/* Signature: the tile frieze. Idle it sits still; while the host is thinking it slides. */
.frieze {
  flex: none;
  height: 14px;
  background: var(--tile) 0 50% / 14px 14px repeat-x;
  border-block: 1px solid var(--kashi);
}
.frieze.busy { animation: tile-run 0.9s linear infinite; }
@keyframes tile-run { to { background-position-x: 14px; } }

/* ---------- Gate ---------- */

#gate {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.frieze.tall {
  height: 72px;
  background-size: 72px 72px;
  border-top: 0;
  border-bottom: 3px solid var(--kashi);
}

#gate-form {
  width: min(400px, calc(100% - 32px));
  margin: auto;
  padding: 48px 0 64px;
  text-align: center;
}

#gate .wordmark { font-size: clamp(48px, 14vw, 84px); color: var(--kashi); white-space: nowrap; }

.gate-tagline { font-size: 18px; font-weight: 500; margin-top: 14px; }

.gate-address { color: var(--muted); font-size: 14px; margin: 6px 0 36px; }

.gate-field {
  display: flex;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  transition: border-color 0.15s;
}
.gate-field:focus-within { border-color: var(--kashi); }

.gate-field input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}
.gate-field input::placeholder { color: var(--muted); }
.gate-field input:focus { outline: none; }

#gate-enter {
  background: var(--kashi);
  color: var(--on-kashi);
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 20px;
}
#gate-enter:hover { background: var(--kashi-deep); }
#gate-enter:disabled { opacity: 0.6; cursor: default; }

.gate-error { color: var(--chili); font-size: 14px; margin-top: 14px; }

/* ---------- Chat frame ---------- */

#chat {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(16px, 4vw, 28px);
  background: var(--panel);
}

.topbar-id { display: flex; align-items: baseline; gap: 14px; min-width: 0; }

.topbar .wordmark.sm {
  font-size: 26px;
  color: var(--kashi);
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--leaf); }
.status.closed .dot { background: var(--chili); }

.topbar-side { display: flex; align-items: center; gap: 6px; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--kashi);
  color: var(--kashi);
  font-weight: 600;
  font-size: 14px;
}
.pill-btn svg { width: 17px; height: 17px; }
.pill-btn:hover { background: var(--kashi-soft); }

/* ---------- Messages ---------- */

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 26px clamp(16px, 4vw, 28px);
}

.rail {
  max-width: var(--rail);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.msg.agent {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.user {
  align-self: flex-end;
  background: var(--kashi);
  color: var(--on-kashi);
  border-bottom-right-radius: 4px;
}
.msg a { color: var(--kashi); text-underline-offset: 2px; }
.msg.user a { color: inherit; font-weight: 600; }

.msg.note {
  align-self: center;
  max-width: 100%;
  background: none;
  color: var(--chili);
  font-size: 13.5px;
  padding: 2px 0;
}

.msg.typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.msg.typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--kashi);
  animation: pulse 1.1s ease-in-out infinite;
}
.msg.typing i:nth-child(2) { animation-delay: 0.18s; }
.msg.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Confirmation cards ---------- */

.card {
  align-self: flex-start;
  width: min(360px, 92%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--kashi);
  border-radius: 6px 6px 14px 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: card-in 0.35s ease-out;
}
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } }

.card.cancelled { border-top-color: var(--chili); }
.card.cancelled .card-code { text-decoration: line-through; color: var(--muted); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 10px;
}
.card-kind { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.card-title { font-size: 20px; margin-top: 4px; }
.card-code {
  font-family: "Rozha One", Georgia, serif;
  font-size: 22px;
  color: var(--kashi);
  white-space: nowrap;
}

.card-rows { padding: 2px 16px 12px; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14.5px; }
.card-rows dt { color: var(--muted); }
.card-rows dd { font-weight: 500; text-align: right; }

.receipt { padding: 4px 16px 10px; font-size: 14.5px; }
.receipt-line { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.receipt-line span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.receipt-line.sub { color: var(--muted); }
.receipt-line.total {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-weight: 700;
  font-size: 16px;
}

.card-foot {
  padding: 10px 16px 12px;
  background: var(--kashi-soft);
  font-size: 13.5px;
  color: var(--ink);
}

/* ---------- Composer ---------- */

.composer {
  border-top: 1px solid var(--line);
  padding: 10px clamp(16px, 4vw, 28px) calc(14px + env(safe-area-inset-bottom));
  background: var(--panel);
}

.chips {
  max-width: var(--rail);
  margin: 0 auto 10px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--kashi-soft);
  color: var(--kashi);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}
.chip:hover { background: var(--kashi); color: var(--on-kashi); }
.chip:first-child { background: var(--haldi); color: var(--haldi-ink); }

.compose-row, .record-row {
  max-width: var(--rail);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#input {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 132px;
  background: var(--plaster);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  padding: 10px 14px;
  transition: border-color 0.15s;
}
#input::placeholder { color: var(--muted); }
#input:focus { outline: none; border-color: var(--kashi); }

.icon-btn {
  flex: none;
  color: var(--muted);
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--ink); background: var(--panel-2); }

.icon-btn.round {
  width: 42px; height: 42px;
  background: var(--plaster);
  border: 1px solid var(--line);
}
.icon-btn.round.primary {
  background: var(--kashi);
  border-color: var(--kashi);
  color: var(--on-kashi);
}
.icon-btn.round.primary:hover { background: var(--kashi-deep); }

.record-row { align-items: center; }

#wave {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: var(--plaster);
  border: 1px solid var(--kashi);
  border-radius: 12px;
}

#rec-time {
  color: var(--kashi);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: center;
}

#rec-cancel:hover { color: var(--chili); }

/* Voice bubble */

.voice { display: flex; align-items: center; gap: 10px; min-width: 190px; }

.vp-btn {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
}
.vp-btn svg { width: 14px; height: 14px; }

.vp-track { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
.vp-fill { height: 100%; width: 0; background: currentColor; }

.vp-time { font-size: 12px; font-variant-numeric: tabular-nums; opacity: 0.8; }

.transcript {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 13.5px;
  font-style: italic;
  opacity: 0.9;
}

/* ---------- Menu sheet ---------- */

.sheet { position: fixed; inset: 0; z-index: 10; display: flex; justify-content: flex-end; }

.sheet-scrim { position: absolute; inset: 0; background: rgba(18, 21, 48, 0.45); animation: fade 0.2s ease-out; }
@keyframes fade { from { opacity: 0; } }

.sheet-panel {
  position: relative;
  width: min(480px, 100%);
  height: 100%;
  background: var(--plaster);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slide-in 0.25s ease-out;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px 20px;
  background: var(--panel);
}
.sheet-head h2 { font-size: 30px; color: var(--kashi); }

.cat-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 16px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs button {
  flex: none;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}
.cat-tabs button.active { background: var(--kashi); color: var(--on-kashi); }

.menu-body { flex: 1; overflow-y: auto; padding: 4px 20px 28px; scroll-padding-top: 8px; }

.menu-cat { padding-top: 22px; }
.menu-cat h3 { font-family: "Rozha One", Georgia, serif; font-weight: 400; font-size: 23px; line-height: 1.1; }
.menu-cat-note { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

.dish { padding: 14px 0; border-bottom: 1px solid var(--line); }
.dish:last-child { border-bottom: 0; }
.dish-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.dish-name { font-weight: 600; font-size: 16px; }
.dish-desc { color: var(--muted); font-size: 14px; margin-top: 3px; max-width: 60ch; }

.tags { display: inline-flex; gap: 5px; margin-left: 6px; vertical-align: 2px; }
.tag { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.tag.signature { background: var(--haldi); color: var(--haldi-ink); }
.tag.spicy { color: var(--chili); border: 1px solid currentColor; }
.tag.veg { color: var(--leaf); border: 1px solid currentColor; }
.tag.popular, .tag.seasonal, .tag.pre-order { color: var(--kashi); border: 1px solid currentColor; }

.dish-adds { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.add-btn .plus {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--kashi);
  color: var(--on-kashi);
  display: grid;
  place-items: center;
  font-weight: 700;
  line-height: 1;
}
.add-btn:hover { border-color: var(--kashi); }
.add-btn .qty { font-weight: 700; color: var(--kashi); }

.cart-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--ink);
  color: var(--plaster);
}
.cart-sum { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.cart-sum span { font-size: 13.5px; opacity: 0.8; font-variant-numeric: tabular-nums; }
.cart-clear { font-size: 14px; opacity: 0.8; padding: 8px; }
.cart-go {
  background: var(--haldi);
  color: var(--haldi-ink);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
}

@media (max-width: 520px) {
  .topbar .wordmark.sm { font-size: 22px; }
  .topbar-id { flex-direction: column; gap: 2px; }
  .msg { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
  .frieze.busy { animation: none; opacity: 0.6; }
  .msg.typing i { animation: none; opacity: 0.7; }
  .card, .sheet-panel, .sheet-scrim { animation: none; }
}

/* ---------- Manager dashboard ---------- */

body.admin { min-height: 100%; }
body.admin .topbar { position: sticky; top: 0; z-index: 2; }
body.admin a.pill-btn { text-decoration: none; }

.admin-main { max-width: 960px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 28px) 64px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stats div { background: var(--panel); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stats strong { font-family: "Rozha One", Georgia, serif; font-weight: 400; font-size: 28px; line-height: 1.1; color: var(--kashi); font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 13.5px; }

.admin-tabs { display: flex; align-items: center; gap: 6px; margin: 28px 0 8px; }
.admin-tabs button { padding: 7px 16px; border-radius: 999px; font-weight: 600; color: var(--muted); }
.admin-tabs button[aria-selected="true"] { background: var(--kashi); color: var(--on-kashi); }
.refreshed { margin-left: auto; color: var(--muted); font-size: 13px; }

.day { font-size: 22px; margin: 26px 0 8px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row.dim { opacity: 0.55; }
.row-main { display: flex; gap: 16px; min-width: 0; }
.row-time { flex: none; width: 76px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--kashi); }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.row-sub a { color: inherit; }
.muted { color: var(--muted); font-weight: 400; }

.status-select {
  flex: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.status-select.s-confirmed, .status-select.s-received { border-color: var(--kashi); color: var(--kashi); }
.status-select.s-preparing, .status-select.s-on_the_way, .status-select.s-seated { border-color: var(--haldi); }
.status-select.s-cancelled, .status-select.s-no_show { color: var(--chili); }

.empty { color: var(--muted); padding: 32px 0; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row { flex-direction: column; align-items: stretch; gap: 8px; }
  .row-main { gap: 12px; }
  .row-time { width: 64px; }
  .status-select { align-self: flex-end; }
}
