/* =============================================================
   ShoppingPH — Archive, Category, Tag & Search Pages
   assets/css/archive.css
   ============================================================= */


/* ── ARCHIVE PAGE LAYOUT ─────────────────────────────────────── */
.sph-archive {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 1024px) {
  .sph-archive {
    grid-template-columns: 1fr 280px;
  }
}

.sph-archive__main {
  min-width: 0;
}

.sph-archive__sidebar {
  position: sticky;
  top: calc(var(--header-height) + var(--catbar-height) + var(--space-4));
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}


/* ── CATEGORY HERO ───────────────────────────────────────────── */
.sph-archive-hero {
  background: linear-gradient(135deg, var(--sph-red) 0%, var(--sph-orange) 100%);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-8);
  margin-bottom: var(--space-6);
  position: relative;
  overflow: hidden;
  color: var(--sph-white);
}

/* Decorative bubbles */
.sph-archive-hero::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  pointer-events: none;
}

.sph-archive-hero::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: 10%;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}

.sph-archive-hero__inner {
  position: relative;
  z-index: 1;
}

.sph-archive-hero__icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: var(--space-3);
  display: block;
}

.sph-archive-hero__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: var(--weight-extrabold);
  color: var(--sph-white);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
}

.sph-archive-hero__desc {
  font-size: var(--text-base);
  color: rgba(255,255,255,0.82);
  line-height: var(--leading-relaxed);
  max-width: 520px;
  margin-bottom: var(--space-4);
}

.sph-archive-hero__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.7);
}

.sph-archive-hero__meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.sph-archive-hero__meta-item strong {
  color: var(--sph-white);
  font-weight: var(--weight-bold);
}

.sph-archive-hero__meta-sep {
  width: 1px;
  height: 14px;
  background: rgba(255,255,255,0.3);
}

/* Tag/store specific hero variants */
.sph-archive-hero--tag {
  background: linear-gradient(135deg, #212121 0%, #424242 100%);
}

.sph-archive-hero--search {
  background: linear-gradient(135deg, var(--sph-gray-800) 0%, var(--sph-gray-900) 100%);
  padding: var(--space-6) var(--space-8);
}

.sph-archive-hero--search .sph-archive-hero__title {
  font-size: var(--text-2xl);
}


/* ── FILTER + SORT BAR ───────────────────────────────────────── */
.sph-filter-bar {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--sph-gray-200);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.sph-filter-bar__group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sph-filter-bar__label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--sph-gray-500);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
}

.sph-filter-bar__divider {
  width: 1px;
  height: 24px;
  background: var(--sph-gray-200);
  flex-shrink: 0;
}

/* Results count + view toggle pushed to the right */
.sph-filter-bar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sph-filter-bar__count {
  font-size: var(--text-xs);
  color: var(--sph-gray-500);
  white-space: nowrap;
}

.sph-filter-bar__count strong {
  color: var(--sph-gray-900);
}

/* View toggle (grid / list) */
.sph-view-toggle {
  display: flex;
  border: 1px solid var(--sph-gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sph-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--sph-gray-400);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.sph-view-btn:hover { color: var(--sph-gray-700); background: var(--sph-gray-50); }
.sph-view-btn.is-active { background: var(--sph-red); color: var(--sph-white); }
.sph-view-btn svg { width: 16px; height: 16px; }

/* Sort select */
.sph-sort-select {
  appearance: none;
  -webkit-appearance: none;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--sph-gray-700);
  background: var(--sph-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239E9E9E' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center / 14px 14px;
  border: 1px solid var(--sph-gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--duration-fast);
  min-width: 140px;
}

.sph-sort-select:hover,
.sph-sort-select:focus {
  border-color: var(--sph-red);
  outline: none;
}

/* Store filter chips */
.sph-store-filter {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sph-store-chip {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--sph-gray-200);
  color: var(--sph-gray-600);
  background: var(--sph-white);
  cursor: pointer;
  transition: all var(--duration-fast);
  white-space: nowrap;
  user-select: none;
}

.sph-store-chip:hover {
  border-color: var(--sph-gray-400);
  color: var(--sph-gray-800);
}

.sph-store-chip.is-active {
  background: var(--sph-gray-900);
  border-color: var(--sph-gray-900);
  color: var(--sph-white);
}

.sph-store-chip[data-store="shopee"].is-active  { background: #EE4D2D; border-color: #EE4D2D; }
.sph-store-chip[data-store="lazada"].is-active   { background: #0F146D; border-color: #0F146D; }
.sph-store-chip[data-store="tiktok"].is-active   { background: #010101; border-color: #010101; }
.sph-store-chip[data-store="zalora"].is-active   { background: #F7941D; border-color: #F7941D; }

.sph-store-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Rating filter */
.sph-rating-filter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sph-rating-chip {
  padding: 4px var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--sph-gray-200);
  color: var(--sph-gray-600);
  background: var(--sph-white);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.sph-rating-chip:hover { border-color: var(--sph-gold); color: var(--sph-gold-dark); }
.sph-rating-chip.is-active {
  background: var(--sph-gold);
  border-color: var(--sph-gold);
  color: #7A4800;
}

/* Mobile filter collapse */
.sph-filter-bar__toggle {
  display: none;
}

@media (max-width: 767px) {
  .sph-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .sph-filter-bar__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--sph-gray-700);
    background: none;
    border: none;
    padding: 0;
  }

  .sph-filter-bar__toggle svg {
    width: 16px;
    height: 16px;
    color: var(--sph-gray-400);
    transition: transform var(--duration-base) var(--ease-out);
  }

  .sph-filter-bar__toggle.is-open svg {
    transform: rotate(180deg);
  }

  .sph-filter-bar__collapsible {
    display: none;
    flex-direction: column;
    gap: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--sph-gray-100);
  }

  .sph-filter-bar__collapsible.is-open {
    display: flex;
  }

  .sph-filter-bar__right {
    margin-left: 0;
    justify-content: space-between;
  }

  .sph-filter-bar__divider {
    display: none;
  }
}


/* ── LIST VIEW (alternative to grid) ────────────────────────── */
.product-grid.is-list-view {
  grid-template-columns: 1fr !important;
}

.product-grid.is-list-view .product-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  border-radius: var(--radius-md);
}

.product-grid.is-list-view .product-card__image-wrap {
  aspect-ratio: 1;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.product-grid.is-list-view .product-card__body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.product-grid.is-list-view .product-card__title {
  -webkit-line-clamp: 3;
  font-size: var(--text-base);
}

@media (max-width: 639px) {
  .product-grid.is-list-view .product-card {
    grid-template-columns: 90px 1fr;
  }
}


/* ── NO RESULTS STATE ────────────────────────────────────────── */
.sph-no-results {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.sph-no-results__icon {
  font-size: 4rem;
  display: block;
  margin-bottom: var(--space-4);
  line-height: 1;
}

.sph-no-results__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--sph-gray-900);
  margin-bottom: var(--space-2);
}

.sph-no-results__desc {
  font-size: var(--text-base);
  color: var(--sph-gray-500);
  margin-bottom: var(--space-6);
  max-width: 360px;
  margin-inline: auto;
  line-height: var(--leading-relaxed);
}

.sph-no-results__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* Filter active — no results within filter */
.sph-filter-no-results {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  color: var(--sph-gray-500);
  display: none;
}

.sph-filter-no-results.is-visible {
  display: block;
}

.sph-filter-no-results p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}


/* ── TAG CLOUD (sidebar widget) ──────────────────────────────── */
.sph-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sph-tag-cloud a {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--sph-gray-600);
  background: var(--sph-gray-100);
  border: 1px solid var(--sph-gray-200);
  border-radius: var(--radius-pill);
  transition: all var(--duration-fast);
  text-decoration: none;
}

.sph-tag-cloud a:hover {
  background: var(--sph-red-light);
  border-color: var(--sph-red);
  color: var(--sph-red-dark);
}

/* Weighted tag sizes */
.sph-tag-cloud a[data-size="1"] { font-size: 10px; }
.sph-tag-cloud a[data-size="2"] { font-size: 11px; }
.sph-tag-cloud a[data-size="3"] { font-size: 12px; }
.sph-tag-cloud a[data-size="4"] { font-size: 13px; font-weight: var(--weight-semibold); }
.sph-tag-cloud a[data-size="5"] { font-size: 14px; font-weight: var(--weight-bold); }


/* ── SEARCH RESULTS ──────────────────────────────────────────── */
.sph-search-highlight {
  background: var(--sph-gold);
  color: var(--sph-gray-900);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: var(--weight-semibold);
}

/* Search suggestions when 0 results */
.sph-search-suggestions {
  margin-top: var(--space-6);
  text-align: left;
}

.sph-search-suggestions__title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--sph-gray-700);
  margin-bottom: var(--space-3);
}

.sph-search-suggestions__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sph-search-suggestions__list a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  background: var(--sph-white);
  border: 1px solid var(--sph-gray-200);
  border-radius: var(--radius-md);
  color: var(--sph-gray-700);
  text-decoration: none;
  transition: all var(--duration-fast);
}

.sph-search-suggestions__list a:hover {
  border-color: var(--sph-red);
  color: var(--sph-red);
  background: var(--sph-red-mist);
}

/* Inline search form (larger, for search page) */
.sph-search-page-form {
  margin-bottom: var(--space-6);
}

.sph-search-page-form .search-form {
  max-width: none;
  height: 52px;
  box-shadow: var(--shadow-md);
  border: 2px solid var(--sph-gray-200);
  border-radius: var(--radius-md);
}

.sph-search-page-form .search-form input {
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-5);
}

.sph-search-page-form .search-form__btn {
  width: 52px;
  height: 100%;
}

.sph-search-page-form .search-form__btn svg {
  width: 20px;
  height: 20px;
}


/* ── PAGINATION (archive-specific, enhanced) ─────────────────── */
.sph-archive-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-10);
  flex-wrap: wrap;
}

.sph-archive-pagination .page-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--sph-gray-700);
  background: var(--surface-card);
  border: 1px solid var(--sph-gray-200);
  text-decoration: none;
  transition: all var(--duration-fast);
  box-shadow: var(--shadow-xs);
}

.sph-archive-pagination .page-numbers:hover {
  background: var(--sph-red-light);
  border-color: var(--sph-red);
  color: var(--sph-red);
}

.sph-archive-pagination .page-numbers.current {
  background: var(--sph-red);
  border-color: var(--sph-red);
  color: var(--sph-white);
  box-shadow: 0 2px 8px rgba(238,77,45,0.35);
}

.sph-archive-pagination .page-numbers.dots {
  border: none;
  background: none;
  box-shadow: none;
  color: var(--sph-gray-400);
  cursor: default;
}

.sph-archive-pagination .prev.page-numbers,
.sph-archive-pagination .next.page-numbers {
  gap: var(--space-1);
  font-size: var(--text-xs);
}


/* ── INLINE AD BETWEEN GRID ROWS ─────────────────────────────── */
.sph-archive-ad-row {
  grid-column: 1 / -1;
  background: var(--sph-gray-100);
  border: 1px solid var(--sph-gray-200);
  border-radius: var(--radius-md);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.sph-archive-ad-row .ad-label {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sph-gray-400);
}


/* ── ACTIVE FILTER PILL BAR ──────────────────────────────────── */
.sph-active-filters {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.sph-active-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--sph-red-dark);
  background: var(--sph-red-light);
  border: 1px solid var(--sph-red-light);
  border-radius: var(--radius-pill);
}

.sph-active-filter-pill button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(238,77,45,0.2);
  color: var(--sph-red);
  border: none;
  cursor: pointer;
  font-size: 10px;
  transition: background var(--duration-fast);
  padding: 0;
  line-height: 1;
}

.sph-active-filter-pill button:hover {
  background: var(--sph-red);
  color: white;
}

.sph-clear-all-filters {
  font-size: var(--text-xs);
  color: var(--sph-gray-500);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color var(--duration-fast);
}

.sph-clear-all-filters:hover { color: var(--sph-red); }
