/* ─── ПЕРЕМЕННЫЕ ТЕМ ─────────────────────────────────────────────────────── */
:root {
  --bg:         #121212;
  --bg-card:    #1E1E1E;
  --text:       #F0F0F0;
  --text-sub:   #AAAAAA;
  --accent:     #1D9E75;
  --accent-pressed: #5DCAA5;
  --border:     #2E2E2E;
  --header-bg:  #1A1A1A;
  --input-bg:   #2A2A2A;
  --shadow:     0 4px 14px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-active: 0 2px 6px rgba(0,0,0,0.2);
  --radius:     12px;
  --transition: transform 0.18s ease, box-shadow 0.18s ease;
}

[data-theme="light"] {
  --bg:         #F5F5F5;
  --bg-card:    #FFFFFF;
  --text:       #111111;
  --text-sub:   #666666;
  --accent:     #1D9E75;
  --accent-pressed: #177A5A;
  --border:     #E0E0E0;
  --header-bg:  #FFFFFF;
  --input-bg:   #F0F0F0;
  --shadow:     0 4px 14px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.1);
  --shadow-active: 0 2px 6px rgba(0,0,0,0.08);
}

/* ─── СБРОС И БАЗА ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }

/* ─── ШАПКА ─────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header__logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.header__cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.header__cats::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  transition: var(--transition);
  white-space: nowrap;
}
.cat-btn:hover  { background: var(--accent); color: #fff; border-color: var(--accent); }
.cat-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.header__controls {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--input-bg); transform: scale(1.1); }

/* ─── ГЛАВНЫЙ КОНТЕНТ ───────────────────────────────────────────────────── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

.badge-hot {
  background: #E53935;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.5px;
}

/* ─── СЕТКА ТОВАРОВ ─────────────────────────────────────────────────────── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* ─── КАРТОЧКА ТОВАРА ───────────────────────────────────────────────────── */
.product-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
}

.product-card:hover  { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.product-card:active { transform: translateY(1px);  box-shadow: var(--shadow-active); }

.product-card__img {
  width: 100%;
  aspect-ratio: 4/5;
  object-fit: contain;
  padding: 8px;
  background: var(--input-bg);
}

.product-card__img-placeholder {
  width: 100%;
  aspect-ratio: 4/5;
  background: var(--input-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--text-sub);
}

.product-card__body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-card__name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.product-card__price {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  margin-top: auto;
}

.product-card__buy {
  margin: 0 12px 12px;
  padding: 10px;
  border-radius: 8px;
  border: none;
  border-bottom: 3px solid rgba(0,0,0,0.25);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  transition: var(--transition);
}
.product-card__buy:hover  { background: var(--accent-pressed); transform: translateY(-2px); }
.product-card__buy:active { transform: translateY(1px); box-shadow: var(--shadow-active); }

.badge-hot-card {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #E53935;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ─── БАННЕР ────────────────────────────────────────────────────────────── */
.banner-section {
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.banner-slider {
  position: relative;
  width: 100%;
}

.banner-slide {
  display: none;
  position: relative;
}
.banner-slide.active { display: block; }

.banner-slide img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  padding: 8px;
}

.banner-slide__text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff;
}

.banner-slide__title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.banner-slide__sub {
  font-size: 16px;
  opacity: 0.85;
}

.banner-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  border: none;
  transition: background 0.3s;
  padding: 0;
}
.banner-dot.active { background: #fff; }

/* ─── МОДАЛЬНЫЕ ОКНА ────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 24px;
}

.modal--chat {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-sub);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal__close:hover { background: var(--input-bg); }

.modal__img {
  width: 100%;
  aspect-ratio: 4/5;
  object-fit: contain;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.modal__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal__desc {
  color: var(--text-sub);
  line-height: 1.6;
  margin-bottom: 16px;
}

.modal__price {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 20px;
}

/* ─── ФОРМА ─────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 600;
}

.input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--accent); }

.form-error {
  color: #E53935;
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

/* ─── КНОПКИ ────────────────────────────────────────────────────────────── */
.btn {
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  border-bottom: 3px solid rgba(0,0,0,0.2);
  font-size: 15px;
  font-weight: 700;
  transition: var(--transition);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover  { background: var(--accent-pressed); transform: translateY(-2px); box-shadow: var(--shadow); }
.btn--primary:active { transform: translateY(1px); box-shadow: var(--shadow-active); }

.btn--full { width: 100%; }

/* ─── ЧАТ ───────────────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
  min-height: 200px;
  max-height: 400px;
}

.chat-msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-msg--buyer {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg--admin {
  align-self: flex-start;
  background: var(--input-bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-msg__time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.chat-input-row .input { flex: 1; }

/* ─── АДАПТИВ ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .banner-slide img { height: 140px; }
  .banner-slide__title { font-size: 20px; }
  .header__inner { height: 54px; }
}

@media (max-width: 480px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .main { padding: 16px 12px; gap: 28px; }
}
/* ─── КАТЕГОРИИ ПОД БАННЕРОМ ─────────────────────────────────────────────── */
.cats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 0;
  justify-content: center;
}

.cats-bar .cat-btn {
  flex: 1;
  min-width: 120px;
  max-width: 160px;
  text-align: center;
  padding: 10px 16px;
}

/* ─── МОБИЛЬНОЕ МЕНЮ ─────────────────────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--header-bg);
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 16px;
}

.mobile-nav__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 11px;
  padding: 6px 16px;
  border-radius: 8px;
  transition: color 0.15s;
}
.mobile-nav__btn:hover { color: var(--accent); }
.mobile-nav__btn.active { color: var(--accent); }

@media (max-width: 768px) {
  .mobile-nav { display: flex; }
  .main { padding-bottom: 72px; }
}

.banner-slide.active { display: block; }
a.banner-slide { display: none; text-decoration: none; }
a.banner-slide.active { display: block; }

.banner-slide { display: none !important; }
.banner-slide.active { display: block !important; }

.banner-slide__text { pointer-events: none; }
a.banner-slide.active { display: block; position: relative; z-index: 1; }
a.banner-slide img { display: block; }

.banner-section a { 
  display: block; 
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  touch-action: manipulation;
}

.banner-section a {
  position: relative;
  z-index: 10;
}
.banner-slide__text {
  z-index: 1;
  pointer-events: none;
}

/* ─── МОБИЛЬНЫЕ ФИКСЫ ───────────────────────────────────────────────────── */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  position: relative;
}
.search-bar {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.search-bar input {
  width: 100% !important;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .mobile-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }
}

/* ─── iOS SAFE AREA ─────────────────────────────────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: env(safe-area-inset-top);
  }
  .mobile-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-nav {
    height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}
