/**
 * Wx1 Каталог Товаров — основные стили фронтенда.
 *
 * Структура:
 *  1. Переменные
 *  2. Каталог (шорткод) — сортировка и сетка
 *  3. Карточка товара
 *  4. Страница одиночного товара
 *  5. Лайтбокс
 *  6. Адаптивность
 */

/* ==========================================================================
   1. Переменные
   ========================================================================== */
:root {
  --wx1-primary:       #1a86c7;
  --wx1-primary-hover: #20a5f5;
  --wx1-accent:        #1a86c7;
  --wx1-text:          #222;
  --wx1-text-light:    #666;
  --wx1-border:        #dde1e6;
  --wx1-bg-card:       #fff;
  --wx1-bg-hover:      #f4f7f4;
  --wx1-radius:        8px;
  --wx1-shadow:        0 2px 10px rgba(0,0,0,.08);
  --wx1-shadow-hover:  0 6px 20px rgba(0,0,0,.13);
  --wx1-font:          inherit;
}
/* ==========================================================================
   2. Каталог — сортировка и сетка
   ========================================================================== */
.wx1-catalog {
  font-family: var(--wx1-font);
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 16px;
}

.wx1-catalog__sort {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--wx1-text-light);
}

.wx1-sort-btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--wx1-border);
  border-radius: 4px;
  color: var(--wx1-text);
  text-decoration: none;
  background: #fff;
  transition: background .15s, border-color .15s;
  font-size: 13px;
  white-space: nowrap;
}

.wx1-sort-btn:hover {
  background: var(--wx1-bg-hover);
  border-color: var(--wx1-primary);
  color: var(--wx1-primary);
}

.wx1-sort-btn.wx1-sort--active {
  background: var(--wx1-primary);
  border-color: var(--wx1-primary);
  color: #fff;
  font-weight: 600;
}

.wx1-catalog__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

/* --- Состояние загрузки (AJAX-запрос активен) --- */
.wx1-catalog--loading .wx1-catalog__grid {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* Сообщение об ошибке внутри сетки */
.wx1-catalog__error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  font-size: 15px;
  color: var(--wx1-text-light);
}

/* ==========================================================================
   3. Карточка товара
   ========================================================================== */
.wx1-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--wx1-border);
  border-radius: var(--wx1-radius);
  overflow: hidden;
  background: var(--wx1-bg-card);
  box-shadow: var(--wx1-shadow);
  text-decoration: none;
  color: var(--wx1-text);
  transition: box-shadow .2s, transform .2s;
  cursor: pointer;
}

.wx1-card:hover {
  box-shadow: var(--wx1-shadow-hover);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--wx1-text);
}

/* Обёртка изображений */
.wx1-card__img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #f0f0f0;
}

.wx1-card__photo,
.wx1-card__layout {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity .3s;
}

/* По умолчанию показываем фото, скрываем планировку */
.wx1-card__photo { opacity: 1; z-index: 1; }
.wx1-card__layout { opacity: 0; z-index: 2; object-fit: contain;}

/* При наведении — показываем планировку */
.wx1-card:hover .wx1-card__layout { opacity: 1; }
.wx1-card:hover .wx1-card__photo { opacity: 0; }

.wx1-card__no-photo {
  position: absolute;
  inset: 0;
  background: #e8ecf0;
}

/* Контент карточки */
.wx1-card__info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.wx1-card__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.wx1-card__params {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.wx1-card__price {
  font-size: 18px;
  color: var(--wx1-primary);
  font-weight: 700;
}

.wx1-card__area span,
.wx1-card__size span {
  color: var(--wx1-text-light);
  margin-right: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Карточка «Не нашли, что искали?» */
.wx1-card--notfound {
  justify-content: center;
  align-items: center;
  border-style: dashed;
  border-color: var(--wx1-border);
  background: #fafafa;
  min-height: 220px;
  cursor: default;
}

.wx1-card--notfound:hover {
  transform: none;
  box-shadow: var(--wx1-shadow);
}

.wx1-card__notfound-inner {
  text-align: center;
  padding: 32px 24px;
}

.wx1-card__notfound-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}

.wx1-card__notfound-desc {
  font-size: 14px;
  color: var(--wx1-text-light);
  margin: 0 0 20px;
}

/* ==========================================================================
   4. Кнопки
   ========================================================================== */
.wx1-btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1.4;
  text-align: center;
}

.wx1-btn--primary {
  background: var(--wx1-primary);
  color: #fff;
  border: 2px solid var(--wx1-primary);
}

.wx1-btn--primary:hover {
  background: var(--wx1-primary-hover);
  border-color: var(--wx1-primary-hover);
  color: #fff;
}

.wx1-btn--secondary {
  background: transparent;
  color: var(--wx1-primary);
  border: 2px solid var(--wx1-primary);
}

.wx1-btn--secondary:hover {
  background: var(--wx1-primary);
  color: #fff;
}

.wx1-btn--outline {
  background: transparent;
  color: var(--wx1-primary);
  border: 2px solid var(--wx1-primary);
}

.wx1-btn--outline:hover {
  background: var(--wx1-primary);
  color: #fff;
}

/* ==========================================================================
   5. Страница одиночного товара
   ========================================================================== */
.wx1-single-product {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  font-family: var(--wx1-font);
  color: var(--wx1-text);
}

/* --- Хлебные крошки --- */
.wx1-breadcrumbs {
  font-size: 13px;
  color: var(--wx1-text-light);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.wx1-breadcrumbs a {
  color: var(--wx1-text-light);
  text-decoration: none;
}

.wx1-breadcrumbs a:hover {
  color: var(--wx1-primary);
  text-decoration: underline;
}

.wx1-breadcrumbs__sep {
  color: var(--wx1-border);
}

/* --- Ссылка «Вернуться» --- */
.wx1-back-link {
  margin-bottom: 20px;
}

.wx1-back-link__a {
  font-size: 14px;
  color: var(--wx1-primary);
  text-decoration: none;
}

.wx1-back-link__a:hover {
  text-decoration: underline;
}

/* --- Шапка товара --- */
.wx1-product-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 24px;
  margin-bottom: 40px;
  align-items: start;
}

.wx1-product-header__meta {
  grid-column: 1;
  grid-row: 1;
}

.wx1-product-images {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wx1-product-actions {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.wx1-product-sku {
  font-size: 13px;
  color: var(--wx1-text-light);
  margin-bottom: 6px;
}

.wx1-product-sku span {
  font-weight: 600;
  color: var(--wx1-text);
}

.wx1-product-title {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 16px;
}

.wx1-product-price {
  margin-bottom: 24px;
}

.wx1-product-price__label {
  font-size: 14px;
  color: var(--wx1-text-light);
  display: block;
  margin-bottom: 2px;
}

.wx1-product-price__value {
  font-size: 28px;
  font-weight: 700;
  color: var(--wx1-primary);
}

/* --- Изображения товара --- */
.wx1-product-images__main,
.wx1-product-images__layout {
  width: 100%;
  height: auto;
  border-radius: var(--wx1-radius);
  display: block;
  object-fit: cover;
}

.wx1-product-images__main {
  max-height: 420px;
  object-position: center;
}

.wx1-product-images__layout {
  max-height: 200px;
}

/* Ссылка лайтбокса */
.wx1-lightbox {
  position: relative;
  display: block;
  cursor: zoom-in;
  border-radius: var(--wx1-radius);
  overflow: hidden;
}

.wx1-lightbox__icon {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(255,255,255,.75);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0;
  transition: opacity .2s;
}

.wx1-lightbox:hover .wx1-lightbox__icon {
  opacity: 1;
}

/* --- Параметры товара --- */
.wx1-product-params {
  margin-bottom: 32px;
}

.wx1-product-params__title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 12px;
}

.wx1-product-params__table {
  border-collapse: collapse;
  width: 100%;
  max-width: 560px;
  font-size: 15px;
}

.wx1-product-params__table th,
.wx1-product-params__table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--wx1-border);
}

.wx1-product-params__table th {
  color: var(--wx1-text-light);
  font-weight: 500;
  width: 180px;
  background: #f8f9fa;
}

/* --- Описание товара --- */
.wx1-product-description {
  margin-bottom: 40px;
  max-width: 780px;
}

.wx1-product-description__title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 12px;
}

.wx1-product-description__body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--wx1-text);
}

/* --- Другие товары категории --- */
.wx1-related-products {
  margin-top: 40px;
}

.wx1-related-products__title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 20px;
}

/* ==========================================================================
   6. Лайтбокс
   ========================================================================== */
.wx1-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .75);
  z-index: 9998;
  cursor: pointer;
}

.wx1-lightbox-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  background: transparent;
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
}

.wx1-lightbox-modal__img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--wx1-radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
  display: block;
}

.wx1-lightbox-modal__close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,.9);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 10000;
  transition: background .15s;
}

.wx1-lightbox-modal__close:hover {
  background: #fff;
}

/* ==========================================================================
   7. Адаптивность
   ========================================================================== */
@media (max-width: 768px) {
  .wx1-catalog__grid {
    grid-template-columns: 1fr;
  }

  .wx1-product-header {
    grid-template-columns: 1fr;
  }

  .wx1-product-images {
    grid-column: 1;
    grid-row: 2;
  }

  .wx1-product-header__meta {
    grid-row: 1;
  }

  .wx1-product-actions {
    grid-row: 3;
  }

  .wx1-product-title {
    font-size: 22px;
  }

  .wx1-product-price__value {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .wx1-single-product {
    padding: 16px 12px 32px;
  }

  .wx1-product-params__table th {
    width: 120px;
  }

  .wx1-btn {
    width: 100%;
  }
}
