/* ================================================================
   base.css — Design tokens, reset, app shell, side panel, topbar
   ================================================================ */

:root {
  color-scheme: light;
  --ink: #171714;
  --muted: #77766f;
  --line: #e8e4d9;
  --paper: #f6f4ee;
  --surface: #fffdf8;
  --accent: #ef5a2f;
  --accent-dark: #d84620;
  --accent-soft: #fff0e8;
  --green: #277c53;
  --green-soft: #e4f4eb;
  --shadow: 0 20px 55px rgba(54, 44, 30, .09);
  --side: 238px;
  --order: 326px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; overflow-x: clip; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.hidden { display: none !important; }
body.app-booting .app-shell,
body.app-booting .mobile-nav,
body.app-booting .platform-sticker { display: none; }
body:not(.app-booting) .app-boot-loader { display: none; }
.app-boot-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: var(--paper);
}
.app-boot-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: app-boot-spin .7s linear infinite;
}
@keyframes app-boot-spin { to { transform: rotate(360deg); } }
.prices-hidden .price-only { display: none !important; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }

/* ---- App Shell ---- */
.app-shell { min-height: 100vh; padding-left: var(--side); padding-right: var(--order); }
.side-panel, .order-panel { position: fixed; top: 0; bottom: 0; z-index: 20; background: var(--surface); }
.side-panel { left: 0; display: flex; width: var(--side); flex-direction: column; padding: 24px 17px; border-right: 1px solid var(--line); }
.brand { display: flex; gap: 11px; align-items: center; padding: 7px; color: inherit; background: transparent; text-align: left; }
.brand-mark, .assistant-avatar { display: grid; place-items: center; color: white; background: var(--ink); border-radius: 15px; }
.brand-mark { width: 43px; height: 43px; flex: 0 0 43px; background: #fff; padding: 3px; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-mark svg, .assistant-avatar svg { stroke: none; fill: currentColor; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; font-weight: 900; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.main-nav { display: grid; gap: 6px; margin-top: 38px; }
.nav-button { position: relative; display: flex; min-height: 48px; align-items: center; gap: 12px; padding: 0 13px; color: #77766f; background: transparent; border-radius: 12px; font-size: 12px; font-weight: 800; text-align: left; }
.nav-button:hover, .nav-button.active { color: var(--accent-dark); background: var(--accent-soft); }
.nav-button svg { width: 18px; }
.nav-count { min-width: 20px; padding: 3px 6px; margin-left: auto; color: white; background: var(--accent); border-radius: 99px; font-size: 9px; font-style: normal; text-align: center; }
.side-callout { padding: 17px; margin-top: auto; background: var(--ink); border-radius: 16px; }
.side-callout span { display: block; margin-bottom: 12px; color: #b7b4aa; font-size: 10px; }
.side-callout a { display: flex; align-items: center; gap: 8px; color: white; font-size: 11px; font-weight: 900; text-decoration: none; }
.side-callout svg { width: 17px; color: #ff8b68; }

/* ---- Order Panel ---- */
.order-panel { right: 0; display: flex; width: var(--order); flex-direction: column; padding: 28px 22px; border-left: 1px solid var(--line); }
.order-panel-head { display: flex; align-items: flex-start; justify-content: space-between; }
.order-panel h2 { margin: 0; font-size: 20px; letter-spacing: -.04em; }
.text-button { padding: 6px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 800; }
.text-button:hover { color: var(--accent); }
.cart-lines { display: grid; gap: 10px; margin: 23px 0; overflow: auto; }
.order-panel .cart-lines { flex: 1; }
.cart-empty { display: grid; min-height: 210px; place-items: center; padding: 26px 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; text-align: center; }
.cart-empty svg { width: 28px; height: 28px; margin-bottom: 10px; color: #bbb5a8; }
.cart-empty strong, .cart-empty span { display: block; }
.cart-empty strong { color: var(--ink); font-size: 12px; }
.cart-empty span { margin-top: 5px; font-size: 10px; line-height: 1.5; }
.cart-line { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px; background: #faf8f2; border: 1px solid #eee9de; border-radius: 13px; }
.cart-line-art { display: grid; width: 46px; height: 46px; place-items: center; color: white; background: linear-gradient(145deg, #ff9268, var(--accent)); border-radius: 11px; font-size: 16px; font-weight: 900; }
.cart-line-copy { min-width: 0; }
.cart-line-copy strong, .cart-line-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line-copy strong { font-size: 11px; }
.cart-line-copy small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.line-actions { display: grid; justify-items: end; gap: 7px; }
.line-actions strong { font-size: 10px; }
.quantity-control { display: flex; align-items: center; gap: 7px; }
.quantity-control button { display: grid; width: 21px; height: 21px; place-items: center; color: var(--accent-dark); background: var(--accent-soft); border-radius: 6px; font-size: 13px; }
.quantity-control span { min-width: 10px; font-size: 9px; font-weight: 900; text-align: center; }
.order-panel-foot { padding-top: 18px; border-top: 1px solid var(--line); }
.total-row { display: flex; align-items: baseline; justify-content: space-between; }
.total-row span { color: var(--muted); font-size: 11px; font-weight: 700; }
.total-row strong { font-size: 22px; letter-spacing: -.05em; }
.primary-button, .secondary-button { width: 100%; min-height: 49px; border-radius: 12px; font-size: 11px; font-weight: 900; }
.primary-button { margin-top: 17px; color: white; background: var(--accent); box-shadow: 0 10px 25px rgba(239, 90, 47, .2); }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }
.secondary-button { margin-top: 8px; color: var(--ink); background: #ece8de; }
.order-panel-foot p { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 12px 0 0; color: var(--muted); font-size: 8px; }
.order-panel-foot p svg { width: 13px; color: var(--green); }

/* ---- Main Stage & Topbar ---- */
.main-stage { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; min-height: 74px; align-items: center; justify-content: space-between; padding: 13px 24px; background: rgba(246, 244, 238, .9); border-bottom: 1px solid rgba(232, 228, 217, .8); backdrop-filter: blur(16px); }
.topbar-brand { display: none; align-items: center; gap: 10px; min-width: 0; padding: 4px 6px 4px 4px; color: inherit; background: transparent; border-radius: 12px; text-align: left; }
.topbar-brand:hover { background: rgba(255, 255, 255, .55); }
.topbar-brand-mark { display: grid; width: 36px; height: 36px; place-items: center; flex: 0 0 36px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.topbar-brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.topbar-brand-name { overflow: hidden; font-size: 13px; font-weight: 900; letter-spacing: -.03em; text-overflow: ellipsis; white-space: nowrap; }
.topbar-status { display: grid; grid-template-columns: auto auto; gap: 1px 7px; align-items: center; margin-left: auto; }
.open-dot { width: 7px; height: 7px; background: #36a46d; border-radius: 99px; box-shadow: 0 0 0 4px var(--green-soft); }
.topbar strong { font-size: 10px; }
.topbar small { grid-column: 2; color: var(--muted); font-size: 8px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.language-select { display: inline-flex; min-height: 36px; align-items: center; gap: 6px; padding: 0 7px 0 10px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 10px; font-size: 8px; font-weight: 900; }
.language-select span { color: var(--muted); text-transform: uppercase; }
.language-select .lang-flag { color: inherit; text-transform: none; font-size: 14px; line-height: 1; }
.language-select select { min-width: 48px; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 9px; font-weight: 900; }
.install-button { min-height: 36px; padding: 0 13px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 10px; font-size: 9px; font-weight: 800; }
.cart-button { position: relative; display: none; width: 38px; height: 38px; place-items: center; color: white; background: var(--ink); border-radius: 11px; }
.cart-button svg { width: 17px; }
.cart-button span { position: absolute; top: -5px; right: -4px; display: grid; min-width: 17px; height: 17px; place-items: center; padding: 0 4px; color: white; background: var(--accent); border: 2px solid var(--paper); border-radius: 99px; font-size: 7px; font-weight: 900; }
.view { display: none; min-height: calc(100vh - 74px); }
.view.active { display: block; }

/* ---- Keyframes (shared) ---- */
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 50% { opacity: .25; transform: translateY(-2px); } }
@keyframes wave { to { transform: scaleY(.45); } }
@keyframes softPulse { 50% { box-shadow: 0 0 0 5px rgba(239,90,47,.15); } }
@keyframes breathe { 50% { transform: scale(1.08); box-shadow: 0 0 70px rgba(239,90,47,.7); } }
@keyframes rings { to { opacity: 0; transform: scale(1.18); } }
@keyframes voiceLevel { to { transform: scaleY(.4); opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dialogPop { from { opacity: 0; transform: scale(.96) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes cartSpin { to { transform: rotate(360deg); } }

/* ---- Responsive: side panel / topbar ---- */
@media (max-width: 1180px) {
  :root { --side: 205px; --order: 290px; }
  .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1280px) {
  .app-shell { padding: 0; }
  .side-panel, .order-panel { display: none; }
  .topbar-brand { display: flex; flex: 0 1 auto; min-width: 0; }
  .topbar-status { display: none; }
  .cart-button { display: grid; }
  :root { --topbar-h: 74px; --mobile-nav-h: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .main-stage { padding-bottom: var(--mobile-nav-h); }
  .view { min-height: calc(100vh - var(--topbar-h) - var(--mobile-nav-h)); }
  .chat-layout { height: calc(100vh - var(--topbar-h) - var(--mobile-nav-h)); }
  .mobile-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 50; display: flex; width: 100%; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); background: rgba(255,253,248,.97); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(54,44,30,.1); backdrop-filter: blur(15px); }
  .mobile-nav button { flex: 1 1 0; min-width: 0; display: grid; min-height: 48px; place-items: center; align-content: center; gap: 2px; color: #8b877c; background: transparent; border-radius: 11px; font-size: 9px; font-weight: 900; }
  .mobile-nav button.active { color: var(--accent-dark); background: var(--accent-soft); }
  .mobile-nav svg { width: 17px; height: 17px; }
  .mobile-cart-icon { position: relative; }
  .mobile-cart-icon em { position: absolute; top: -7px; right: -12px; display: grid; min-width: 15px; height: 15px; place-items: center; padding: 0 3px; color: white; background: var(--accent); border-radius: 99px; font-size: 6px; font-style: normal; }
  .fab-cart { bottom: calc(var(--mobile-nav-h) + 12px); }
  .platform-sticker { bottom: calc(var(--mobile-nav-h) + 12px); }
  .toast { bottom: calc(var(--mobile-nav-h) + 12px); }
  .guided-footer { right: 0; bottom: var(--mobile-nav-h); left: 0; }
  body.pos-mode .guided-footer { bottom: 0; }
  .pos-page { padding: 20px; }
  .pos-card, .pos-launcher { padding: 24px; }
  .pos-head { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .pos-modes { grid-template-columns: 1fr; }
  .guided-layout { grid-template-columns: 1fr; }
  .guided-summary { position: static; }
}
@media (max-width: 620px) {
  :root { --topbar-h: 64px; }
  .topbar { min-height: 64px; padding: 10px 13px; }
  .topbar-brand-name, .conversations-button, .cart-button { display: none !important; }
  .language-select { padding: 0 5px; }
  .language-select span { display: none; }
  .language-select .lang-flag { display: inline-block; }
  .language-select select { min-width: 42px; }
}
