/* Copyright (c) 2025-2026 Spwig contributors. Licensed under AGPL-3.0. */

/* ==========================================================================
   Category Page - List Template
   Modern horizontal product rows with image, details, pricing, and actions.
   Uses --theme-element-category-* design tokens from the token system.
   Fallbacks use hardcoded values for graceful degradation.
   ========================================================================== */

/* ==========================================================================
   Product List Container
   ========================================================================== */

.cat-list-products {
  display: flex;
  flex-direction: column;
  gap: var(--theme-element-category-list-gap, 1.25rem);
}

/* ==========================================================================
   Product Row
   ========================================================================== */

.cat-list-row {
  display: flex;
  flex-direction: row;
  background: var(--theme-element-category-list-row-bg, #ffffff);
  border: var(--theme-element-category-list-row-border-width, 1px) solid
    var(--theme-element-category-list-row-border-color, #e5e7eb);
  border-radius: var(--theme-element-category-list-row-radius, 0.75rem);
  box-shadow: var(--theme-element-category-list-row-shadow, 0 1px 3px rgba(0, 0, 0, 0.06));
  overflow: hidden;
  transition:
    box-shadow var(--theme-element-category-list-row-transition-duration, 200ms)
      var(--theme-element-category-list-row-transition-easing, ease),
    transform var(--theme-element-category-list-row-transition-duration, 200ms)
      var(--theme-element-category-list-row-transition-easing, ease);
}

.cat-list-row:hover {
  box-shadow: var(--theme-element-category-list-row-shadow-hover, 0 8px 25px rgba(0, 0, 0, 0.1));
  transform: var(--theme-element-category-list-row-hover-transform, translateY(-1px));
}

/* Reversed layout: image on the right */
.cat-list-row--img-right {
  flex-direction: row-reverse;
}

/* ==========================================================================
   Product Image
   ========================================================================== */

.cat-list-row__image {
  position: relative;
  flex: 0 0 var(--theme-element-category-list-image-width, 16rem);
  width: var(--theme-element-category-list-image-width, 16rem);
  aspect-ratio: var(--theme-element-category-list-image-aspect-ratio, 1);
  overflow: hidden;
  border-radius: var(--theme-element-category-list-image-radius, 0);
  background: var(--theme-element-category-list-image-bg, #f9fafb);
}

.cat-list-row__image-link {
  display: block;
  width: 100%;
  height: 100%;
}

.cat-list-row__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--theme-element-category-list-image-transition-duration, 300ms)
    var(--theme-element-category-list-image-transition-easing, ease);
}

.cat-list-row:hover .cat-list-row__img {
  transform: var(--theme-element-category-list-image-hover-transform, scale(1.03));
}

.cat-list-row__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--theme-element-category-list-placeholder-size, 2.5rem);
  color: var(--theme-element-category-list-placeholder-color, #9ca3af);
}

/* Image hover overlay */
.cat-list-row__overlay {
  position: absolute;
  inset: 0;
  background: var(--theme-color-surface-hover, rgba(0, 0, 0, 0.03));
  opacity: 0;
  transition: opacity var(--theme-element-category-list-row-transition-duration, 200ms)
    var(--theme-element-category-list-row-transition-easing, ease);
  pointer-events: none;
}

.cat-list-row:hover .cat-list-row__overlay {
  opacity: 1;
}

/* ==========================================================================
   Product Info
   ========================================================================== */

.cat-list-row__info {
  flex: 1;
  padding: var(--theme-element-category-list-info-padding, 1.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.cat-list-row__title {
  font-size: var(--theme-element-category-list-title-size, 1.25rem);
  font-weight: var(--theme-element-category-list-title-weight, 600);
  color: var(--theme-element-category-list-title-color, #1f2937);
  margin: 0 0 var(--theme-space-2, 0.5rem) 0;
  line-height: var(--theme-element-category-list-title-line-height, 1.3);
}

.cat-list-row__title a {
  color: inherit;
  text-decoration: none;
}

.cat-list-row__title a:hover {
  color: var(--theme-element-category-list-title-hover-color, #2563eb);
}

.cat-list-row__desc {
  font-size: var(--theme-element-category-list-desc-size, 0.9375rem);
  color: var(--theme-element-category-list-desc-color, #6b7280);
  line-height: var(--theme-element-category-list-desc-line-height, 1.6);
  margin: 0 0 var(--theme-space-3, 0.75rem) 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   Product Price
   ========================================================================== */

.cat-list-row__price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--theme-space-2, 0.5rem);
  margin: 0 0 var(--theme-space-3, 0.75rem) 0;
}

.cat-list-row__price-current {
  font-size: var(--theme-element-category-list-price-size, 1.25rem);
  font-weight: var(--theme-element-category-list-price-weight, 700);
  color: var(--theme-element-category-list-price-color, #1f2937);
}

.cat-list-row__price-current--sale {
  color: var(--theme-color-danger, #dc2626);
}

.cat-list-row__price-original {
  font-size: var(--theme-font-size-sm, 0.875rem);
  color: var(--theme-color-text-muted, #6b7280);
  text-decoration: line-through;
}

/* ==========================================================================
   Product Actions
   ========================================================================== */

.cat-list-row__actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--theme-element-category-list-actions-gap, 0.75rem);
  margin-top: auto;
  padding-top: var(--theme-space-3, 0.75rem);
}

/* Wishlist button sizing for list context */
.cat-list-row__wishlist-btn {
  flex-shrink: 0;
}

/* Override product-card button width (defaults to 100%) for list context */
.cat-list-row__cart-btn,
.cat-list-row__quickview-btn,
.cat-list-row__options-btn {
  width: auto;
  padding: var(--theme-space-2, 0.5rem) var(--theme-space-5, 1.25rem);
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.cat-list-empty {
  text-align: center;
  padding: var(--theme-space-12, 3rem) var(--theme-space-6, 1.5rem);
  color: var(--theme-element-category-list-empty-color, #6b7280);
}

.cat-list-empty i {
  font-size: var(--theme-element-category-list-empty-icon-size, 3rem);
  margin-bottom: var(--theme-space-4, 1rem);
  display: block;
  color: var(--theme-element-category-list-empty-icon-color, #d1d5db);
}

/* ==========================================================================
   Responsive - Tablet
   ========================================================================== */

@media (max-width: 1024px) {
  .cat-list-row__image {
    flex: 0 0 var(--theme-element-category-list-image-tablet-width, 12rem);
    width: var(--theme-element-category-list-image-tablet-width, 12rem);
  }

  .cat-list-row__info {
    padding: var(--theme-element-category-list-info-tablet-padding, 1.25rem);
  }

  .cat-list-row__title {
    font-size: var(--theme-element-category-list-title-tablet-size, 1.125rem);
  }
}

/* ==========================================================================
   Responsive - Mobile
   ========================================================================== */

@media (max-width: 768px) {
  .cat-list-row,
  .cat-list-row--img-right {
    flex-direction: column;
  }

  .cat-list-row__image {
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: var(--theme-element-category-list-image-mobile-aspect-ratio, 16 / 9);
  }

  .cat-list-row__info {
    padding: var(--theme-element-category-list-info-mobile-padding, 1rem);
  }

  .cat-list-row__title {
    font-size: var(--theme-element-category-list-title-mobile-size, 1.125rem);
  }

  .cat-list-row__actions {
    flex-wrap: wrap;
  }

  .cat-list-row__cart-btn,
  .cat-list-row__quickview-btn,
  .cat-list-row__options-btn {
    flex: 1;
    justify-content: center;
  }
}

/* ==========================================================================
   Responsive - Extra Small
   ========================================================================== */

@media (max-width: 480px) {
  .cat-list-row__info {
    padding: var(--theme-element-category-list-info-xs-padding, 0.75rem);
  }

  .cat-list-row__desc {
    -webkit-line-clamp: 3;
  }

  .cat-list-row__price-current {
    font-size: var(--theme-element-category-list-price-mobile-size, 1.125rem);
  }
}

/* ==========================================================================
   Touch Devices
   ========================================================================== */

@media (hover: none) {
  .cat-list-row__overlay {
    display: none;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .cat-list-row,
  .cat-list-row__img,
  .cat-list-row__overlay {
    transition: none;
  }
}
