/*
 * WC Pagespeed Filter — frontend styles
 * Uses CSS variables from the eurosmak theme.
 * BEM-ish: .wcpsf-filter, .wcpsf-fg, .wcpsf-item, .wcpsf-products-wrap
 */

/* Map legacy --yellow/--dark to theme accent colors */
:root {
  --yellow: var(--accent, #16a34a);
  --dark:   #fff;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.wcpsf-filter {
  font-size: 14px;
  line-height: 1.5;
  width: 100%;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.wcpsf-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  margin-bottom: 4px;
}
.wcpsf-filter-head-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text, #111827);
}
.wcpsf-filter-reset {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 20px;
  cursor: pointer;
  color: var(--text2, #6b7280);
  font-size: 12px;
  padding: 3px 10px 3px 8px;
  transition: background .15s, border-color .15s, color .15s;
}
.wcpsf-filter-reset::before { content: '×'; font-size: 15px; line-height: 1; }
.wcpsf-filter-reset:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ── Filter group ───────────────────────────────────────────────────────── */
.wcpsf-fg {
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.wcpsf-fg-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px 0;
  text-align: left;
  gap: 6px;
  color: var(--text, #111827);
  font-size: 13px;
  font-weight: 600;
}
.wcpsf-fg-toggle:hover { color: var(--yellow); }
.wcpsf-fg-toggle-label { flex: 1; }
.wcpsf-fg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--yellow);
  color: var(--dark);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
}
.wcpsf-fg-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform .2s;
  color: var(--text2, #6b7280);
}
.wcpsf-fg-toggle[aria-expanded="true"] .wcpsf-fg-arrow {
  transform: rotate(180deg);
}

/* ── Group body ─────────────────────────────────────────────────────────── */
.wcpsf-fg-body {
  overflow: hidden;
  padding-bottom: 12px;
  max-height: 2000px;
  transition: max-height .3s ease, padding .3s ease, opacity .3s ease;
  opacity: 1;
}
.wcpsf-fg--collapsed .wcpsf-fg-body {
  max-height: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* Conditional visibility — hidden until dependent filter is active */
.wcpsf-fg--hidden {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height .35s ease, opacity .25s ease, margin .3s ease;
  margin-bottom: 0;
}
.wcpsf-fg--hidden.wcpsf-fg--visible {
  max-height: 2000px;
  opacity: 1;
  pointer-events: auto;
  margin-bottom: 8px;
}

/* ── Item list ──────────────────────────────────────────────────────────── */
.wcpsf-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.wcpsf-items::-webkit-scrollbar { width: 4px; }
.wcpsf-items::-webkit-scrollbar-track { background: transparent; }
.wcpsf-items::-webkit-scrollbar-thumb { background: var(--border, #e5e7eb); border-radius: 2px; }

/* ── Checkbox / radio item ──────────────────────────────────────────────── */
.wcpsf-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: var(--radius, 6px);
  transition: background .12s;
}
.wcpsf-item label:hover { background: var(--bg-light, #f9fafb); }
/* Checkbox / radio appearance — defined in theme main.css to guarantee delivery */
.wcpsf-item-label {
  flex: 1;
  color: var(--text, #111827);
  font-size: 13px;
}
.wcpsf-item-count {
  font-size: 11px;
  color: var(--text3, #9ca3af);
  margin-left: auto;
}
.wcpsf-item--active .wcpsf-item-label { font-weight: 600; color: #000; }
/* Greyed-out unavailable term */
.wcpsf-item--disabled {
  opacity: 0.35;
  pointer-events: none;
}
.wcpsf-item--disabled label { cursor: default; }

/* ── Color swatch ───────────────────────────────────────────────────────── */
.wcpsf-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.12);
  flex-shrink: 0;
}
.wcpsf-item--active .wcpsf-swatch {
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px var(--yellow);
}
.wcpsf-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ── Price range ────────────────────────────────────────────────────────── */
.wcpsf-price-range { padding: 4px 0 8px; }
.wcpsf-slider-wrap {
  position: relative;
  height: 22px;
  margin-bottom: 12px;
}
.wcpsf-slider-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border, #e5e7eb);
  border-radius: 2px;
  transform: translateY(-50%);
}
.wcpsf-slider-fill {
  position: absolute;
  height: 100%;
  background: var(--yellow);
  border-radius: 2px;
}
.wcpsf-range {
  position: absolute;
  width: 100%;
  top: 50%;
  transform: translateY(-50%);
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  pointer-events: none;
  margin: 0;
}
.wcpsf-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--yellow);
  pointer-events: all;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.wcpsf-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--yellow);
  pointer-events: all;
  cursor: pointer;
  border: 2px solid #fff;
}
.wcpsf-price-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
}
.wcpsf-price-inputs label {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  font-size: 12px;
  color: var(--text2, #6b7280);
}
.wcpsf-price-inputs input[type="number"] {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 6px);
  font-size: 13px;
  color: var(--text, #111827);
}
.wcpsf-price-inputs input[type="number"]::-webkit-outer-spin-button,
.wcpsf-price-inputs input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.wcpsf-price-inputs input[type="number"] { -moz-appearance: textfield; }
.wcpsf-price-inputs input[type="number"]:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(22,163,74,.15);
}

/* ── Apply button ───────────────────────────────────────────────────────── */
.wcpsf-filter-footer { padding: 16px 0 0; }
.wcpsf-filter-apply {
  width: 100%;
  padding: 10px;
  background: var(--yellow);
  color: var(--dark);
  border: none;
  border-radius: var(--radius, 8px);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.wcpsf-filter-apply:hover { opacity: .88; }

/* ── Products wrap + loading overlay ────────────────────────────────────── */
.wcpsf-products-wrap {
  position: relative;
  min-height: 200px;
}
.wcpsf-products-wrap.wcpsf-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 5;
  border-radius: var(--radius, 8px);
}
.wcpsf-spinner {
  display: none;
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border, #e5e7eb);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: wcpsf-spin .7s linear infinite;
}
.wcpsf-products-wrap.wcpsf-loading .wcpsf-spinner { display: block; }

@keyframes wcpsf-spin { to { transform: translateX(-50%) rotate(360deg); } }
@keyframes wcpsf-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Skeleton loading ──────────────────────────────────────────────────── */
.wcpsf-skeleton-wrap {
  display: grid;
  /* Mirrors .woocommerce ul.products grid breakpoints from the theme */
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 4px 0;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 4;
  background: #fff;
  align-items: start;
}
.wcpsf-skeleton-wrap--hidden { display: none; }
@media (max-width: 820px) { .wcpsf-skeleton-wrap { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (max-width: 560px) { .wcpsf-skeleton-wrap { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.wcpsf-skeleton-card {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.wcpsf-skel--img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 0;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: wcpsf-shimmer 1.4s infinite;
}
.wcpsf-skeleton-card__body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wcpsf-skel {
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: wcpsf-shimmer 1.4s infinite;
}
.wcpsf-skel--title { height: 13px; width: 85%; }
.wcpsf-skel--title2 { height: 13px; width: 60%; }
.wcpsf-skel--price { height: 18px; width: 45%; margin-top: 2px; }
.wcpsf-skel--btn   { height: 34px; width: 100%; border-radius: var(--radius-sm, 6px); margin-top: 4px; }

/* ── No products ─────────────────────────────────────────────────────────── */
.wcpsf-no-products {
  padding: 48px 24px;
  text-align: center;
  color: var(--text2, #6b7280);
  background: var(--surface, #f9fafb);
  border-radius: var(--radius, 12px);
  border: 2px dashed var(--border, #e5e7eb);
  margin: 16px 0;
}
.wcpsf-no-products__icon {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--border, #d1d5db);
}
.wcpsf-no-products__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #374151);
  margin: 0 0 6px;
}
.wcpsf-no-products__hint {
  font-size: 13px;
  margin: 0 0 16px;
}
.wcpsf-filter-reset-link {
  display: inline-block;
  padding: 8px 20px;
  background: var(--yellow);
  color: var(--dark);
  border-radius: var(--radius, 8px);
  font-size: 13px;
  text-decoration: none;
  transition: opacity .15s;
}
.wcpsf-filter-reset-link:hover { opacity: .85; }

/* ── Pagination area ──────────────────────────────────────────────────────── */
.wcpsf-pagination {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
}
.wcpsf-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 6px);
  font-size: 13px;
  color: var(--text, #111827);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.wcpsf-pagination .page-numbers:hover,
.wcpsf-pagination .page-numbers.current {
  background: var(--yellow);
  border-color: var(--yellow);
  color: var(--dark);
}
.wcpsf-pagination .page-numbers.dots {
  border: none;
  background: none;
}

/* ── SEO filter page intro/bottom text ──────────────────────────────────── */
.wcpsf-intro-text {
  margin-bottom: 20px;
  color: var(--text2, #6b7280);
  font-size: 14px;
  line-height: 1.6;
}
.wcpsf-bottom-text {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border, #e5e7eb);
  color: var(--text2, #6b7280);
  font-size: 13px;
  line-height: 1.7;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
/* Note: on mobile the sliding container is #archive-sidebar (theme).
   .wcpsf-filter just fills it — no fixed positioning here. */
@media (max-width: 900px) {
  .wcpsf-filter {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
  }
  body.wcpsf-filter-overlay-active::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 998;
  }
}
