/* ==========================================
   STORE.CSS — Карточка товара и Магазин
   Полный адаптив для ПК, Планшетов и Телефонов
   ========================================== */

/* ====== КАРТОЧКА ТОВАРА (PRODUCT.HTML) ====== */
.product-page {
  padding: 20px 0 60px;
  width: 100%;
  overflow-x: hidden; /* Защита от вылезания элементов */
}

.product-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px; /* minmax(0, 1fr) позволяет левой колонке сжиматься */
  gap: 30px;
  background: var(--bg-white);
  border-radius: var(--radius-md);
  padding: 30px;
  box-shadow: var(--shadow-sm);
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

/* ====== ГАЛЕРЕЯ ====== */
.product-gallery {
  display: flex;
  gap: 16px;
  align-items: start;
  width: 100%;
  min-width: 0; /* Важно для предотвращения распора грида */
  box-sizing: border-box;
}

/* Миниатюры на ПК (слева) */
.product-gallery__thumbnails {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 76px;
  flex-shrink: 0;
  max-height: 500px;
  overflow-y: auto;
  scrollbar-width: none;
}

.product-gallery__thumbnails::-webkit-scrollbar {
  display: none;
}

.product-gallery__thumb {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid var(--border);
  object-fit: contain;
  background: var(--bg-gray);
  transition: var(--transition-fast);
  padding: 2px;
  box-sizing: border-box;
}

.product-gallery__thumb.active,
.product-gallery__thumb:hover {
  border-color: var(--primary);
}

/* Главный блок фото/видео */
.product-gallery__main {
  flex: 1;
  width: 100%;
  min-width: 0;
  max-height: 500px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #f8f9fa;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  box-sizing: border-box;
}

.product-gallery__main img,
.product-gallery__main video {
  width: 100%;
  height: 100%;
  object-fit: contain !important; /* Фото видно целиком */
  padding: 8px;
  box-sizing: border-box;
}

/* ====== ИНФОРМАЦИЯ О ТОВАРЕ ====== */
.product-info {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0; /* Разрешает правильное сжатие */
  box-sizing: border-box;
}

.product-info__title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 12px;
  word-break: break-word;
}

.product-info__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.product-info__rating {
  color: var(--warning);
  letter-spacing: 1px;
}

/* Блок цены */
.product-price-block {
  background: var(--bg-gray);
  padding: 18px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.product-price-block .current {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-primary);
}

.product-price-block .old {
  font-size: 15px;
  color: var(--text-light);
  text-decoration: line-through;
}

.product-price-block .discount {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* Кнопки действия */
.product-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  width: 100%;
  box-sizing: border-box;
}

.product-actions .btn-add-cart {
  flex: 1;
  padding: 16px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.product-actions .btn-add-cart:hover {
  background: var(--primary-dark);
}

.product-actions .btn-fav {
  width: 54px;
  height: 54px;
  min-width: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 20px;
  color: var(--text-muted);
  background: #fff;
  cursor: pointer;
  transition: var(--transition);
  box-sizing: border-box;
}

.product-actions .btn-fav:hover,
.product-actions .btn-fav.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* Карточка магазина */
.product-shop-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}

.product-shop-card img,
.product-shop-card > div:first-child {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.product-shop-card__info {
  flex: 1;
  min-width: 0;
}

.product-shop-card__name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.product-shop-card__stats {
  font-size: 12px;
  color: var(--text-muted);
}

/* Характеристики */
.product-features {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
}

.product-features li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-light);
  font-size: 14px;
  gap: 12px;
}

.product-features li span:first-child {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.product-features li span:last-child {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

/* ====== ВИТРИНА МАГАЗИНА (SHOP.HTML) ====== */
.shop-hero {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 30px;
}

.shop-hero__cover {
  height: 200px;
  background: linear-gradient(135deg, var(--secondary), #34495e);
}

.shop-hero__info {
  padding: 0 40px 40px;
  display: flex;
  align-items: flex-end;
  gap: 24px;
  margin-top: -50px;
  position: relative;
  z-index: 2;
}

.shop-hero__avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: #fff;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.shop-hero__details {
  flex: 1;
  padding-bottom: 10px;
}

.shop-hero__title {
  font-size: 28px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.shop-hero__stats {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.shop-hero__actions {
  padding-bottom: 10px;
  display: flex;
  gap: 12px;
}

/* ==========================================
   ПОЛНОЭКРАННЫЙ ЗУМ ФОТО (LIGHTBOX)
   ========================================== */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  z-index: 99999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: lightboxFade 0.2s ease;
  user-select: none;
}

.lightbox-modal.active {
  display: flex;
}

@keyframes lightboxFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: #fff;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 100001;
}

.lightbox-close:hover {
  background: var(--primary);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 22px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100001;
}

.lightbox-nav.prev { left: 20px; }
.lightbox-nav.next { right: 20px; }

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 82vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-img {
  max-width: 85vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-in;
  transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
}

.lightbox-img.zoomed {
  cursor: zoom-out;
  transform: scale(2.2);
}

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
  font-weight: 600;
}

.lightbox-hint {
  position: absolute;
  top: 24px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}

/* ==========================================
   АДАПТИВ (ПЛАНШЕТЫ И ТЕЛЕФОНЫ) — ЖЕСТКИЙ ФИКС
   ========================================== */
@media (max-width: 900px) {
  .product-layout {
    grid-template-columns: 1fr !important; /* Переводим в 1 колонку */
    padding: 16px 12px !important;
    gap: 20px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Галерея: главное фото сверху, превью снизу */
  .product-gallery {
    flex-direction: column-reverse !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Миниатюры становятся строкой СТРОГО в пределах экрана */
  .product-gallery__thumbnails {
    flex-direction: row !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 4px;
    box-sizing: border-box !important;
  }

  .product-gallery__thumb {
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
    flex-shrink: 0 !important;
  }

  .product-gallery__main {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 380px !important;
  }

  .shop-hero__info { 
    flex-direction: column; 
    align-items: center; 
    text-align: center; 
    margin-top: -70px; 
    padding: 0 20px 20px;
  }
  
  .shop-hero__actions { width: 100%; }
  .shop-hero__actions button { flex: 1; }
}

@media (max-width: 640px) {
  .product-page {
    padding: 10px 0 40px;
  }

  .product-info__title { 
    font-size: 20px !important; 
    line-height: 1.3 !important;
  }

  .product-info__meta { 
    flex-direction: column; 
    align-items: flex-start; 
    gap: 4px; 
    font-size: 12px;
  }
  
  /* Фикс вылезания плашки «Выгода» и цены */
  .product-price-block { 
    padding: 14px !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
  }

  .product-price-block .current { 
    font-size: 24px !important; 
  }

  .product-price-block .old { 
    font-size: 13px !important; 
  }

  .product-price-block .discount {
    font-size: 11px !important;
    padding: 3px 8px !important;
  }

  .product-actions {
    gap: 8px;
  }

  .product-actions .btn-add-cart { 
    padding: 12px 8px !important; 
    font-size: 14px !important; 
  }

  .product-actions .btn-fav { 
    width: 46px !important; 
    height: 46px !important; 
    min-width: 46px !important; 
    font-size: 18px !important; 
  }

  .product-shop-card { 
    flex-wrap: wrap; 
    padding: 12px !important; 
    gap: 10px !important; 
  }

  .btn-contact-seller { 
    width: 100% !important; 
    justify-content: center !important; 
    padding: 10px !important; 
    order: 3; 
  }

  .product-features li {
    font-size: 13px;
    padding: 8px 0;
  }

  .lightbox-nav.prev { left: 8px; width: 40px; height: 40px; font-size: 18px; }
  .lightbox-nav.next { right: 8px; width: 40px; height: 40px; font-size: 18px; }
  .lightbox-close { top: 12px; right: 12px; width: 38px; height: 38px; font-size: 20px; }
}

/* ==========================================
   СВЁРТЫВАНИЕ ОПИСАНИЯ
   ========================================== */
.product-desc-container {
  position: relative;
  overflow: hidden;
  /* Высота в свернутом виде (~5 строк) */
  max-height: 120px; 
  transition: max-height 0.4s ease;
}

.product-desc-container.expanded {
  /* Большая высота для развернутого вида */
  max-height: 2000px;
}

.product-desc-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.product-desc-container.expanded .product-desc-fade {
  opacity: 0;
}

.product-desc-toggle {
  display: inline-block;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.product-desc-toggle:hover {
  text-decoration: underline;
}

/* ==========================================
   ПОХОЖИЕ ТОВАРЫ (РЕКОМЕНДАЦИИ)
   ========================================== */
.similar-section {
  margin-top: 50px;
  padding-top: 40px;
  border-top: 1px solid var(--border-light);
}

.similar-header {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 24px;
}

.similar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .similar-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .similar-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* Кнопки коллекций в магазине */
.chip-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.chip-btn:hover {
  border-color: var(--primary);
}

.chip-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Скрываем скроллбар для контейнера с коллекциями на мобильных */
#shopCollectionsNav::-webkit-scrollbar {
  display: none;
}
#shopCollectionsNav {
  -ms-overflow-style: none;
  scrollbar-width: none;
}