/* ==========================================================================
   Bar Queue — общая дизайн-система
   Тёмная по умолчанию, светлая по prefers-color-scheme,
   поверх всего — themeParams Telegram (см. js/theme.js)
   ========================================================================== */

:root {
  --ink:        #0e0f13;
  --surface:    #171922;
  --surface-2:  #1f222d;
  --line:       #2b2f3d;
  --text:       #f2f3f7;
  --muted:      #9aa0b4;

  --accent:     #ffb454;
  --accent-ink: #241703;
  --accent-soft: rgba(255, 180, 84, .14);

  --ok:         #3ddc84;
  --ok-soft:    rgba(61, 220, 132, .14);
  --warn:       #ffcc4d;
  --danger:     #ff6b6b;
  --danger-soft: rgba(255, 107, 107, .13);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .2);
  --tap: 46px;
  --maxw: 620px;
}

@media (prefers-color-scheme: light) {
  :root {
    --ink:       #f4f5f8;
    --surface:   #ffffff;
    --surface-2: #f0f1f5;
    --line:      #e2e4ec;
    --text:      #14161d;
    --muted:     #6b7288;
    --accent:    #e58a11;
    --accent-ink: #fff8ec;
    --accent-soft: rgba(229, 138, 17, .12);
    --ok:        #12a95c;
    --ok-soft:   rgba(18, 169, 92, .12);
    --danger:    #d93b3b;
    --danger-soft: rgba(217, 59, 59, .1);
    --shadow: 0 10px 30px rgba(20, 22, 29, .1);
    --shadow-sm: 0 2px 8px rgba(20, 22, 29, .07);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.wrap-wide { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* --- Кнопки --------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text);
  font-weight: 600; cursor: pointer;
  transition: transform .12s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ok      { background: var(--ok); color: #05230f; }
.btn-ghost   { background: transparent; border-color: var(--line); }
.btn-danger  { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-block   { width: 100%; }
.btn-sm      { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: var(--r-sm); }
.btn-lg      { min-height: 56px; font-size: 17px; border-radius: var(--r-lg); }

.icon-btn {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line); cursor: pointer;
}

/* --- Поля ----------------------------------------------------------------- */

.input, textarea.input, select.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 72px; resize: vertical; line-height: 1.4; }
.field { display: grid; gap: 6px; }
.field > label { font-size: 13px; color: var(--muted); font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 48px; height: 28px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .18s ease;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: transform .18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* --- Шапка ---------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--ink) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 58px; }
.topbar h1 { font-size: 18px; }
.brand-dot {
  width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), #ff7a59); font-size: 18px;
}

/* --- Бейджи и карточки ---------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
  background: var(--surface-2); color: var(--muted);
}
.badge-ok     { background: var(--ok-soft);     color: var(--ok); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* --- Меню гостя ----------------------------------------------------------- */

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.menu-list { display: grid; gap: 12px; padding: 8px 0 140px; }

.item {
  display: flex; gap: 14px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  animation: rise .35s ease both;
}
.item.out { opacity: .5; }
.item-photo {
  flex: 0 0 92px; width: 92px; height: 92px; border-radius: var(--r-md);
  object-fit: cover; background: var(--surface-2);
  display: grid; place-items: center; font-size: 34px; overflow: hidden;
}
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-name { font-size: 17px; font-weight: 700; }
.item-comp { font-size: 14px; color: var(--muted); }
.item-desc { font-size: 13px; color: var(--muted); opacity: .85; }
.item-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: auto; }

.qty { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.qty button {
  width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent;
  color: var(--text); font-size: 20px; cursor: pointer; line-height: 1;
}
.qty .n { min-width: 22px; text-align: center; font-weight: 700; }
.add-btn { min-height: 38px; padding: 0 16px; border-radius: 999px; }

/* --- Нижняя панель корзины ------------------------------------------------ */

.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  transform: translateY(120%); transition: transform .28s cubic-bezier(.2, .8, .3, 1);
}
.cartbar.show { transform: translateY(0); }
.cartbar-inner { max-width: var(--maxw); margin: 0 auto; display: grid; gap: 10px; }
.cart-lines { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.cart-lines .line { display: flex; justify-content: space-between; gap: 12px; }

/* --- Экран статуса заказа -------------------------------------------------- */

.status-screen { padding: 24px 0 60px; display: grid; gap: 16px; animation: rise .35s ease both; }
.order-card {
  position: relative; overflow: hidden; text-align: center;
  padding: 28px 20px; border-radius: 26px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.order-card.is-ready {
  background: linear-gradient(160deg, var(--ok), #1fa864); border-color: transparent; color: #04240f;
}
.order-card.is-ready .order-label,
.order-card.is-ready .order-sub { color: rgba(4, 36, 15, .72); }
.order-label { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.order-number { font-size: 68px; font-weight: 800; letter-spacing: -.04em; line-height: 1.05; margin: 4px 0 2px; }
.order-state { font-size: 20px; font-weight: 700; }
.order-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.order-items { display: grid; gap: 6px; margin-top: 16px; font-size: 15px; }
.order-items .line { display: flex; justify-content: center; gap: 8px; }

.queue-strip { display: flex; gap: 10px; }
.queue-cell {
  flex: 1; text-align: center; padding: 14px 8px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.queue-cell .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.queue-cell .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.pulse-ring {
  width: 74px; height: 74px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 1.1s linear infinite;
}
.ready-check { font-size: 56px; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }

/* --- Панель бариста ------------------------------------------------------- */

.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 14px 0 40px; align-items: start; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }

.column { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; }
.column-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.column-head .title { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.column-body { display: grid; gap: 10px; min-height: 40px; }

.order-tile {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px;
  background: var(--surface-2); animation: rise .3s ease both;
}
.order-tile.fresh { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.order-tile.late  { border-color: var(--danger); }
.tile-head { display: flex; align-items: baseline; gap: 10px; }
.tile-num { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.tile-guest { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-timer { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; color: var(--muted); }
.tile-timer.late { color: var(--danger); }
.tile-items { margin: 8px 0 10px; display: grid; gap: 3px; font-size: 15px; }
.tile-items b { font-weight: 700; }
.tile-actions { display: flex; gap: 8px; }
.tile-actions .btn-next { flex: 1; }
.tile-actions .btn-cancel { flex: 0 0 auto; width: 46px; padding: 0; font-size: 16px; }

.stoplist { display: grid; gap: 8px; }
.stoplist-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
}

/* --- Админ ---------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { padding: 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.stat .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

.admin-item {
  display: grid; grid-template-columns: 84px 1fr; gap: 14px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.admin-photo {
  width: 84px; height: 84px; border-radius: var(--r-md); object-fit: cover;
  background: var(--surface-2); display: grid; place-items: center; font-size: 28px; overflow: hidden;
}
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px) { .admin-grid { grid-template-columns: 1fr; } .admin-item { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 6px; padding: 12px 0; }
.tab {
  padding: 9px 16px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); cursor: pointer; font-weight: 600; font-size: 14px;
}
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* --- Логин ---------------------------------------------------------------- */

.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; padding: 28px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card .logo { font-size: 40px; text-align: center; }

/* --- Тосты ---------------------------------------------------------------- */

.toasts { position: fixed; left: 0; right: 0; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast {
  max-width: 460px; margin: 0 auto; width: 100%;
  padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: rise .25s ease both;
}
.toast.err { background: var(--danger); color: #fff; border-color: transparent; }
.toast.ok  { background: var(--ok); color: #04240f; border-color: transparent; }

/* --- Анимации ------------------------------------------------------------- */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop  { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
