/* =============================================
   PRODUCT PAGE & CATEGORY PAGE STYLES
   ============================================= */

/* ---- Product Detail Page ---- */
.product-detail {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: var(--space-lg);
  align-items: start;
}
@media (max-width: 991px) {
  .product-detail { grid-template-columns: 1fr; }
}

/* Gallery */
.product-gallery { position: sticky; top: calc(var(--header-h) + 96px + var(--space-md)); }
.gallery-main {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  cursor: zoom-in;
  position: relative;
}
.gallery-main img {
  width: 100%; height: 100%;
  object-fit: contain;
  transition: transform var(--trans-slow);
}
.gallery-main:hover img { transform: scale(1.05); }
.gallery-badge {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
}

.gallery-thumbs {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.gallery-thumbs::-webkit-scrollbar { display: none; }
.gallery-thumb {
  flex-shrink: 0;
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--trans-fast);
  background: var(--gray-100);
}
.gallery-thumb.active { border-color: var(--primary); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 767px) {
  .product-gallery { position: static; }
}

/* Product Info */
.product-info { }

.product-info__shop {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: var(--space-sm);
}
.product-info__shop a { color: var(--primary); }
.product-info__shop .verified { color: var(--success); font-size: 14px; }

.product-info__title {
  font-size: 18px;
  font-weight: 500;
  color: var(--black);
  line-height: 1.4;
  margin-bottom: var(--space-sm);
}

.product-info__meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.product-info__rating-val {
  color: var(--primary);
  font-weight: 700;
  border-bottom: 1px solid var(--primary);
}
.product-info__meta .sep { color: var(--gray-300); }

.product-price-box {
  background: var(--gray-50);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.product-price-box__current {
  color: var(--accent);
  font-size: 28px;
  font-weight: 700;
}
.product-price-box__original {
  color: var(--gray-400);
  font-size: 16px;
  text-decoration: line-through;
}
.product-price-box__discount {
  background: var(--accent);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

/* Product Options */
.product-option { margin-bottom: var(--space-md); }
.product-option__label {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: var(--space-sm);
}
.product-option__label span { color: var(--black); font-weight: 600; margin-left: 8px; }

.option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.option-chip {
  padding: 6px 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--trans-fast);
  background: var(--white);
  position: relative;
  overflow: hidden;
}
.option-chip:hover { border-color: var(--primary); color: var(--primary); }
.option-chip.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-xlight);
}
.option-chip.selected::after {
  content: '✓';
  position: absolute;
  bottom: -2px; right: -2px;
  width: 16px; height: 16px;
  background: var(--primary);
  color: var(--white);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* Quantity */
.qty-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.qty-input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.qty-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  background: var(--gray-50);
  transition: background var(--trans-fast);
  color: var(--gray-800);
  border: none;
}
.qty-btn:hover { background: var(--gray-100); color: var(--primary); }
.qty-value {
  width: 60px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
  padding: 0 8px;
  height: 36px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.qty-stock { font-size: 12px; color: var(--gray-600); }

/* CTA Buttons */
.product-cta {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}
.btn-add-cart {
  flex: 1;
  min-width: 160px;
  background: var(--primary-xlight);
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-add-cart:hover { background: var(--primary); color: var(--white); }
.btn-buy-now {
  flex: 1;
  min-width: 160px;
  background: var(--primary);
  color: var(--white);
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
}
.btn-buy-now:hover { background: var(--primary-dark); }

/* Shipping Info */
.shipping-info {
  margin-top: var(--space-md);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.shipping-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.shipping-row:last-child { border-bottom: none; }
.shipping-row__label {
  color: var(--gray-600);
  min-width: 80px;
  flex-shrink: 0;
}
.shipping-row__value { color: var(--black); }
.shipping-row__value a { color: var(--primary); }
.shipping-badge {
  background: var(--primary-xlight);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

/* ---- Shop Info Card ---- */
.shop-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.shop-card__avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gray-200);
  background: var(--gray-100);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shop-card__info { flex: 1; }
.shop-card__name { font-size: 16px; font-weight: 600; }
.shop-card__status { font-size: 12px; color: var(--success); }
.shop-card__stats {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}
.shop-stat { font-size: 12px; color: var(--gray-600); }
.shop-stat strong { display: block; color: var(--primary); font-size: 14px; }
.shop-card__actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

/* ---- Product Reviews ---- */
.reviews-section {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}
.reviews-summary {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}
.reviews-score {
  text-align: center;
  flex-shrink: 0;
}
.reviews-score__number { font-size: 48px; font-weight: 800; color: var(--accent); line-height: 1; }
.reviews-score__label { font-size: 12px; color: var(--gray-600); margin-top: 4px; }
.reviews-bars { flex: 1; min-width: 200px; }
.review-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 6px;
  font-size: 12px;
}
.review-bar-row__label { width: 24px; text-align: right; color: var(--primary); }
.review-bar-row__bar { flex: 1; height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.review-bar-row__fill { height: 100%; background: var(--primary); border-radius: 3px; }

.review-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}
.review-filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: 12px;
  cursor: pointer;
  background: var(--white);
  transition: all var(--trans-fast);
}
.review-filter-btn.active { border-color: var(--primary); background: var(--primary); color: var(--white); }

.review-item {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--gray-100);
}
.review-item:last-child { border-bottom: none; }
.review-item__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.review-item__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-xlight);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.review-item__user { font-size: 13px; font-weight: 500; }
.review-item__date { font-size: 11px; color: var(--gray-400); }
.review-item__variant { font-size: 11px; color: var(--gray-600); margin-bottom: var(--space-xs); }
.review-item__text { font-size: 13px; color: var(--gray-800); line-height: 1.6; }
.review-item__photos {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}
.review-item__photo {
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--gray-200);
  background: var(--gray-100);
}

/* ---- Category / Archive Page ---- */
.category-page { display: grid; grid-template-columns: 260px 1fr; gap: var(--space-lg); align-items: start; }
@media (max-width: 991px) { .category-page { grid-template-columns: 1fr; } }

/* Inside category page (sidebar present), 4 cols max */
.category-page .product-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1199px) { .category-page .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 991px)  { .category-page .product-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 767px)  { .category-page .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 479px)  { .category-page .product-grid { grid-template-columns: repeat(2, 1fr); } }

/* Archive page wrapper polish */
.archive-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.archive-page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--black);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.archive-page-title::before {
  content: '';
  width: 4px;
  height: 22px;
  background: var(--primary);
  border-radius: 2px;
  display: block;
}
.archive-result-count {
  font-size: 13px;
  color: var(--gray-600);
  background: var(--gray-100);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

/* ---- Improved Filter Sidebar ---- */
.filter-sidebar {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: sticky;
  top: calc(var(--header-h) + var(--space-md));
  max-height: calc(100vh - var(--header-h) - var(--space-md) * 2);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}
.filter-sidebar::-webkit-scrollbar { width: 4px; }
.filter-sidebar::-webkit-scrollbar-track { background: transparent; }
.filter-sidebar::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }

@media (max-width: 991px) {
  .filter-sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 800;
    border-radius: 0;
    max-height: none;
    overflow-y: auto;
  }
  .filter-sidebar.open { display: block; }
}

/* Filter Header */
.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 2px solid var(--primary-xlight);
  background: linear-gradient(135deg, var(--primary-xlight) 0%, var(--white) 100%);
  position: sticky;
  top: 0;
  z-index: 1;
}
.filter-header__left { display: flex; align-items: center; gap: var(--space-sm); }
.filter-header__icon { font-size: 18px; }
.filter-header__title { font-size: 15px; font-weight: 700; color: var(--black); }
.filter-header__right { display: flex; align-items: center; gap: var(--space-sm); }
.filter-clear-btn {
  font-size: 11px;
  color: var(--primary);
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.filter-clear-btn:hover { color: var(--primary-dark); }
.filter-close-btn {
  width: 28px; height: 28px;
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans-fast);
}
.filter-close-btn:hover { background: var(--gray-200); }

.filter-accordion:not(.open) .filter-accordion__body { display: none; }

/* Accordion sections */
.filter-accordion {
  border-bottom: 1px solid var(--gray-100);
}
.filter-accordion__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--space-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--trans-fast);
  text-align: left;
  font-family: inherit;
}
.filter-accordion__trigger:hover { background: var(--gray-50); }
.filter-accordion__arrow {
  font-size: 12px;
  color: var(--gray-400);
  transition: transform var(--trans-fast);
  flex-shrink: 0;
}
.filter-accordion.open .filter-accordion__arrow { transform: rotate(0deg); }
.filter-accordion:not(.open) .filter-accordion__arrow { transform: rotate(-90deg); }

.filter-accordion__body { padding: 0 var(--space-md) var(--space-md); }

/* Brand chips */
.brand-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}
.brand-chip {
  padding: 5px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  background: var(--white);
  color: var(--gray-800);
  transition: all var(--trans-fast);
  font-family: inherit;
}
.brand-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-xlight); }
.brand-chip.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
}

/* Custom checkbox rows */
.filter-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 7px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-800);
  transition: color var(--trans-fast);
  position: relative;
}
.filter-check:hover { color: var(--primary); }
.filter-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.filter-check__box {
  width: 16px; height: 16px;
  border: 2px solid var(--gray-200);
  border-radius: 4px;
  flex-shrink: 0;
  transition: all var(--trans-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
}
.filter-check input:checked ~ .filter-check__box {
  background: var(--primary);
  border-color: var(--primary);
}
.filter-check input:checked ~ .filter-check__box::after {
  content: '✓';
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.filter-check:hover .filter-check__box { border-color: var(--primary); }
.filter-check__label { flex: 1; }
.filter-check__count {
  font-size: 11px;
  color: var(--gray-400);
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.filter-check input:checked ~ .filter-check__label { color: var(--primary); font-weight: 600; }

/* Price range */
.price-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: var(--space-sm);
}
.price-quick-chip {
  padding: 4px 9px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: 11px;
  cursor: pointer;
  background: var(--white);
  color: var(--gray-700);
  font-family: inherit;
  transition: all var(--trans-fast);
}
.price-quick-chip:hover, .price-quick-chip.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-xlight);
}

.price-range-inputs {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.price-input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 12px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--trans-fast);
  background: var(--gray-50);
  color: var(--black);
}
.price-input:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(26,80,160,0.08); }
.price-range-sep { color: var(--gray-400); font-size: 12px; flex-shrink: 0; }

/* Star rating filter */
.filter-rating-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 7px 0;
  cursor: pointer;
  transition: background var(--trans-fast);
  border-radius: var(--radius-sm);
  padding-left: 4px;
}
.filter-rating-row:hover { background: var(--gray-50); }
.filter-rating-row input[type="radio"] { accent-color: var(--primary); width: 14px; height: 14px; flex-shrink: 0; }
.filter-rating-stars { display: flex; gap: 1px; }
.fstar { font-size: 15px; line-height: 1; }
.fstar.filled { color: #FFB800; }
.fstar.empty { color: var(--gray-200); }
.filter-rating-label { font-size: 12px; color: var(--gray-600); }
.filter-rating-row:has(input:checked) .fstar.empty { color: #FFE066; }
.filter-rating-row:has(input:checked) .filter-rating-label { color: var(--primary); font-weight: 600; }

/* Filter footer */
.filter-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--gray-100);
  background: var(--white);
  position: sticky;
  bottom: 0;
}
.filter-apply-count {
  background: var(--white);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  margin-left: 4px;
}

/* Toolbar */
.products-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
  color: var(--gray-600);
}
.sort-btn {
  padding: 6px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  background: var(--white);
  transition: all var(--trans-fast);
  color: var(--gray-800);
}
.sort-btn.active { border-color: var(--primary); background: var(--primary); color: var(--white); }
.sort-select {
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  background: var(--white);
}
.filter-mobile-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  background: var(--white);
}
@media (max-width: 991px) { .filter-mobile-btn { display: flex; } }
