/* Telegram mavzu ranglari (telegram-web-app.js o'rnatadi), brauzer uchun zaxira qiymatlar */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(127, 127, 127, 0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 12px 12px 8px;
}

.header__title { margin: 0 0 10px; font-size: 20px; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 0;
  border-radius: 16px;
  padding: 6px 14px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.chip--active { background: var(--accent); color: var(--accent-text); }

.status { margin: 32px 16px; text-align: center; color: var(--hint); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 4px 12px 16px;
}

.card {
  border: 0;
  padding: 0;
  text-align: left;
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  overflow: hidden;
  font: inherit;
}

.photo {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  background: var(--card);
  font-size: 40px;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card__body { padding: 8px 10px 10px; }
.card__title {
  margin: 0 0 4px;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__price { margin: 0; font-weight: 600; }
.card__size { margin: 2px 0 0; font-size: 13px; color: var(--hint); }

.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 16px;
}

.sheet__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 16px;
}

.sheet__title { margin: 12px 0 4px; font-size: 18px; }
.sheet__price { margin: 0 0 8px; font-size: 18px; font-weight: 700; }

.sheet__meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 16px;
}
.sheet__meta dt { color: var(--hint); }
.sheet__meta dd { margin: 0; }

.button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
}
.button:disabled { opacity: 0.6; }

.sheet__label { margin: 0 0 8px; color: var(--hint); font-size: 14px; }
.sizes { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.sizes .chip { border: 1px solid transparent; }
.sizes .chip small { color: var(--hint); margin-left: 4px; }
.sizes .chip--active small { color: inherit; opacity: 0.8; }

/* --- Faza 6: galereya, eski narx, savat --- */
[hidden] { display: none !important; }
.hint { margin: 0 0 12px; font-size: 13px; color: var(--hint); }

.card { position: relative; }
.sale-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  border-radius: 8px;
  padding: 2px 6px;
  background: #e53935;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.price-old { color: var(--hint); font-weight: 400; font-size: 0.85em; }

.gallery {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  border-radius: 12px;
  scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery .photo {
  flex: 0 0 100%;
  scroll-snap-align: center;
  aspect-ratio: 1 / 1;
  max-height: 55vh;
  font-size: 64px;
}
.gallery .photo img { object-fit: contain; background: var(--card); }
.gallery__dots { display: flex; justify-content: center; gap: 6px; min-height: 6px; margin-top: 8px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hint); opacity: 0.4; }
.dot--active { opacity: 1; background: var(--accent); }

.chip--soldout { opacity: 0.6; text-decoration: none; }

body.has-cart-bar main { padding-bottom: 72px; }
.cart-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 8;
  border: 0;
  border-radius: 12px;
  padding: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.cart-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.cart-line {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  padding: 8px;
  background: var(--card);
}
.cart-line .photo {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  font-size: 28px;
}
.cart-line__info { flex: 1; min-width: 0; }
.cart-line .qty { margin-top: 6px; }
.cart-line__title { margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line__price { margin: 2px 0 0; font-size: 13px; color: var(--hint); }
.cart-total { margin: 8px 0 12px; font-weight: 700; font-size: 17px; }
.qty { display: flex; align-items: center; gap: 4px; flex: none; }
.qty__btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.qty__btn--remove { color: #e53935; }
.qty__value { min-width: 20px; text-align: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 20;
  transform: translateX(-50%);
  border-radius: 10px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 14px;
}

/* --- Faza 8: brend, qidiruv, filtrlar --- */
.brand { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.brand__logo { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.brand__text { flex: 1; min-width: 0; }
.brand__name { margin: 0; font-size: 18px; line-height: 1.2; }
.brand__tagline { margin: 0; font-size: 13px; color: var(--hint); }

.search { display: flex; gap: 8px; }
.search__input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.search__input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.search__filter {
  position: relative;
  flex: none;
  width: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
}
.search__filter.is-active { background: var(--accent); color: var(--accent-text); }
.count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  background: #e53935;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}

.chips--wrap { flex-wrap: wrap; overflow: visible; margin: 0 0 14px; }
.toggle { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.filter-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.button--ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.button + .button { margin-top: 8px; }
.status__reset {
  display: block;
  margin: 10px auto 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
}

/* --- Video, jins/fasl tezkor filtrlari --- */
.chips--quick { margin-top: 10px; }
.chips--quick .chip { padding: 5px 12px; font-size: 13px; }

.video-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 8px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.gallery .photo--video { background: #000; }
.photo--video video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.dot--video { border-radius: 2px; }
.sheet__meta[hidden] { display: none; }

/* --- Burger menyu (katalog va admin panel) --- */
.menu-button {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
.menu-button.is-active { background: var(--accent); color: var(--accent-text); }
.menu-button .count-badge { top: -3px; right: -3px; }
body.no-scroll { overflow: hidden; }

.drawer { position: fixed; inset: 0; z-index: 15; }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); animation: fade-in 0.2s ease; }
.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(300px, 84vw);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 8px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
  animation: drawer-in 0.22s ease-out;
}
.drawer__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 4px 8px;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--border);
}
.drawer__head .brand__logo { width: 40px; height: 40px; }
.drawer__close {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--hint);
  font: inherit;
}
.drawer__label {
  margin: 14px 12px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hint);
}
.drawer__items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
}
.menu-item__icon { flex: none; width: 32px; font-size: 18px; text-align: center; }
.menu-item__thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  font-size: 17px;
}
.menu-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.menu-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item__count { flex: none; font-size: 13px; color: var(--hint); }
.menu-item--active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.menu-item--active .menu-item__count { color: inherit; opacity: 0.85; }
.menu-item--active .menu-item__thumb { background: rgba(255, 255, 255, 0.25); }
.menu-item:not(.menu-item--active):active { background: var(--card); }
.menu-item:focus { outline: none; }
.menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) {
  .menu-item:not(.menu-item--active):hover { background: var(--card); }
}
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .drawer__panel, .drawer__backdrop { animation: none; }
}

/* --- Rasmiylashtirish (Mini App ichida) --- */
.checkout { display: grid; gap: 12px; }
.checkout .sheet__title { margin: 2px 40px 0 0; }
.co-items {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--card);
  font-size: 14px;
}
.co-items li { display: flex; justify-content: space-between; gap: 10px; }
.co-items li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.co-items li span:last-child { flex: none; font-weight: 600; white-space: nowrap; }
.co-section {
  margin: 6px 0 -4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hint);
}
.form-field { display: grid; gap: 4px; min-width: 0; }
.form-field__label { font-size: 13px; color: var(--hint); }
.form-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-input.is-invalid { border-color: #e53935; }
textarea.form-input { resize: vertical; }
.form-input--code { text-transform: uppercase; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.form-input--code::placeholder { text-transform: none; font-family: inherit; }
.form-error { margin: -4px 0 0; font-size: 13px; color: #e53935; }
.co-codes { margin: 0; }
.co-promo { display: flex; gap: 8px; }
.co-promo .button { width: auto; flex: none; padding: 10px 16px; }
.co-promo-applied {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 4px 10px 12px;
  background: rgba(46, 160, 67, 0.14);
  font-size: 14px;
}
.co-promo-applied span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.co-promo-applied button { border: 0; background: transparent; color: var(--hint); font: inherit; padding: 2px 10px; }
.co-payment { display: grid; gap: 8px; }
.co-payment .co-section { margin-bottom: 0; }
.co-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.co-option:has(input:checked) { border-color: var(--accent); }
.co-option input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.co-totals {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  margin: 4px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.co-totals dt { color: var(--hint); overflow-wrap: anywhere; }
.co-totals dd { margin: 0; text-align: right; white-space: nowrap; }
.co-totals .co-discount { color: #2ea043; }
.co-totals .co-total { margin-top: 2px; color: var(--text); font-size: 17px; font-weight: 700; }
.co-note { margin: -4px 0 0; }
.hint--flat { margin: 0; }

.co-done { display: grid; gap: 12px; padding-top: 8px; }
.co-done__icon { font-size: 48px; line-height: 1; text-align: center; }
.co-done__title { margin: 0; font-size: 20px; text-align: center; }
.co-done__number { margin: -6px 0 0; color: var(--hint); text-align: center; }
.co-done__text { margin: 0; }
.co-card { display: grid; gap: 6px; border-radius: 12px; padding: 12px; background: var(--card); }
.co-card p { margin: 0; }
.co-card__title { font-weight: 600; }
.co-card__number {
  border: 1px dashed var(--accent);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg);
  color: var(--text);
  font: 600 18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
}
.co-card__line { font-size: 14px; }
