/*
  Палитра и типографика:
  - Фон/текст берём из переменных темы Telegram (--tg-theme-*), которые
    JS проставляет из window.Telegram.WebApp.themeParams — так приложение
    всегда совпадает с текущей темой пользователя (светлая/тёмная), как и
    положено нативному Mini App, а не выглядит вставленным сайтом.
  - Акцентный цвет — насыщенный янтарный/шафрановый (#C98A2C), а не
    типовой терракотовый — ассоциация со специями и подачей блюд, не клише.
  - Заголовки — Fraunces (тёплая контрастная антиква), текст — Manrope.
*/

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --separator: color-mix(in srgb, var(--hint) 25%, transparent);
  --accent: #c98a2c;
  --accent-ink: #4a2e05;
  --danger: #d64545;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 100px;
}

h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--hint);
  font-size: 14px;
  margin: 0;
}

.view { padding: 20px 16px 8px; }
.view.hidden { display: none; }

.topbar { margin-bottom: 20px; }
.topbar.with-back { display: flex; align-items: flex-start; gap: 12px; }

.back-btn {
  border: none;
  background: var(--secondary-bg);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.back-btn:active { opacity: 0.6; }

/* ---------- Restaurant list ---------- */

.restaurant-list { display: flex; flex-direction: column; gap: 12px; }

.restaurant-card {
  background: var(--secondary-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  border: none;
  color: var(--text);
  width: 100%;
  cursor: pointer;
}
.restaurant-card:active { opacity: 0.85; }

.restaurant-photo {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  margin: -16px -16px 8px; /* растягиваем на всю карточку сверху */
  background: var(--separator);
}

.restaurant-card .name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 19px;
  font-weight: 600;
}

.restaurant-card .meta {
  color: var(--hint);
  font-size: 13px;
  display: flex;
  gap: 10px;
}

.skeleton-card {
  height: 84px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--secondary-bg) 25%, color-mix(in srgb, var(--secondary-bg) 60%, var(--hint) 10%) 50%, var(--secondary-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  text-align: center;
  color: var(--hint);
  padding: 40px 20px;
}

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

.menu-categories { display: flex; flex-direction: column; gap: 24px; }

.category-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--separator);
}
.menu-item:last-child { border-bottom: none; }

/* Карточка блюда с фото: чуть больше воздуха и фон, как «плитка» */
.menu-item.with-photo {
  background: var(--secondary-bg);
  border-radius: var(--radius-md);
  border-bottom: none;
  padding: 12px;
  margin-bottom: 10px;
}
.menu-item .item-photo {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--separator);
}

.hours-notice {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.menu-item .info { flex: 1; min-width: 0; }
.menu-item .item-name { font-weight: 700; font-size: 15px; }
.menu-item .item-desc {
  color: var(--hint);
  font-size: 13px;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.menu-item .item-price { font-size: 14px; margin-top: 6px; font-weight: 600; }
.menu-item.unavailable { opacity: 0.45; }
.menu-item.unavailable .item-price::after { content: ' · нет в наличии'; font-weight: 400; color: var(--danger); }

.qty-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-btn:active { transform: scale(0.92); }
.qty-btn:disabled { background: var(--hint); }

.qty-value { min-width: 18px; text-align: center; font-weight: 700; }

.add-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.add-btn:active { opacity: 0.85; }
.add-btn:disabled { background: var(--hint); }

/* ---------- Checkout ---------- */

.checkout-form { display: flex; flex-direction: column; gap: 16px; }

.cart-summary {
  background: var(--secondary-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.cart-summary .row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.cart-summary .row.total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--separator); margin-top: 6px; padding-top: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--hint); }
.field input, .field textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--secondary-bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  resize: none;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); }

.error-text { color: var(--danger); font-size: 13px; margin: 0; }
.error-text.hidden { display: none; }

.free-delivery-hint { color: var(--accent); font-size: 13px; margin: 6px 0 0; font-weight: 600; }

/* ---------- Отзывы ---------- */

.reviews-section { margin-top: 28px; }
.review-card {
  background: var(--secondary-bg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.review-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.review-stars { color: var(--accent); letter-spacing: 2px; }
.review-name { font-weight: 700; }
.review-date { color: var(--hint); margin-left: auto; font-size: 12px; }
.review-text { font-size: 13px; margin-top: 6px; line-height: 1.45; }

.review-form {
  background: var(--secondary-bg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.star-row { display: flex; gap: 4px; }
.star-btn {
  border: none;
  background: none;
  font-size: 28px;
  color: var(--separator);
  padding: 0 4px;
  cursor: pointer;
}
.star-btn.active { color: var(--accent); }
.review-form textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px;
  resize: none;
}
.review-btn { margin-top: 8px; }

/* Подтверждение телефона */
.phone-ok {
  background: color-mix(in srgb, #34c759 12%, transparent);
  border: 1px solid color-mix(in srgb, #34c759 35%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
}
.phone-ask {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.muted-text { color: var(--hint); font-size: 13px; margin: 0; line-height: 1.45; }
.share-phone-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}

/* Способы оплаты */
.payment-options { display: flex; flex-direction: column; gap: 8px; }
.pay-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--secondary-bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.pay-option:has(input:checked) { outline: 2px solid var(--accent); }

/* Согласие на обработку ПД */
.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--hint);
  line-height: 1.45;
}
.consent input { margin-top: 2px; flex-shrink: 0; }
.consent a { color: var(--accent); }

.app-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 11px;
  color: var(--hint);
  line-height: 1.6;
}
.app-footer a { color: var(--accent); }

#my-orders-btn { width: 100%; margin-top: 16px; }

/* ---------- Мои заказы ---------- */

.orders-list { display: flex; flex-direction: column; gap: 12px; }

.order-card {
  background: var(--secondary-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.order-card.cancelled { opacity: 0.6; }
.order-head { display: flex; justify-content: space-between; align-items: center; }
.order-num { font-weight: 700; font-size: 15px; }
.order-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  padding: 3px 10px;
  border-radius: 999px;
}
.order-card.cancelled .order-status { background: color-mix(in srgb, var(--danger) 15%, transparent); }
.order-items { font-size: 13px; color: var(--text); }
.order-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--hint); }

/* ---------- Success ---------- */

.success-screen {
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.btn-secondary {
  margin-top: 20px;
  border: none;
  background: var(--secondary-bg);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

/* ---------- Cart bar (fixed) ---------- */

.cart-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.cart-bar.hidden { display: none; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
}
.toast.hidden { display: none; }
