:root {
  --bg: #f1ede2;
  --bg-soft: #e9e3d3;
  --ink: #2a2620;
  --muted: #93897a;
  --muted-2: #b0a795;
  --line: #e2dac7;
  --card: #fffdf9;
  --accent: #5c6b3f;
  --accent-soft: #7c8a5c;
  --dot-placed: #cf9a3f;
  --dot-started: #6f8f57;
  --dot-ready: #4c7a94;
  --pill-dark: #211e19;
  --pill-dark-text: #f6f2e7;
  --shadow: 0 10px 30px rgba(40, 34, 20, 0.08);
  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

.en {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------ */
/* Bilingual emphasis — the toggle mutes the non-primary language for
   auxiliary labels. The hero headline stays fully bilingual always. */
/* ------------------------------------------------------------------ */
html[data-lang="ar"] .status-line .en,
html[data-lang="ar"] .agent-status .en,
html[data-lang="ar"] .cta .en,
html[data-lang="ar"] .confirm-btn .en,
html[data-lang="ar"] .subtotal-label .en,
html[data-lang="ar"] .side-panel-head .en,
html[data-lang="ar"] .link-btn .en,
html[data-lang="ar"] .order-panel-head .en {
  opacity: 0.45;
  font-size: 0.82em;
}

html[data-lang="en"] .status-line .ar,
html[data-lang="en"] .agent-status .ar,
html[data-lang="en"] .cta .ar,
html[data-lang="en"] .confirm-btn .ar,
html[data-lang="en"] .subtotal-label .ar,
html[data-lang="en"] .side-panel-head .ar,
html[data-lang="en"] .link-btn .ar,
html[data-lang="en"] .order-panel-head .ar {
  opacity: 0.45;
  font-size: 0.82em;
}

/* ------------------------------------------------------------------ */
/* App shell                                                           */
/* ------------------------------------------------------------------ */
.app {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 30px;
  z-index: 5;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--pill-dark);
  border-radius: 999px;
  padding: 4px;
  border: none;
  cursor: pointer;
}
.lang-opt {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: rgba(246, 242, 231, 0.55);
  transition: background 0.2s ease, color 0.2s ease;
}
.lang-opt.active {
  background: var(--pill-dark-text);
  color: var(--pill-dark);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: row-reverse;
}
.brand-mark { width: 30px; height: 30px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.brand-text strong { font-family: var(--font-serif); font-size: 17px; letter-spacing: 0.3px; }
.tagline {
  font-size: 9.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.tagline-sep { margin: 0 6px; opacity: 0.6; }

/* ------------------------------------------------------------------ */
/* Stage layout — idle: centered hero. active: order panel + hero.     */
/* ------------------------------------------------------------------ */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 20px 40px 100px;
  position: relative;
}

.app.state-active .stage {
  grid-template-columns: minmax(260px, 320px) 1fr minmax(260px, 340px);
  place-items: stretch;
  gap: 32px;
}

.app.state-active .hero { justify-self: center; align-self: center; }

@media (max-width: 1180px) {
  .app.state-active .stage { grid-template-columns: minmax(260px, 320px) 1fr; }
  .transcript-panel { display: none; }
}

/* ------------------------------------------------------------------ */
/* Hero: headline / avatar / status / CTA                              */
/* ------------------------------------------------------------------ */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 560px;
}

.headline {
  margin: 0 0 34px;
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.25;
}
.headline .en { display: block; font-size: 38px; color: var(--ink); }
.headline .ar { display: block; font-size: 30px; margin-top: 4px; }
.headline .accent { color: var(--accent); }

.app.state-active .headline { display: none; }

.avatar-wrap { position: relative; margin-bottom: 22px; }

.avatar {
  position: relative;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow), 0 0 0 10px rgba(255, 253, 249, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

.avatar-orb {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f3ead9, #d9c9a8 55%, #b99f76 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: breathe 4.5s ease-in-out infinite;
}
.avatar-glyph {
  width: 56px;
  height: 56px;
  color: #6b5636;
  opacity: 0.85;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.avatar--connecting .avatar-ring {
  border-color: var(--muted-2);
  border-top-color: var(--accent);
  animation: spin 1.1s linear infinite;
}
.avatar--connecting .avatar-orb { animation-duration: 2s; }

.avatar--live .avatar-ring {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 0 rgba(92, 107, 63, 0.35);
  animation: pulseRing 1.6s ease-out infinite;
}
.avatar--live .avatar-orb { animation-duration: 1.8s; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(92, 107, 63, 0.35); }
  70% { box-shadow: 0 0 0 16px rgba(92, 107, 63, 0); }
  100% { box-shadow: 0 0 0 0 rgba(92, 107, 63, 0); }
}

.agent-status {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 22px;
}
.dot-sep { margin: 0 8px; opacity: 0.6; }

.caption {
  max-width: 420px;
  min-height: 20px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  background: rgba(255, 253, 249, 0.75);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  margin-bottom: 18px;
  transition: opacity 0.25s ease;
}
.caption.user { color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------------ */
/* Pills / buttons                                                     */
/* ------------------------------------------------------------------ */
.pill {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.12s ease, opacity 0.2s ease, background 0.2s ease;
}
.pill:active { transform: scale(0.97); }
.pill:disabled { cursor: default; }

.pill-dark {
  background: var(--pill-dark);
  color: var(--pill-dark-text);
  padding: 13px 26px;
}
.pill-dark:disabled { opacity: 0.45; }

.pill-outline {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 12px 25px;
}
.pill-outline:hover { border-color: #b5675a; color: #b5675a; }

.pill-accent {
  background: var(--accent);
  color: var(--pill-dark-text);
  padding: 13px 26px;
}

.cta { font-size: 15px; }
.cta:disabled { opacity: 0.5; }
.mic-icon { font-size: 15px; }

.confirm-btn {
  width: 100%;
  justify-content: center;
  margin-top: 12px;
}
.lock-icon { font-size: 13px; }
.confirm-btn.ready {
  opacity: 1;
  background: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Order panel (left, appears once a call is active)                   */
/* ------------------------------------------------------------------ */
.order-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 140px);
}

.order-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
  margin-bottom: 6px;
}
.order-panel-head h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 24px;
  margin: 0;
}
.chip {
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
}

.status-line {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 18px;
}

.current-order {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 60px;
}

.hint { color: var(--muted-2); font-size: 12.5px; line-height: 1.6; }

.order-line {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
}
.order-line .line-top { display: flex; justify-content: space-between; font-weight: 700; }
.order-line .line-sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.order-line.unavailable { background: #f3e6df; color: #8a4a34; }

.order-panel-foot {
  border-top: 1px dashed var(--line);
  margin-top: 16px;
  padding-top: 16px;
}
.subtotal-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-direction: row-reverse;
}
.subtotal-value { font-family: var(--font-serif); font-size: 20px; }
.subtotal-label { font-size: 11px; color: var(--muted); }

.order-panel.receipt { border-color: var(--accent-soft); }
.order-panel.receipt .order-panel-head h2::before { content: "🧾 "; }

/* ------------------------------------------------------------------ */
/* Transcript panel (right, appears once a call is active)             */
/* ------------------------------------------------------------------ */
.transcript-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 140px);
}
.transcript-panel .side-panel-head { margin-bottom: 14px; }
.transcript-panel h2 { font-family: var(--font-serif); font-weight: 400; font-size: 22px; margin: 0; }

.transcript-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 92%;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--bg-soft);
}
.msg.user {
  align-self: flex-end;
  background: var(--pill-dark);
  color: var(--pill-dark-text);
}
.msg.system {
  align-self: center;
  color: var(--muted);
  font-size: 11.5px;
  font-style: italic;
  background: none;
}

/* ------------------------------------------------------------------ */
/* Bottom-left corner controls                                         */
/* ------------------------------------------------------------------ */
.corner-controls {
  position: fixed;
  left: 30px;
  bottom: 26px;
  display: flex;
  gap: 12px;
  z-index: 5;
}

.link-btn {
  position: relative;
  overflow: hidden;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.link-btn:hover { border-color: var(--muted-2); color: var(--ink); }

.hold-reset { user-select: none; }
.hold-fill {
  position: absolute;
  inset: 0;
  background: var(--accent-soft);
  opacity: 0.25;
  width: 0%;
  transition: width 0.05s linear;
  z-index: 0;
}
.hold-label { position: relative; z-index: 1; display: flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------------ */
/* Bottom-right live order-status stack                                */
/* ------------------------------------------------------------------ */
.order-stack {
  position: fixed;
  right: 30px;
  bottom: 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  align-items: flex-end;
}

.order-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 11.5px;
  box-shadow: var(--shadow);
  animation: pillIn 0.3s ease;
  direction: rtl;
}
.order-pill .pill-status {
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 10px;
  color: var(--muted);
}
.order-pill .pill-name { font-weight: 600; }
.order-pill .pill-code { color: var(--muted); font-variant-numeric: tabular-nums; }
.order-pill .pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot-placed); }

@keyframes pillIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------ */
/* Slide-in side panels (menu + kitchen board) + scrim                 */
/* ------------------------------------------------------------------ */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 20, 0.28);
  backdrop-filter: blur(2px);
  z-index: 20;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.scrim.visible { opacity: 1; }

.side-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(440px, 92vw);
  background: var(--bg);
  z-index: 21;
  display: flex;
  flex-direction: column;
  padding: 26px 22px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease;
}

.menu-panel { left: 0; transform: translateX(-105%); }
.menu-panel.open { transform: translateX(0); }

.kitchen-panel { right: 0; transform: translateX(105%); }
.kitchen-panel.open { transform: translateX(0); }

.side-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
  margin-bottom: 18px;
}
.side-panel-head h2 { font-family: var(--font-serif); font-weight: 400; font-size: 22px; margin: 0; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--bg-soft);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
}

.menu-tabs {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 10px;
  flex-direction: row-reverse;
}
.menu-tab {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  padding-bottom: 4px;
}
.menu-tab.active { color: var(--ink); font-weight: 700; border-bottom: 2px solid var(--ink); }

.menu-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

.menu-card {
  display: flex;
  flex-direction: row-reverse;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
}
.menu-card-swatch {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: var(--bg-soft);
}
.menu-card-body { flex: 1; text-align: right; }
.menu-card-top { display: flex; justify-content: space-between; flex-direction: row-reverse; align-items: baseline; gap: 8px; }
.menu-card-name { font-weight: 700; font-size: 14.5px; }
.menu-card-price { font-size: 11.5px; color: var(--accent); font-weight: 700; }
.menu-card-desc { font-size: 12px; color: var(--muted); margin: 4px 0 8px; line-height: 1.5; }
.menu-card-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.menu-card-tag {
  font-size: 10px;
  color: var(--muted);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 3px 9px;
}

/* ------------------------------------------------------------------ */
/* Kitchen board                                                       */
/* ------------------------------------------------------------------ */
.order-board { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.order-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  animation: pillIn 0.3s ease;
}
.order-card .order-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.order-card .order-meta { color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
.order-card ul { margin: 0; padding-inline-start: 18px; font-size: 12.5px; }

/* ------------------------------------------------------------------ */
/* Scrollbars + responsive                                             */
/* ------------------------------------------------------------------ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

@media (max-width: 860px) {
  .app.state-active .stage { grid-template-columns: 1fr; }
  .order-panel { max-height: none; }
  .headline .en { font-size: 28px; }
  .headline .ar { font-size: 22px; }
  .avatar { width: 180px; height: 180px; }
  .avatar-orb { width: 116px; height: 116px; }
  .corner-controls { left: 16px; bottom: 16px; }
  .order-stack { right: 16px; bottom: 16px; }
}
