/* ============================================
   product-cards.css (Production Ready)
   Карточки товаров и макет каталога
   ============================================ */

/* ============================================
   1. Основной макет
   ============================================ */
.catalog-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  width: 100%;
}

.catalog-sidebar {
  flex: 0 0 280px;
  position: sticky;
  top: 80px;
  align-self: flex-start;
  min-width: 0; 
  max-height: calc(100vh - 120px); /* 🔥 Критически важно: ограничиваем высоту */
  display: flex;           /* 🔥 ДОБАВЛЕНО */
  flex-direction: column;  /* 🔥 ДОБАВЛЕНО */        
}

.catalog-main {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.catalog-main--full {
  flex: 1;
  width: 100%;
  max-width: 100%;
}

/* ============================================
   2. Сетка товаров
   ============================================ */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  width: 100%;
}

/* ============================================
   3. Карточка товара (Базовая)
   ============================================ */
.product-card {
  background: var(--bg-white, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius, 8px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color var(--transition, 0.2s ease), 
              box-shadow var(--transition, 0.2s ease), 
              transform var(--transition, 0.2s ease);
}

.product-card:hover {
  border-color: var(--primary-light, #93c5fd);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  transform: translateY(-4px);
}

/* Базовые стили для тега <mark> внутри карточки */
.product-card__title mark,
.product-card__brand mark,
.product-card__body mark {
    /* Светлый оттенок основного цвета (замените #264593 на ваш реальный --primary, если он другой) */
    background-color: rgba(38, 69, 147, 0.1); 
    color: var(--primary, #264593);
    font-weight: 700; /* Делаем совпадение жирным для акцента */
    border-radius: 3px; /* Легкое скругление углов */
    padding: 0 3px; /* Небольшой внутренний отступ, чтобы фон не "прилипал" к буквам */
    text-decoration: none; /* Гарантируем отсутствие подчеркивания внутри ссылки */
    
    /* Важно для корректного переноса подсвеченного текста на новую строку */
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* ============================================
   4. Изображение и галерея
   ============================================ */
.product-card__image {
  position: relative;
  padding-top: 75%; /* 4:3 */
  background: var(--bg-light, #f8fafc);
  overflow: hidden;
  flex-shrink: 0;
}

.product-card__images-wrapper {
  position: absolute;
  inset: 0; /* Современный шорткат для top:0; left:0; width:100%; height:100% */
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.product-card__images-wrapper img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 16px;
  background: var(--bg-white, #ffffff);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.product-card__images-wrapper img:first-child {
  opacity: 1;
  z-index: 2;
}

.product-card:hover .product-card__images-wrapper {
  transform: scale(1.04);
}

.product-card__image .no-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted, #64748b);
  font-size: 0.85rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 0;
}

.product-card__image .no-image svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

/* ============================================
   5. Бейджи и наличие
   ============================================ */
.product-card__badges {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}

.product-card__badge {
  padding: 4px 12px;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--primary, #3b82f6);
  color: #ffffff;
  width: fit-content;
}

.product-card__badge--hit { background: #f59e0b; }
.product-card__badge--sale { background: #ef4444; }
.product-card__badge--new { background: #22c55e; }

.product-card__badge--ivzip { 
  background: #ffffff;
  background-image: url("/assets/images/ivzip.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  width: 80px;    
  height: 28px;
  padding: 0;
  color: transparent;
}

.product-card__stock-badge {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 10;
}

.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
}

.stock-badge--in-stock { background: rgba(34, 197, 94, 0.9); }
.stock-badge--out-of-stock { background: rgba(239, 68, 68, 0.9); }
.stock-badge--unknown { background: rgba(156, 163, 175, 0.9); }

/* Оптимизация анимаций: вынесли общее в базовый класс */
.stock-badge--low,
.stock-badge--expected {
  animation: pulse-stock 1.5s ease-in-out infinite;
}
.stock-badge--low { background: rgba(245, 158, 11, 0.9); }
.stock-badge--expected { 
  background: rgba(59, 130, 246, 0.9); 
  animation-duration: 2s; 
}

@keyframes pulse-stock {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============================================
   6. Тело карточки и типографика
   ============================================ */
.product-card__body {
  padding: 0 16px 16px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-card__brand {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #64748b);
  margin-bottom: 6px;
}

.product-card__brand a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition, 0.2s ease);
}

.product-card__brand a:hover {
  color: var(--primary, #3b82f6);
}

.product-card__title {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.product-card__title a {
  color: var(--text-primary, #0f172a);
  text-decoration: none;
  transition: color var(--transition, 0.2s ease);
}

.product-card__title a:hover {
  color: var(--primary, #3b82f6);
}

.product-card__sku {
  font-size: 0.75rem;
  color: var(--text-muted, #64748b);
  margin-bottom: 10px;
}

/* ============================================
   7. Цена и действия
   ============================================ */
.product-card__price {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: auto; /* Прижимает цену к низу, если контент разной высоты */
  padding-top: 12px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.product-card__price-current {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

.product-card__price-current .currency {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  margin-left: 2px;
}

.product-card__price-old {
  font-size: 0.85rem;
  color: var(--text-muted, #64748b);
  text-decoration: line-through;
}

.product-card__price-discount {
  font-size: 0.75rem;
  font-weight: 600;
  color: #ef4444;
  background: #fef2f2;
  padding: 2px 10px;
  border-radius: var(--radius-full, 9999px);
  margin-left: auto;
}

.product-card__price--empty {
  color: var(--text-muted, #64748b);
  font-size: 0.85rem;
}

.product-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  justify-content: right;
}

.product-card__actions .btn {
  flex: 1;
  justify-content: center;
  font-size: 0.85rem;
  padding: 8px 16px;
  min-height: 36px;
}

.product-card__actions .btn-primary {
  background: var(--primary, #3b82f6);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: all var(--transition, 0.2s ease);
  display: flex;
  align-items: center;
  gap: 6px;
}

.product-card__actions .btn-primary:hover {
  background: var(--primary-dark, #2563eb);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
}

.product-card__actions .btn-primary:active {
  transform: scale(0.97);
}

.product-card__actions .btn-outline {
  background: transparent;
  color: var(--text-secondary, #475569);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: all var(--transition, 0.2s ease);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  flex: 0 0 auto;
}

.product-card__actions .btn-outline:hover {
  border-color: var(--primary, #3b82f6);
  color: var(--primary, #3b82f6);
  background: var(--primary-bg, #eff6ff);
}

.product-card__actions .btn-outline svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   8. Индикатор фото (Точки)
   ============================================ */
.product-card__image-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 8px 0;
  background: var(--bg-white, #ffffff);
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

.product-card__image-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  transition: all 0.25s ease;
  display: inline-block;
  flex-shrink: 0;
}

.product-card__image-dot.active {
  background: var(--primary, #3b82f6);
  width: 18px;
  border-radius: 3px;
}

/* ============================================
   9. Избранное (Favorites)
   ============================================ */
.btn-favorite {
  transition: all 0.2s ease;
}

.btn-favorite svg {
  transition: all 0.2s ease;
}

.btn-favorite.is-active {
  background: #fee2e2;
  border-color: #ef4444;
  color: #ef4444;
}

.btn-favorite.is-active svg {
  fill: #ef4444;
  stroke: #ef4444;
}

.btn-favorite.is-clicked {
  animation: favorite-pulse 0.3s ease;
}

@keyframes favorite-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Анимация удаления карточки */
.product-card.is-removing {
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  overflow: hidden;
}

/* Шапка страницы избранного */
.catalog-main--full .catalog-header {
  width: 100%;
}

.catalog-main--full .catalog-header__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.catalog-main--full .catalog-header__count {
  font-size: 1rem;
  color: var(--text-muted, #64748b);
}

.catalog-main--full .catalog-header__count strong {
  color: var(--text-primary, #0f172a);
  font-weight: 600;
}

/* ============================================
   10. Адаптивность (Desktop-first)
   ============================================ */
@media (max-width: 992px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
  }
  .catalog-sidebar { flex: 0 0 240px; }
}

@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }
  
  .catalog-layout {
    flex-direction: column;
    gap: 24px;
  }
  
  .catalog-sidebar { display: none; }
  .catalog-main { width: 100%; }

  .product-card__body { padding: 12px; }
  .product-card__title { font-size: 0.8rem; min-height: 2.4em; }
  .product-card__price-current { font-size: 1.2rem; }
  .product-card__actions .btn { font-size: 0.75rem; padding: 6px 12px; min-height: 32px; }
  .stock-badge { font-size: 0.6rem; padding: 3px 10px; }
}

@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .product-card__image { padding-top: 70%; }
  .product-card__images-wrapper img { padding: 8px; }
  
  .product-card__body { padding: 10px; }
  .product-card__title { font-size: 0.75rem; min-height: 2.2em; }
  .product-card__brand { font-size: 0.6rem; }
  .product-card__sku { font-size: 0.65rem; }
  .product-card__price-current { font-size: 1rem; }
  .product-card__price-old { font-size: 0.7rem; }
  
  .product-card__actions { flex-wrap: wrap; }
  .product-card__actions .btn { font-size: 0.7rem; padding: 4px 10px; min-height: 28px; }
  .product-card__actions .btn-outline { padding: 4px 8px; }
  .product-card__actions .btn-outline svg { width: 14px; height: 14px; }
  
  .stock-badge { font-size: 0.55rem; padding: 2px 8px; }
  .product-card__stock-badge { bottom: 8px; left: 8px; }
  
  .product-card__image-dots { gap: 4px; padding: 6px 0; }
  .product-card__image-dot { width: 5px; height: 5px; }
  .product-card__image-dot.active { width: 14px; }
}

@media (max-width: 360px) {
  .products-grid { gap: 8px; }
  .product-card__body { padding: 8px; }
  .product-card__price-current { font-size: 0.9rem; }
}