/* ================================================================
   Kaomi Filters — Frontend Styles
   Custom checkboxes, price slider, active chips, loading overlay.
   Designed to extend the existing sidebar-filter-card styles in shop.css.
   ================================================================ */

/* ── Custom Checkboxes ── */
.kf-checkbox-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(123,82,179,0.15) transparent;
  margin-right: -4px !important;
  padding-right: 4px !important;
}
.kf-checkbox-list::-webkit-scrollbar { width: 3px; }
.kf-checkbox-list::-webkit-scrollbar-track { background: transparent; }
.kf-checkbox-list::-webkit-scrollbar-thumb { background: rgba(123,82,179,0.15); border-radius: 3px; }

.kf-checkbox-item { list-style: none !important; }

.kf-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--fs-sm, 0.875rem);
  color: var(--color-text, #1a1a2e);
  user-select: none;
}
.kf-checkbox-label:hover {
  background: rgba(123, 82, 179, 0.06);
  color: var(--color-primary, #7b52b3);
}

/* Hide native checkbox */
.kf-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Custom checkbox mark */
.kf-checkbox-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--color-border, #e5e5f0);
  border-radius: 6px;
  background: var(--color-bg, #fff);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  flex-shrink: 0;
}
.kf-checkbox-mark::after {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  background-color: #fff;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center / contain;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* Checked state */
.kf-checkbox:checked + .kf-checkbox-mark {
  background: var(--color-primary, #7b52b3);
  border-color: var(--color-primary, #7b52b3);
  box-shadow: 0 2px 8px rgba(123, 82, 179, 0.3);
}
.kf-checkbox:checked + .kf-checkbox-mark::after {
  opacity: 1;
  transform: scale(1);
}

/* Checked item row highlight */
.kf-checkbox-item.is-checked .kf-checkbox-label {
  background: rgba(123, 82, 179, 0.08);
  font-weight: 700;
}

/* Focus ring for keyboard nav */
.kf-checkbox:focus-visible + .kf-checkbox-mark {
  outline: 2px solid var(--color-primary, #7b52b3);
  outline-offset: 2px;
}

/* ── Show More / Less Button ── */
.kf-show-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-sm, 0.5rem);
  padding: 0.3rem 0;
  font-size: var(--fs-xs, 0.75rem);
  font-weight: 700;
  color: var(--color-primary, #7b52b3) !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  outline: none;
  cursor: pointer;
  transition: color 0.2s ease, opacity 0.2s ease;
  font-family: inherit;
}
.kf-show-more:hover,
.kf-show-more:focus,
.kf-show-more:active {
  color: var(--color-primary-dark, #5a3a8c) !important;
  background: none !important;
  box-shadow: none !important;
  opacity: 0.85;
}

/* ── Price Range Slider ── */
.kf-price-slider {
  padding: var(--space-sm, 0.5rem) 0;
}

.kf-price-track {
  position: relative;
  height: 6px;
  background: var(--color-bg-alt, #f5f3fa);
  border-radius: 3px;
  margin: 1.2rem 0 1rem;
}

.kf-price-track__fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary, #7b52b3), #a18cd1);
  border-radius: 3px;
  pointer-events: none;
  transition: left 0.05s ease, width 0.05s ease;
}

/* Range inputs — stacked, transparent tracks, both thumbs visible */
.kf-price-input {
  position: absolute;
  top: -8px;
  left: 0;
  width: 100%;
  height: 22px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent !important;
  pointer-events: none;
  margin: 0;
  padding: 0;
  outline: none;
}
/* Min on top by default — JS swaps z-index when dragging near max */
.kf-price-input--min { z-index: 4; }
.kf-price-input--max { z-index: 3; }

/* Track must be fully transparent so thumbs are never hidden */
.kf-price-input::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
}
.kf-price-input::-moz-range-track {
  width: 100%;
  height: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
}

/* Thumb styles — both thumbs must accept pointer events */
.kf-price-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--color-primary, #7b52b3);
  box-shadow: 0 2px 8px rgba(123, 82, 179, 0.25);
  cursor: grab;
  pointer-events: all;
  position: relative;
  margin-top: -8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kf-price-input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(123, 82, 179, 0.35);
}
.kf-price-input::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}
.kf-price-input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--color-primary, #7b52b3);
  box-shadow: 0 2px 8px rgba(123, 82, 179, 0.25);
  cursor: grab;
  pointer-events: all;
}

/* Editable price number inputs */
.kf-price-inputs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 0.25rem;
}
.kf-price-input-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--color-bg-alt, #f5f3fa);
  border: 1px solid #e5e5f0;
  border-radius: 10px;
  padding: 0.3rem 0.6rem;
  flex: 1;
  min-width: 0;
  transition: border-color 0.2s ease;
}
.kf-price-input-group:focus-within {
  border-color: var(--color-primary, #7b52b3);
  box-shadow: 0 0 0 2px rgba(123, 82, 179, 0.1);
}
.kf-price-currency {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted, #6b6b80);
  flex-shrink: 0;
}
.kf-price-number {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-text, #1a1a2e);
  padding: 0.15rem 0;
  outline: none;
  font-family: inherit;
  -moz-appearance: textfield;
}
.kf-price-number::-webkit-outer-spin-button,
.kf-price-number::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.kf-price-sep {
  font-size: var(--fs-sm, 0.875rem);
  color: var(--color-text-muted, #6b6b80);
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Hierarchical Category Indentation ── */
.kf-cat-parent > .kf-checkbox-label {
  font-weight: 700;
}
.kf-cat-child > .kf-checkbox-label {
  font-size: 0.82rem;
  color: #444;
}

/* ── Brand Search Input ── */
.kf-search-wrap {
  margin-bottom: 0.5rem;
}
.kf-search-input {
  width: 100%;
  padding: 0.45rem 0.7rem 0.45rem 2rem;
  border: 1px solid #e5e5f0;
  border-radius: 10px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--color-text, #1a1a2e);
  background: var(--color-bg-alt, #f9f8fc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238c8c9e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 0.6rem center;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.kf-search-input:focus {
  border-color: var(--color-primary, #7b52b3);
  box-shadow: 0 0 0 2px rgba(123, 82, 179, 0.1);
}
.kf-search-input::placeholder {
  color: #aaa;
  font-weight: 500;
}
.kf-checkbox-item.kf-search-hidden {
  display: none !important;
}

/* ── Active Filter Chips ── */
.kf-active-chips {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: var(--space-sm, 0.5rem) 0;
  margin-bottom: var(--space-sm, 0.5rem);
}
.kf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.7rem;
  background: rgba(123, 82, 179, 0.1);
  color: var(--color-primary, #7b52b3);
  border-radius: var(--radius-full, 999px);
  font-size: var(--fs-xs, 0.75rem);
  font-weight: 700;
  animation: chipIn 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
.kf-chip__label {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kf-chip__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: rgba(123, 82, 179, 0.15);
  color: var(--color-primary, #7b52b3);
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  font-family: inherit;
}
.kf-chip__remove:hover {
  background: var(--color-primary, #7b52b3);
  color: #fff;
}
.kf-clear-all {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.8rem;
  background: none;
  border: 1px dashed rgba(123, 82, 179, 0.3);
  color: var(--color-primary, #7b52b3);
  border-radius: var(--radius-full, 999px);
  font-size: var(--fs-xs, 0.75rem);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}
.kf-clear-all:hover {
  background: rgba(123, 82, 179, 0.06);
  border-style: solid;
}

/* ── Loading Overlay ── */
.kf-loading {
  position: relative;
  pointer-events: none;
}
.kf-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 10;
  border-radius: 12px;
  animation: kfPulse 1.2s ease-in-out infinite;
}
@keyframes kfPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.9; }
}

/* ── Product Grid Fade-In ── */
.kf-fade-in {
  animation: kfFadeIn 0.35s ease-out;
}
@keyframes kfFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive: Price slider on mobile drawer ── */
.shop-sidebar-mobile .kf-price-slider {
  padding: var(--space-sm, 0.5rem) 4px;
}

/* ── Avanam Theme Sidebar Integration ── */
.primary-sidebar .kf-sidebar,
.sidebar-inner-wrap .kf-sidebar {
  margin-bottom: 1.5rem;
}
.primary-sidebar .sidebar-filter-card,
.sidebar-inner-wrap .sidebar-filter-card,
.kf-sidebar .sidebar-filter-card {
  background: #fff;
  border: 1px solid #e8e5ef;
  border-radius: 14px;
  padding: 1.2rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.kf-sidebar .sidebar-filter-card__title {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0 0 0.75rem;
  color: #1a1a2e;
  letter-spacing: -0.01em;
}

/* ── Recently Viewed (inside any sidebar) ── */
.kf-sidebar .sidebar-recent-products {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.kf-sidebar .sidebar-recent-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  padding: 0.4rem;
  border-radius: 10px;
  transition: background 0.2s ease;
}
.kf-sidebar .sidebar-recent-item:hover {
  background: rgba(123, 82, 179, 0.05);
}
.kf-sidebar .sidebar-recent-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.kf-sidebar .sidebar-recent-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.kf-sidebar .sidebar-recent-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1a1a2e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kf-sidebar .sidebar-recent-price {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--color-primary, #7b52b3);
}

/* ── Filter count badges ── */
.kf-sidebar .filter-count {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  color: #8c8c9e;
  background: #f5f3fa;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.kf-sidebar .filter-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Inline Filter Toggle (no-sidebar layout) ── */
.kf-inline-filters-wrap {
  margin-bottom: 1rem;
}
.kf-inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.6rem 1.2rem;
  background: #fff;
  border: 2px solid var(--color-primary, #7b52b3);
  color: var(--color-primary, #7b52b3);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}
.kf-inline-toggle:hover,
.kf-inline-toggle.is-open {
  background: var(--color-primary, #7b52b3);
  color: #fff;
}
.kf-inline-toggle__icon {
  font-size: 1.1rem;
}
.kf-inline-filters {
  margin-top: 1rem;
  padding: 1.5rem;
  background: #fff;
  border: 1px solid #e8e5ef;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.kf-inline-filters .kf-sidebar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.kf-inline-filters .sidebar-filter-card {
  margin-bottom: 0;
}

/* ── Mobile Filter Drawer (Avanam popup) ── */
#filter-drawer .drawer-inner {
  background: #fff !important;
  color: #1a1a2e !important;
}
#filter-drawer .drawer-header .drawer-toggle {
  color: #1a1a2e !important;
}
#filter-drawer .kf-sidebar {
  padding: 0;
}
#filter-drawer .kf-sidebar .sidebar-filter-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid #eee;
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 0;
  padding: 1rem 0;
}
#filter-drawer .kf-sidebar .sidebar-filter-card:last-child {
  border-bottom: none;
}
#filter-drawer .kf-sidebar .sidebar-filter-card__title {
  color: #1a1a2e;
}
#filter-drawer .kf-sidebar .kf-checkbox-label {
  color: #333;
}
#filter-drawer .kf-sidebar .filter-name {
  color: #333;
}
#filter-drawer .kf-sidebar .kf-checkbox-mark {
  border-color: #ccc;
}
#filter-drawer .kf-sidebar .kf-search-input {
  background-color: #f5f3fa;
  border-color: #e5e5f0;
  color: #1a1a2e;
}
#filter-drawer .kf-sidebar .kf-search-input::placeholder {
  color: #aaa;
}
#filter-drawer .kf-sidebar .kf-price-input-group {
  background: #f5f3fa;
  border-color: #e5e5f0;
}
#filter-drawer .kf-sidebar .kf-price-number,
#filter-drawer .kf-sidebar .kf-price-currency,
#filter-drawer .kf-sidebar .kf-price-sep {
  color: #1a1a2e;
}
#filter-drawer .kf-sidebar .kf-show-more {
  color: var(--color-primary, #7b52b3);
}

/* ── Custom CSS from admin ── */
/* Injected via wp_add_inline_style in kaomi-filters.php */

