/* Тема приходит из Telegram (themeParams) — переменные ставит app.js,
   значения здесь — запасной тёмный вариант для открытия вне Telegram. */
:root {
  --bg: #17212b;
  --text: #f5f7fa;
  --hint: #8b98a5;
  --secondary-bg: #232e3c;
  --accent: #5288c1;
  --accent-text: #ffffff;
  --link: #6ab3f3;
  --danger: #e06c6c;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 12px calc(76px + env(safe-area-inset-bottom));
}

h1, h2, h3 { margin: 0 0 8px; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }
p { margin: 0 0 10px; }

a { color: var(--link); }

button {
  font: inherit;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }

button.ghost {
  background: var(--secondary-bg);
  color: var(--text);
}

button.danger-ghost {
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
}

input, textarea {
  font: inherit;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--hint);
  background: var(--secondary-bg);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--hint); }
textarea { resize: vertical; min-height: 70px; }

.page-message {
  text-align: center;
  color: var(--hint);
  padding: 48px 16px;
}

.muted { color: var(--hint); font-size: 14px; }
.error-text { color: var(--danger); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }

/* ── Шапка витрины ─────────────────────────────────────────────── */
.venue { margin-bottom: 12px; }
.venue .venue-meta { color: var(--hint); font-size: 14px; }

/* ── Вкладки категорий ─────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto;
  background: var(--secondary-bg);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
}
.tabs button.active {
  background: var(--accent);
  color: var(--accent-text);
}

/* ── Сетка позиций ─────────────────────────────────────────────── */
.items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.item-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: color-mix(in srgb, var(--secondary-bg) 60%, var(--bg));
}
.photo .photo-ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: var(--hint);
}
.photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.item-body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.item-name { font-weight: 600; font-size: 15px; }
.item-weight { color: var(--hint); font-size: 13px; }
.item-price { margin-top: auto; font-weight: 700; }

/* ── Карточка блюда ────────────────────────────────────────────── */
.dish { display: flex; flex-direction: column; gap: 14px; }
.dish .photo { border-radius: var(--radius); overflow: hidden; }
.dish-meta { color: var(--hint); font-size: 14px; }

.option-group {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 12px;
}
.option-group h3 { font-size: 15px; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.option label { flex: 1; }
.option .price { color: var(--hint); }

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--secondary-bg);
  border-radius: 999px;
  padding: 4px 10px;
}
.stepper button {
  border-radius: 999px;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.stepper .qty { min-width: 22px; text-align: center; font-weight: 600; }

.dish-footer {
  position: sticky;
  bottom: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Корзина ───────────────────────────────────────────────────── */
.cart-line {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.cart-line .mods { color: var(--hint); font-size: 13px; }
.cart-line .line-total { font-weight: 700; }
.cart-subtotal {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 700;
  margin: 14px 0;
}

/* ── Оформление ────────────────────────────────────────────────── */
.segmented {
  display: flex;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
  margin-bottom: 12px;
}
.segmented button {
  flex: 1;
  background: none;
  color: var(--text);
  padding: 10px;
}
.segmented button.active {
  background: var(--accent);
  color: var(--accent-text);
}

.field { margin-bottom: 10px; }
.field .muted { margin-bottom: 4px; display: block; }

.saved-address {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--secondary-bg);
  color: var(--text);
  margin-bottom: 8px;
}
.saved-address.active {
  outline: 2px solid var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips button {
  background: var(--secondary-bg);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
}
.chips button.active {
  background: var(--accent);
  color: var(--accent-text);
}

.quote-box {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 12px;
  margin: 10px 0;
}
.quote-box .total { font-weight: 700; }

.bonus-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.bonus-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.section { margin: 16px 0; }

.submit-bar {
  position: sticky;
  bottom: 12px;
  margin-top: 16px;
}
.submit-bar button { width: 100%; padding: 15px; font-size: 17px; }

/* ── Экран «заказ создан» ──────────────────────────────────────── */
.created { text-align: center; padding: 32px 8px; }
.created .big { font-size: 40px; }

/* ── Мои заказы ────────────────────────────────────────────────── */
.order-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.order-card summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}
.order-card summary::-webkit-details-marker { display: none; }
.order-card .order-items {
  margin-top: 10px;
  border-top: 1px solid var(--hint);
  padding-top: 10px;
  color: var(--hint);
  font-size: 14px;
}
.order-line { display: flex; justify-content: space-between; padding: 2px 0; }

/* ── Нижняя навигация ──────────────────────────────────────────── */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--secondary-bg);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
.nav button {
  background: none;
  color: var(--hint);
  padding: 6px 18px;
  font-size: 13px;
  position: relative;
}
.nav button.active { color: var(--text); }
.nav .badge {
  position: absolute;
  top: 0;
  right: 6px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 4px;
}

/* ── Бонусы ────────────────────────────────────────────────────── */
.loyalty-balance {
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  padding: 24px 0 12px;
}
.loyalty-balance span {
  display: block;
  font-size: 14px;
  font-weight: 400;
  color: var(--hint);
  margin-top: 4px;
}
.loyalty-history-title { margin-top: 20px; }
.loyalty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.loyalty-sum { font-weight: 700; }
.loyalty-sum.plus { color: #7fc97f; }
.loyalty-sum.minus { color: var(--danger); }

/* ── Тост ──────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  max-width: 88%;
  text-align: center;
  z-index: 10;
}
