/**
 * SuperFilter Pro - Frontend Styles
 * Modern, responsive, high-performance styling with theme presets
 */

:root {
  --wcpf-accent: #3b82f6;
  --wcpf-accent-hover: #2563eb;
  --wcpf-accent-light: rgba(59, 130, 246, 0.12);
  --wcpf-text: #1e293b;
  --wcpf-text-muted: #64748b;
  --wcpf-border: #e2e8f0;
  --wcpf-bg: #ffffff;
  --wcpf-card-bg: #ffffff;
  --wcpf-slider-track: #e2e8f0;
  --wcpf-radius: 8px;
  --wcpf-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --wcpf-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme: Dark Mode */
.wcpf-theme-dark {
  --wcpf-accent: #60a5fa;
  --wcpf-accent-hover: #93c5fd;
  --wcpf-accent-light: rgba(96, 165, 250, 0.18);
  --wcpf-text: #f8fafc;
  --wcpf-text-muted: #94a3b8;
  --wcpf-border: #334155;
  --wcpf-bg: #0f172a;
  --wcpf-card-bg: #1e293b;
  --wcpf-slider-track: #334155;
  --wcpf-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

/* Theme: Glassmorphism */
.wcpf-theme-glass {
  --wcpf-accent: #6366f1;
  --wcpf-accent-hover: #4f46e5;
  --wcpf-accent-light: rgba(99, 102, 241, 0.15);
  --wcpf-text: #1e1b4b;
  --wcpf-text-muted: #475569;
  --wcpf-border: rgba(255, 255, 255, 0.5);
  --wcpf-bg: rgba(255, 255, 255, 0.65);
  --wcpf-card-bg: rgba(255, 255, 255, 0.75);
  --wcpf-slider-track: rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.08);
}

/* Theme: Luxury Gold */
.wcpf-theme-luxury {
  --wcpf-accent: #d97706;
  --wcpf-accent-hover: #b45309;
  --wcpf-accent-light: rgba(217, 119, 6, 0.14);
  --wcpf-text: #27272a;
  --wcpf-text-muted: #71717a;
  --wcpf-border: #e4e4e7;
  --wcpf-bg: #fdfbf7;
  --wcpf-card-bg: #ffffff;
  --wcpf-slider-track: #e4e4e7;
  --wcpf-radius: 4px;
}

/* Theme: Minimalist */
.wcpf-theme-minimal {
  --wcpf-accent: #18181b;
  --wcpf-accent-hover: #27272a;
  --wcpf-accent-light: rgba(24, 24, 27, 0.08);
  --wcpf-text: #18181b;
  --wcpf-text-muted: #71717a;
  --wcpf-border: #f4f4f5;
  --wcpf-bg: transparent;
  --wcpf-card-bg: transparent;
  --wcpf-slider-track: #e4e4e7;
  --wcpf-radius: 0px;
  --wcpf-shadow: none;
}

/* Base Wrapper */
.wcpf-filter-wrapper {
  box-sizing: border-box;
  font-family: inherit;
  color: var(--wcpf-text);
  background-color: var(--wcpf-bg);
  border-radius: var(--wcpf-radius);
  margin-bottom: 2rem;
  position: relative;
}

.wcpf-filter-wrapper *,
.wcpf-filter-wrapper *::before,
.wcpf-filter-wrapper *::after {
  box-sizing: border-box;
}

/* Filter Inner Container */
.wcpf-filter-inner {
  background-color: var(--wcpf-card-bg);
  border: 1px solid var(--wcpf-border);
  border-radius: var(--wcpf-radius);
  padding: 1.5rem;
  box-shadow: var(--wcpf-shadow);
}

/* Header */
.wcpf-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--wcpf-border);
}

.wcpf-filter-main-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--wcpf-text);
  letter-spacing: -0.01em;
}

.wcpf-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wcpf-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--wcpf-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--wcpf-radius);
  transition: var(--wcpf-transition);
}

.wcpf-reset-btn:hover {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.08);
}

.wcpf-drawer-close {
  display: none;
  background: none;
  border: none;
  color: var(--wcpf-text);
  cursor: pointer;
  padding: 0.25rem;
}

/* Active Filter Pills */
.wcpf-active-pills {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--wcpf-border);
}

.wcpf-pills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wcpf-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--wcpf-accent);
  background: var(--wcpf-accent-light);
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--wcpf-transition);
}

.wcpf-pill:hover {
  background: var(--wcpf-accent);
  color: #ffffff;
}

.wcpf-pill-remove {
  font-size: 1.1rem;
  line-height: 1;
  display: inline-block;
  opacity: 0.7;
}

.wcpf-pill:hover .wcpf-pill-remove {
  opacity: 1;
}

/* Filter Item Block */
.wcpf-item {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--wcpf-border);
}

.wcpf-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Accordion Header */
.wcpf-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0;
}

.wcpf-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--wcpf-text);
}

.wcpf-item-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wcpf-text-muted);
  transition: transform 0.25s ease;
}

.wcpf-item-open .wcpf-item-toggle svg {
  transform: rotate(180deg);
}

.wcpf-item-collapsed .wcpf-item-content {
  display: none;
}

.wcpf-item-content {
  padding-top: 0.85rem;
}

/* Dual Range Slider Component */
.wcpf-dual-slider {
  position: relative;
  height: 24px;
  margin: 1rem 0.5rem 1.2rem;
}

.wcpf-slider-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 6px;
  transform: translateY(-50%);
  background-color: var(--wcpf-slider-track);
  border-radius: 9999px;
  pointer-events: none;
}

.wcpf-slider-highlight {
  position: absolute;
  height: 100%;
  background-color: var(--wcpf-accent);
  border-radius: 9999px;
  pointer-events: none;
}

.wcpf-dual-slider input[type="range"] {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  transform: translateY(-50%);
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  pointer-events: none;
  margin: 0;
  outline: none;
}

.wcpf-dual-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--wcpf-accent);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wcpf-dual-slider input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 6px var(--wcpf-accent-light);
}

.wcpf-dual-slider input[type="range"]::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--wcpf-accent);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s ease;
}

/* Number Inputs */
.wcpf-price-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wcpf-input-group {
  display: flex;
  align-items: center;
  flex: 1;
  background-color: var(--wcpf-bg);
  border: 1px solid var(--wcpf-border);
  border-radius: var(--wcpf-radius);
  overflow: hidden;
  transition: var(--wcpf-transition);
}

.wcpf-input-group:focus-within {
  border-color: var(--wcpf-accent);
  box-shadow: 0 0 0 3px var(--wcpf-accent-light);
}

.wcpf-input-affix {
  padding: 0 0.5rem;
  font-size: 0.8rem;
  color: var(--wcpf-text-muted);
  user-select: none;
}

.wcpf-price-input-min,
.wcpf-price-input-max {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.4rem 0.25rem;
  font-size: 0.85rem;
  color: var(--wcpf-text);
  outline: none;
}

.wcpf-input-sep {
  color: var(--wcpf-text-muted);
  font-weight: 500;
}

/* Preset Radio Buckets */
.wcpf-price-presets {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wcpf-preset-radio {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  background-color: var(--wcpf-bg);
  border: 1px solid var(--wcpf-border);
  border-radius: var(--wcpf-radius);
  cursor: pointer;
  transition: var(--wcpf-transition);
  font-size: 0.85rem;
}

.wcpf-preset-radio:hover {
  border-color: var(--wcpf-accent);
}

.wcpf-preset-radio.is-active {
  background-color: var(--wcpf-accent-light);
  border-color: var(--wcpf-accent);
  color: var(--wcpf-accent);
  font-weight: 600;
}

.wcpf-preset-radio input {
  margin-right: 0.5rem;
}

/* Options Lists (Checkboxes & Radios) */
.wcpf-options-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.wcpf-options-list::-webkit-scrollbar {
  width: 5px;
}
.wcpf-options-list::-webkit-scrollbar-thumb {
  background: var(--wcpf-border);
  border-radius: 4px;
}

.wcpf-option-item {
  margin-bottom: 0.35rem;
}

.wcpf-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.875rem;
  color: var(--wcpf-text);
  cursor: pointer;
  padding: 0.25rem 0;
  user-select: none;
  transition: var(--wcpf-transition);
}

.wcpf-checkbox-label:hover {
  color: var(--wcpf-accent);
}

.wcpf-checkbox-label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wcpf-custom-indicator {
  position: relative;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--wcpf-border);
  border-radius: 4px;
  background-color: var(--wcpf-bg);
  flex-shrink: 0;
  transition: var(--wcpf-transition);
}

.wcpf-checkbox-label input[type="radio"] ~ .wcpf-custom-indicator {
  border-radius: 50%;
}

.wcpf-checkbox-label input:checked ~ .wcpf-custom-indicator {
  background-color: var(--wcpf-accent);
  border-color: var(--wcpf-accent);
}

.wcpf-checkbox-label input:checked ~ .wcpf-custom-indicator::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.wcpf-checkbox-label input[type="radio"]:checked ~ .wcpf-custom-indicator::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  transform: none;
}

.wcpf-term-name {
  flex: 1;
}

.wcpf-count {
  font-size: 0.78rem;
  color: var(--wcpf-text-muted);
}

/* Tree / Hierarchy */
.wcpf-children-list {
  list-style: none;
  margin: 0.25rem 0 0 1.25rem;
  padding: 0;
  border-left: 1.5px solid var(--wcpf-border);
  padding-left: 0.65rem;
}

/* Attribute: Color Swatches */
.wcpf-display-color {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.wcpf-swatch-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  position: relative;
}

.wcpf-swatch-label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wcpf-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--wcpf-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wcpf-check-icon {
  display: none;
  color: #ffffff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

.wcpf-swatch-label:hover .wcpf-color-swatch {
  transform: scale(1.15);
}

.wcpf-swatch-label input:checked ~ .wcpf-color-swatch {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--wcpf-accent);
}

.wcpf-swatch-label input:checked ~ .wcpf-color-swatch .wcpf-check-icon {
  display: block;
}

.wcpf-swatch-name {
  font-size: 0.8rem;
  color: var(--wcpf-text);
}

/* Attribute: Badges / Buttons (Sizes, Tags) */
.wcpf-display-badge {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wcpf-badge-label {
  cursor: pointer;
}

.wcpf-badge-label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wcpf-badge-btn {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--wcpf-border);
  border-radius: var(--wcpf-radius);
  background-color: var(--wcpf-bg);
  color: var(--wcpf-text);
  transition: var(--wcpf-transition);
}

.wcpf-badge-label:hover .wcpf-badge-btn {
  border-color: var(--wcpf-accent);
  color: var(--wcpf-accent);
}

.wcpf-badge-label input:checked ~ .wcpf-badge-btn {
  background-color: var(--wcpf-accent);
  border-color: var(--wcpf-accent);
  color: #ffffff;
  font-weight: 600;
}

/* Toggle Switches (In Stock, On Sale, ACF Boolean) */
.wcpf-switch-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.wcpf-toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.wcpf-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.wcpf-slider-switch {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--wcpf-slider-track);
  border-radius: 34px;
  transition: 0.3s;
}

.wcpf-slider-switch::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: 0.3s;
}

.wcpf-toggle-switch input:checked + .wcpf-slider-switch {
  background-color: var(--wcpf-accent);
}

.wcpf-toggle-switch input:checked + .wcpf-slider-switch::before {
  transform: translateX(18px);
}

.wcpf-toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--wcpf-text);
}

/* Star Rating */
.wcpf-rating-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wcpf-rating-item {
  margin-bottom: 0.35rem;
}

.wcpf-rating-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.25rem 0;
}

.wcpf-rating-label input {
  position: absolute;
  opacity: 0;
}

.wcpf-stars {
  display: flex;
  gap: 2px;
  color: #d1d5db;
}

.wcpf-star-icon.filled {
  color: #f59e0b;
}

.wcpf-rating-text {
  font-size: 0.82rem;
  color: var(--wcpf-text-muted);
}

.wcpf-rating-label.is-active .wcpf-rating-text {
  font-weight: 600;
  color: var(--wcpf-accent);
}

/* Live Search Box */
.wcpf-live-search-box {
  display: flex;
  align-items: center;
  position: relative;
  background: var(--wcpf-bg);
  border: 1px solid var(--wcpf-border);
  border-radius: var(--wcpf-radius);
  padding: 0.35rem 0.65rem;
  gap: 0.4rem;
}

.wcpf-search-icon {
  color: var(--wcpf-text-muted);
}

.wcpf-search-input {
  border: none;
  background: transparent;
  width: 100%;
  font-size: 0.875rem;
  outline: none;
  color: var(--wcpf-text);
}

.wcpf-clear-search-btn {
  background: none;
  border: none;
  color: var(--wcpf-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
}

/* In-Filter Term Search Box */
.wcpf-search-box {
  margin-bottom: 0.65rem;
}

.wcpf-term-search-input {
  width: 100%;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  border: 1px solid var(--wcpf-border);
  border-radius: var(--wcpf-radius);
  background: var(--wcpf-bg);
  outline: none;
}

.wcpf-term-search-input:focus {
  border-color: var(--wcpf-accent);
}

/* Layout: Horizontal Filter Bar */
.wcpf-layout-horizontal .wcpf-filter-items {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.wcpf-layout-horizontal .wcpf-item {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
  flex: 1 1 200px;
  min-width: 180px;
}

/* Mobile Trigger & Floating Button */
.wcpf-mobile-trigger {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: var(--wcpf-accent);
  color: #ffffff;
  border: none;
  border-radius: var(--wcpf-radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  margin-bottom: 1rem;
}

.wcpf-mobile-footer {
  display: none;
  margin-top: 1.5rem;
}

.wcpf-mobile-apply-btn {
  width: 100%;
  padding: 0.85rem;
  background: var(--wcpf-accent);
  color: #ffffff;
  border: none;
  border-radius: var(--wcpf-radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

/* Loading Overlay for WooCommerce Product Container */
.wcpf-loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border-radius: var(--wcpf-radius);
}

.wcpf-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--wcpf-border);
  border-top-color: var(--wcpf-accent);
  border-radius: 50%;
  animation: wcpf-spin 0.75s infinite linear;
}

@keyframes wcpf-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Mobile Drawer */
@media (max-width: 768px) {
  .wcpf-mobile-trigger {
    display: inline-flex;
  }

  .wcpf-filter-wrapper.wcpf-drawer-open .wcpf-filter-inner {
    transform: translateX(0);
  }

  .wcpf-filter-wrapper.wcpf-drawer-open .wcpf-drawer-backdrop {
    display: block;
    opacity: 1;
  }

  .wcpf-filter-inner {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 360px;
    z-index: 99999;
    overflow-y: auto;
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }

  .wcpf-drawer-close {
    display: block;
  }

  .wcpf-mobile-footer {
    display: block;
  }

  .wcpf-drawer-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
}
