/* ── Telegram theme variables ── */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #222222);
  --hint: var(--tg-theme-hint-color, #888888);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --accent: #e07b3a;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 100px; /* room for FAB and Telegram MainButton */
}

/* ── Header ── */
.app-header {
  background: var(--btn);
  color: var(--btn-text);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 2rem; }
.shop-name { font-size: 1.1rem; font-weight: 700; }
.shop-sub { font-size: 0.75rem; opacity: 0.8; }
.member-badge {
  background: #ffd700;
  color: #333;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 20px;
}

/* ── Views ── */
.view { padding: 0 0 80px; }
.view.hidden { display: none; }
.view.active { display: block; }

/* ── Loading ── */
#view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--hint);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--secondary-bg);
  border-top-color: var(--btn);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Discount banner ── */
.discount-banner {
  background: linear-gradient(135deg, #ff6b35, #e07b3a);
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── Menu grid ── */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 12px;
}

.menu-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s;
}
.menu-card:active { transform: scale(0.97); }

.menu-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #ddd;
}
.menu-card-img-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, #f5e6d3, #e8c99a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.menu-card-body {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.menu-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
}
.menu-card-price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.qty-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.qty-btn:disabled { opacity: 0.3; }
.qty-num {
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* ── Cart FAB ── */
.cart-fab {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  z-index: 200;
}
.cart-fab button {
  width: 100%;
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.fab-badge {
  background: #ff4444;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

/* ── Cart view ── */
.back-btn {
  background: none;
  border: none;
  color: var(--link);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 14px 16px;
  display: block;
}
.section-title {
  padding: 0 16px 12px;
  font-size: 1.1rem;
  font-weight: 700;
}

.cart-list { padding: 0 12px; display: flex; flex-direction: column; gap: 10px; }

.cart-item {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 0.88rem; font-weight: 600; }
.cart-item-price { font-size: 0.8rem; color: var(--hint); margin-top: 2px; }
.cart-item-controls { display: flex; align-items: center; gap: 8px; }

.cart-summary {
  margin: 16px 12px 0;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.9rem;
}
.discount-row { color: #27ae60; font-weight: 600; }
.total-row { font-size: 1rem; font-weight: 700; border-top: 1px solid rgba(0,0,0,0.08); padding-top: 10px; margin-top: 4px; }
.strikethrough { text-decoration: line-through; color: var(--hint); }

/* ── Success view ── */
#view-success {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}
.success-card {
  text-align: center;
  padding: 32px 24px;
}
.success-icon { font-size: 4rem; margin-bottom: 16px; }
.success-card h2 { font-size: 1.4rem; margin-bottom: 8px; }
.success-card p { color: var(--hint); font-size: 0.9rem; margin-bottom: 24px; }

/* ── Buttons ── */
.primary-btn {
  width: 100%;
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
}
.primary-btn:disabled { opacity: 0.5; }

/* ── Utility ── */
.hidden { display: none !important; }
