/*
 * WC ACF Filter — filter.css
 * Prefix: .wcaf-
 * Không dùng !important trừ overrides cần thiết.
 * CSS custom properties cho theming.
 */

/* ── Variables ────────────────────────────────────────────────────────── */
:root {
  --wcaf-accent:        #2271b1;
  --wcaf-accent-light:  #2271b122;
  --wcaf-accent-hover:  #135e96;
  --wcaf-radius:        8px;
  --wcaf-radius-sm:     4px;
  --wcaf-shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --wcaf-shadow-md:     0 4px 12px rgba(0,0,0,.12);
  --wcaf-bg:            #ffffff;
  --wcaf-bg-alt:        #f6f7f8;
  --wcaf-border:        #e2e5e9;
  --wcaf-text:          #1a1f2e;
  --wcaf-text-muted:    #6b7280;
  --wcaf-font:          inherit;
  --wcaf-transition:    0.2s ease;
  --wcaf-card-radius:   10px;
}

/* ── Screen reader only ───────────────────────────────────────────────── */
.wcaf-sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* ══════════════════════════════════════════════════════════════════════
   FILTER FORM
══════════════════════════════════════════════════════════════════════ */

.wcaf-filter {
  font-family: var(--wcaf-font);
  color: var(--wcaf-text);
  position: relative;
}

/* Mobile toggle button */
.wcaf-filter__mobile-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--wcaf-accent);
  color: #fff;
  border: none;
  border-radius: var(--wcaf-radius);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--wcaf-transition);
}
.wcaf-filter__mobile-toggle:hover { background: var(--wcaf-accent-hover); }

.wcaf-filter__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--wcaf-accent);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
}

/* Filter body */
.wcaf-filter__body {
  background: var(--wcaf-bg);
  border: 1px solid var(--wcaf-border);
  border-radius: var(--wcaf-radius);
  overflow: hidden;
}

.wcaf-filter__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--wcaf-border);
  background: var(--wcaf-bg-alt);
}

.wcaf-filter__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--wcaf-text);
}

/* Filter group (accordion item) */
.wcaf-filter__group {
  border-bottom: 1px solid var(--wcaf-border);
}
.wcaf-filter__group:last-child { border-bottom: none; }

.wcaf-filter__group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--wcaf-text);
  cursor: pointer;
  text-align: left;
  transition: background var(--wcaf-transition);
}
.wcaf-filter__group-toggle:hover { background: var(--wcaf-bg-alt); }

.wcaf-chevron {
  transition: transform var(--wcaf-transition);
  flex-shrink: 0;
  color: var(--wcaf-text-muted);
}
.wcaf-filter__group-toggle[aria-expanded="false"] .wcaf-chevron {
  transform: rotate(180deg);
}

.wcaf-filter__group-body {
  padding: 4px 20px 16px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.wcaf-filter__group-body.wcaf-collapsed { max-height: 0 !important; padding-bottom: 0; }

/* Apply button (mobile only) */
.wcaf-filter__apply {
  padding: 16px 20px;
  border-top: 1px solid var(--wcaf-border);
  display: none;
}

/* Overlay (mobile drawer backdrop) */
.wcaf-filter__overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s;
}
.wcaf-filter__overlay--visible {
  display: block;
  opacity: 1;
}

/* ── Price slider ─────────────────────────────────────────────────────── */
.wcaf-price-slider-wrap { padding-top: 24px; }

.wcaf-price-slider {
  margin: 0 8px 20px;
}

/* noUiSlider custom styles */
.noUi-target {
  background: var(--wcaf-border);
  border: none;
  box-shadow: none;
  border-radius: 4px;
  height: 4px;
}
.noUi-connect {
  background: var(--wcaf-accent);
  border-radius: 4px;
}
.noUi-handle {
  background: #fff;
  border: 2px solid var(--wcaf-accent);
  border-radius: 50%;
  box-shadow: var(--wcaf-shadow);
  width: 18px !important;
  height: 18px !important;
  top: -7px !important;
  right: -9px !important;
  cursor: grab;
  transition: transform var(--wcaf-transition);
}
.noUi-handle:active { cursor: grabbing; transform: scale(1.15); }
.noUi-handle::before, .noUi-handle::after { display: none; }
.noUi-tooltip {
  background: var(--wcaf-text);
  color: #fff;
  border: none;
  border-radius: var(--wcaf-radius-sm);
  font-size: 11px;
  padding: 3px 7px;
  white-space: nowrap;
}

.wcaf-price-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wcaf-price-input-group {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  border: 1px solid var(--wcaf-border);
  border-radius: var(--wcaf-radius-sm);
  overflow: hidden;
  background: var(--wcaf-bg);
  transition: border-color var(--wcaf-transition);
}
.wcaf-price-input-group:focus-within { border-color: var(--wcaf-accent); }

.wcaf-price-input-prefix {
  padding: 0 8px;
  color: var(--wcaf-text-muted);
  font-size: 13px;
  white-space: nowrap;
  background: var(--wcaf-bg-alt);
  border-right: 1px solid var(--wcaf-border);
  line-height: 34px;
}
.wcaf-price-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--wcaf-text);
  min-width: 0;
  outline: none;
  -moz-appearance: textfield;
}
.wcaf-price-input::-webkit-outer-spin-button,
.wcaf-price-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.wcaf-price-sep { color: var(--wcaf-text-muted); font-weight: 600; flex-shrink: 0; }

/* ── Checkbox list ────────────────────────────────────────────────────── */
.wcaf-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.wcaf-checkbox-list::-webkit-scrollbar { width: 4px; }
.wcaf-checkbox-list::-webkit-scrollbar-track { background: var(--wcaf-bg-alt); border-radius: 4px; }
.wcaf-checkbox-list::-webkit-scrollbar-thumb { background: var(--wcaf-border); border-radius: 4px; }

.wcaf-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--wcaf-radius-sm);
  cursor: pointer;
  transition: background var(--wcaf-transition);
  font-size: 14px;
}
.wcaf-checkbox-item:hover { background: var(--wcaf-bg-alt); }

.wcaf-checkbox-item input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--wcaf-accent);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Radio list ───────────────────────────────────────────────────────── */
.wcaf-radio-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wcaf-radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--wcaf-radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--wcaf-transition);
}
.wcaf-radio-item:hover { background: var(--wcaf-bg-alt); }
.wcaf-radio-item input[type="radio"] {
  accent-color: var(--wcaf-accent);
  width: 15px; height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Select ───────────────────────────────────────────────────────────── */
.wcaf-select {
  width: 100%;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--wcaf-border);
  border-radius: var(--wcaf-radius-sm);
  background: var(--wcaf-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  -webkit-appearance: none;
  appearance: none;
  font-size: 14px;
  color: var(--wcaf-text);
  cursor: pointer;
  transition: border-color var(--wcaf-transition);
  outline: none;
}
.wcaf-select:focus { border-color: var(--wcaf-accent); }

/* ── Toggle (true/false) ──────────────────────────────────────────────── */
.wcaf-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 4px 0;
}
.wcaf-toggle input[type="checkbox"] { display: none; }

.wcaf-toggle__track {
  position: relative;
  width: 42px; height: 22px;
  background: var(--wcaf-border);
  border-radius: 11px;
  transition: background var(--wcaf-transition);
  flex-shrink: 0;
}
.wcaf-toggle input:checked ~ .wcaf-toggle__track { background: var(--wcaf-accent); }

.wcaf-toggle__thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--wcaf-shadow);
  transition: transform var(--wcaf-transition);
}
.wcaf-toggle input:checked ~ .wcaf-toggle__track .wcaf-toggle__thumb {
  transform: translateX(20px);
}
.wcaf-toggle__label { font-size: 14px; color: var(--wcaf-text); }

/* ── Text search ──────────────────────────────────────────────────────── */
.wcaf-text-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--wcaf-border);
  border-radius: var(--wcaf-radius-sm);
  font-size: 14px;
  color: var(--wcaf-text);
  background: var(--wcaf-bg);
  transition: border-color var(--wcaf-transition);
  outline: none;
  box-sizing: border-box;
}
.wcaf-text-input:focus { border-color: var(--wcaf-accent); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.wcaf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--wcaf-radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--wcaf-transition);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.wcaf-btn--primary {
  background: var(--wcaf-accent);
  color: #fff;
  border-color: var(--wcaf-accent);
}
.wcaf-btn--primary:hover { background: var(--wcaf-accent-hover); border-color: var(--wcaf-accent-hover); }
.wcaf-btn--reset {
  background: transparent;
  color: var(--wcaf-accent);
  border-color: var(--wcaf-accent);
  font-size: 13px;
  padding: 5px 12px;
}
.wcaf-btn--reset:hover { background: var(--wcaf-accent-light); }
.wcaf-btn--sm { font-size: 12px; padding: 4px 10px; }
.wcaf-btn--full { width: 100%; }

/* ══════════════════════════════════════════════════════════════════════
   ACTIVE FILTERS
══════════════════════════════════════════════════════════════════════ */
.wcaf-active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
}
.wcaf-active-filters__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--wcaf-text-muted);
  white-space: nowrap;
}
.wcaf-active-filters__tags { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }

.wcaf-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--wcaf-accent-light);
  color: var(--wcaf-accent);
  border: 1px solid var(--wcaf-accent);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--wcaf-transition);
}
.wcaf-tag:hover { background: var(--wcaf-accent); color: #fff; }
.wcaf-tag__remove { font-size: 11px; opacity: .7; }

/* ══════════════════════════════════════════════════════════════════════
   RESULTS AREA
══════════════════════════════════════════════════════════════════════ */
.wcaf-results { position: relative; }

/* Toolbar */
.wcaf-results__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--wcaf-border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.wcaf-results__count {
  font-size: 14px;
  color: var(--wcaf-text-muted);
  font-weight: 500;
}
.wcaf-select--sort { width: auto; min-width: 180px; }

/* ── Product grid ─────────────────────────────────────────────────────── */
.wcaf-product-grid {
  display: grid;
  gap: 20px;
}
.wcaf-cols-1 { grid-template-columns: 1fr; }
.wcaf-cols-2 { grid-template-columns: repeat(2, 1fr); }
.wcaf-cols-3 { grid-template-columns: repeat(3, 1fr); }
.wcaf-cols-4 { grid-template-columns: repeat(4, 1fr); }
.wcaf-cols-5 { grid-template-columns: repeat(5, 1fr); }
.wcaf-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* ── Product card ─────────────────────────────────────────────────────── */
.wcaf-card {
  background: var(--wcaf-bg);
  border: 1px solid var(--wcaf-border);
  border-radius: var(--wcaf-card-radius);
  overflow: hidden;
  transition: box-shadow var(--wcaf-transition), transform var(--wcaf-transition);
  display: flex;
  flex-direction: column;
}
.wcaf-card:hover {
  box-shadow: var(--wcaf-shadow-md);
  transform: translateY(-2px);
}
.wcaf-card--oos { opacity: .7; }

.wcaf-card__thumb-link { display: block; }
.wcaf-card__thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--wcaf-bg-alt);
}
.wcaf-card__thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
  display: block;
}
.wcaf-card:hover .wcaf-card__thumb img { transform: scale(1.04); }

.wcaf-card__badges {
  position: absolute;
  top: 10px; left: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.wcaf-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.wcaf-badge--sale { background: #ef4444; color: #fff; }
.wcaf-badge--oos  { background: #6b7280; color: #fff; }

.wcaf-card__body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.wcaf-card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wcaf-card__title a {
  color: var(--wcaf-text);
  text-decoration: none;
  transition: color var(--wcaf-transition);
}
.wcaf-card__title a:hover { color: var(--wcaf-accent); }

.wcaf-card__price {
  font-size: 15px;
  font-weight: 700;
  color: var(--wcaf-accent);
}
.wcaf-card__price del { color: var(--wcaf-text-muted); font-weight: 400; font-size: 13px; margin-right: 4px; }

.wcaf-card__cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  padding: 8px 14px;
  background: var(--wcaf-accent);
  color: #fff;
  border-radius: var(--wcaf-radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background var(--wcaf-transition);
  cursor: pointer;
  border: none;
}
.wcaf-card__cart:hover { background: var(--wcaf-accent-hover); color: #fff; }
.wcaf-card__cart--detail { background: transparent; color: var(--wcaf-accent); border: 1px solid var(--wcaf-accent); }
.wcaf-card__cart--detail:hover { background: var(--wcaf-accent); color: #fff; }

/* ── No results ───────────────────────────────────────────────────────── */
.wcaf-no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--wcaf-text-muted);
}
.wcaf-no-results__icon { font-size: 48px; display: block; margin-bottom: 12px; }
.wcaf-no-results p { font-size: 16px; margin-bottom: 20px; }

/* ── Skeleton loader ──────────────────────────────────────────────────── */
@keyframes wcaf-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.wcaf-skeleton-card {
  border: 1px solid var(--wcaf-border);
  border-radius: var(--wcaf-card-radius);
  overflow: hidden;
}
.wcaf-skeleton-img {
  aspect-ratio: 1;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 400px 100%;
  animation: wcaf-shimmer 1.2s infinite linear;
}
.wcaf-skeleton-line {
  margin: 10px 16px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 400px 100%;
  animation: wcaf-shimmer 1.2s infinite linear;
}
.wcaf-skeleton-line--title { height: 16px; width: 80%; }
.wcaf-skeleton-line--price { height: 20px; width: 50%; }
.wcaf-skeleton-line--btn   { height: 34px; width: 90%; margin-bottom: 16px; }

/* ── Loading overlay ──────────────────────────────────────────────────── */
.wcaf-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
  z-index: 10;
  pointer-events: none;
}
.wcaf-loading__spinner {
  background: var(--wcaf-bg);
  border-radius: 50%;
  padding: 10px;
  box-shadow: var(--wcaf-shadow-md);
  animation: wcaf-spin 0.8s linear infinite;
}
.wcaf-loading__spinner svg { display: block; color: var(--wcaf-accent); }
@keyframes wcaf-spin { to { transform: rotate(360deg); } }

/* ── Pagination ───────────────────────────────────────────────────────── */
.wcaf-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.wcaf-pagination__pages { display: flex; align-items: center; gap: 4px; }

.wcaf-page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--wcaf-radius-sm);
  border: 1px solid var(--wcaf-border);
  background: var(--wcaf-bg);
  color: var(--wcaf-text);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--wcaf-transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}
.wcaf-page-btn:hover:not([disabled]) {
  border-color: var(--wcaf-accent);
  color: var(--wcaf-accent);
  background: var(--wcaf-accent-light);
}
.wcaf-page-btn--active {
  background: var(--wcaf-accent);
  color: #fff;
  border-color: var(--wcaf-accent);
  font-weight: 700;
}
.wcaf-page-btn[disabled] { opacity: .4; cursor: default; }
.wcaf-page-btn--prev, .wcaf-page-btn--next { padding: 0 14px; }
.wcaf-pagination__ellipsis { color: var(--wcaf-text-muted); padding: 0 4px; }

/* ── Body lock when drawer open ───────────────────────────────────────── */
body.wcaf-drawer-open { overflow: hidden; }

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════════ */

/* Large desktop: 5+ cols → 4 max */
@media (max-width: 1200px) {
  .wcaf-cols-5 { grid-template-columns: repeat(4, 1fr); }
  .wcaf-cols-6 { grid-template-columns: repeat(4, 1fr); }
}

/* Tablet landscape */
@media (max-width: 1024px) {
  .wcaf-cols-4 { grid-template-columns: repeat(3, 1fr); }
  .wcaf-cols-5 { grid-template-columns: repeat(3, 1fr); }
  .wcaf-cols-6 { grid-template-columns: repeat(3, 1fr); }
}

/* Tablet portrait */
@media (max-width: 768px) {
  .wcaf-cols-3,
  .wcaf-cols-4,
  .wcaf-cols-5,
  .wcaf-cols-6 { grid-template-columns: repeat(2, 1fr); }

  .wcaf-product-grid { gap: 14px; }

  /* Show mobile toggle, hide filter body by default */
  .wcaf-filter__mobile-toggle {
    display: inline-flex;
    margin-bottom: 12px;
  }
  .wcaf-filter__body {
    position: fixed;
    top: 0; left: 0;
    width: min(320px, 90vw);
    height: 100%;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    border-radius: 0;
    border: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .wcaf-filter__body--open {
    transform: translateX(0);
    box-shadow: var(--wcaf-shadow-md);
  }
  .wcaf-filter__apply { display: block; }

  .wcaf-results__toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .wcaf-select--sort { width: 100%; }
}

/* Mobile */
@media (max-width: 480px) {
  .wcaf-cols-2,
  .wcaf-cols-3,
  .wcaf-cols-4,
  .wcaf-cols-5,
  .wcaf-cols-6 { grid-template-columns: repeat(2, 1fr); }

  .wcaf-cols-1 { grid-template-columns: 1fr; }

  .wcaf-product-grid { gap: 10px; }

  .wcaf-card__body { padding: 10px 12px 12px; }
  .wcaf-card__title { font-size: 13px; }
  .wcaf-card__price { font-size: 14px; }
  .wcaf-card__cart { font-size: 12px; padding: 7px 10px; }

  .wcaf-pagination { gap: 4px; }
  .wcaf-page-btn { min-width: 34px; height: 34px; font-size: 13px; }

  .wcaf-active-filters {
    flex-direction: column;
    align-items: flex-start;
  }
}
