/**
 * LM Archive Filters - Styles
 * Modern, minimal design for high-end jewellery brand
 * BEM methodology with CSS custom properties for easy theming
 */

/* ===== CSS Custom Properties (Theme Variables) ===== */
.lm-archive-filters {
  /* Colors */
  --lm-filters-bg: #f8f8f8;
  --lm-card-bg: #ffffff;
  --lm-border-color: #e4e4e7;
  --lm-text-primary: #21232a;
  --lm-text-muted: #9a9da4;
  --lm-active-bg: #111318;
  --lm-active-text: #ffffff;
  --lm-hover-shadow: rgba(0, 0, 0, 0.08);

  /* Spacing */
  --lm-spacing-xs: 8px;
  --lm-spacing-sm: 12px;
  --lm-spacing-md: 16px;
  --lm-spacing-lg: 24px;
  --lm-spacing-xl: 32px;

  /* Border radius */
  --lm-radius-sm: 12px;
  --lm-radius-md: 18px;
  --lm-radius-lg: 24px;
  --lm-pill-radius: 999px;

  /* Transitions */
  --lm-transition: 0.15s ease;
  --lm-transition-slow: 0.25s ease;

  /* Shadows */
  --lm-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --lm-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --lm-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* ===== Base Wrapper ===== */
.lm-archive-filters {
  width: 100%;
  margin: 0 0 var(--lm-spacing-xl) 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Synthese', 'Segoe UI', sans-serif;
  color: var(--lm-text-primary);
}

.lm-archive-filters.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ===== Toolbar ===== */
.lm-archive-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lm-spacing-lg);
  padding: var(--lm-spacing-md) var(--lm-spacing-lg);
  background: var(--lm-card-bg);
  border: 1px solid var(--lm-border-color);
  border-radius: var(--lm-radius-lg);
  box-shadow: var(--lm-shadow-sm);
}

.lm-toolbar__left {
  display: flex;
  align-items: center;
  gap: var(--lm-spacing-lg);
  flex: 1;
}

.lm-toolbar__filters-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--lm-spacing-xs);
  padding: 10px 18px;
  background: var(--lm-filters-bg);
  border: 1px solid var(--lm-border-color);
  border-radius: var(--lm-pill-radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--lm-text-primary);
  cursor: pointer;
  transition: all var(--lm-transition);
}

.lm-toolbar__filters-btn:hover {
  background: var(--lm-text-primary);
  color: var(--lm-active-text);
  box-shadow: var(--lm-shadow-md);
  transform: translateY(-1px);
}

.lm-toolbar__filters-btn svg {
  width: 16px;
  height: 16px;
}

.lm-toolbar__helper {
  font-size: 14px;
  color: var(--lm-text-muted);
  display: none;
}

.lm-toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--lm-spacing-sm);
}

.lm-toolbar__sort-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lm-text-muted);
}

.lm-toolbar__sort-select {
  padding: 10px 18px;
  background: var(--lm-card-bg);
  border: 1px solid var(--lm-border-color);
  border-radius: var(--lm-pill-radius);
  font-size: 14px;
  color: var(--lm-text-primary);
  cursor: pointer;
  transition: all var(--lm-transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2321232a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.lm-toolbar__sort-select:hover {
  border-color: var(--lm-text-primary);
}

/* ===== Filters Panel ===== */
.lm-archive-filters-panel {
  margin-top: var(--lm-spacing-md);
  padding: var(--lm-spacing-lg);
  background: var(--lm-filters-bg);
  border: 1px solid var(--lm-border-color);
  border-radius: var(--lm-radius-lg);
  overflow: hidden;
  transition: opacity var(--lm-transition), max-height var(--lm-transition-slow);
  max-height: 2000px;
  opacity: 1;
}

.lm-archive-filters-panel.is-collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  border: none;
}

.lm-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--lm-spacing-lg);
}

.lm-filters-header__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lm-text-muted);
}

.lm-filters-header__clear {
  padding: 0;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--lm-text-muted);
  cursor: pointer;
  transition: color var(--lm-transition);
}

.lm-filters-header__clear:hover {
  color: var(--lm-text-primary);
  text-decoration: underline;
}

/* ===== Filters Grid ===== */
.lm-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--lm-spacing-md);
}

/* ===== Filter Card ===== */
.lm-filters-card {
  padding: var(--lm-spacing-lg);
  background: var(--lm-card-bg);
  border: 1px solid var(--lm-border-color);
  border-radius: var(--lm-radius-md);
  box-shadow: var(--lm-shadow-sm);
  transition: all var(--lm-transition);
}

.lm-filters-card--shape {
  transition: opacity var(--lm-transition), transform var(--lm-transition);
}

.lm-archive-filters[data-plain-metal="1"] .lm-filters-card--shape {
  opacity: 0.4;
  pointer-events: none;
  transform: scale(0.98);
}

.lm-filters-card__title {
  margin: 0 0 var(--lm-spacing-md) 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lm-text-muted);
}

.lm-filters-card__content {
  display: flex;
  flex-direction: column;
  gap: var(--lm-spacing-sm);
}

/* ===== Filter Pills ===== */
.lm-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lm-spacing-xs);
}

.lm-filter-pill {
  padding: 8px 16px;
  background: var(--lm-filters-bg);
  border: 1px solid var(--lm-border-color);
  border-radius: var(--lm-pill-radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--lm-text-primary);
  cursor: pointer;
  transition: all var(--lm-transition);
  white-space: nowrap;
}

.lm-filter-pill:hover {
  background: var(--lm-text-primary);
  color: var(--lm-active-text);
  border-color: var(--lm-text-primary);
  box-shadow: var(--lm-shadow-md);
  transform: translateY(-1px);
}

.lm-filter-pill.is-active {
  background: var(--lm-active-bg);
  color: var(--lm-active-text);
  border-color: var(--lm-active-bg);
  box-shadow: var(--lm-shadow-md);
}

/* ===== Visual Filters (Shape, Metal) ===== */
.lm-filter-visual {
  display: flex;
  flex-direction: column;
  gap: var(--lm-spacing-xs);
}

.lm-filter-visual-item {
  display: flex;
  align-items: center;
  gap: var(--lm-spacing-sm);
  padding: 10px var(--lm-spacing-md);
  background: var(--lm-filters-bg);
  border: 1px solid var(--lm-border-color);
  border-radius: var(--lm-radius-sm);
  font-size: 13px;
  color: var(--lm-text-primary);
  cursor: pointer;
  transition: all var(--lm-transition);
  text-align: left;
  width: 100%;
}

.lm-filter-visual-item:hover {
  background: var(--lm-text-primary);
  color: var(--lm-active-text);
  border-color: var(--lm-text-primary);
  box-shadow: var(--lm-shadow-md);
  transform: translateY(-1px);
}

.lm-filter-visual-item.is-active {
  background: var(--lm-active-bg);
  color: var(--lm-active-text);
  border-color: var(--lm-active-bg);
  box-shadow: var(--lm-shadow-md);
}

.lm-filter-visual-item__icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lm-card-bg);
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--lm-text-primary);
  flex-shrink: 0;
}

.lm-filter-visual-item.is-active .lm-filter-visual-item__icon {
  background: var(--lm-active-text);
  color: var(--lm-active-bg);
}

.lm-filter-visual-item__swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--lm-border-color);
  flex-shrink: 0;
}

.lm-metal-swatch--all {
  background: linear-gradient(135deg, #ffd700 0%, #e5e5e5 50%, #ffb6c1 100%);
}

.lm-metal-swatch--18k-yellow-gold {
  background: #ffd700;
}

.lm-metal-swatch--18k-white-gold {
  background: #e5e5e5;
}

.lm-metal-swatch--18k-rose-gold {
  background: #ffb6c1;
}

.lm-filter-visual-item__label {
  flex: 1;
}

/* ===== Checkbox ===== */
.lm-filter-checkbox {
  display: flex;
  align-items: center;
  gap: var(--lm-spacing-sm);
  cursor: pointer;
  padding: var(--lm-spacing-sm) 0;
}

.lm-filter-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--lm-active-bg);
}

.lm-filter-checkbox span {
  font-size: 13px;
  color: var(--lm-text-primary);
}

/* ===== Price Range ===== */
.lm-filter-price-range__display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--lm-spacing-xs);
  margin-bottom: var(--lm-spacing-md);
  font-size: 15px;
  font-weight: 600;
  color: var(--lm-text-primary);
}

.lm-filter-price-range__slider {
  position: relative;
  height: 40px;
  padding-top: 20px;
}

.lm-filter-price-range__input {
  position: absolute;
  width: 100%;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: transparent;
  outline: none;
}

.lm-filter-price-range__input::-webkit-slider-thumb {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--lm-active-bg);
  border: 2px solid var(--lm-card-bg);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--lm-shadow-md);
  transition: all var(--lm-transition);
}

.lm-filter-price-range__input::-moz-range-thumb {
  pointer-events: auto;
  width: 18px;
  height: 18px;
  background: var(--lm-active-bg);
  border: 2px solid var(--lm-card-bg);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--lm-shadow-md);
  transition: all var(--lm-transition);
}

.lm-filter-price-range__input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.lm-filter-price-range__input::-moz-range-thumb:hover {
  transform: scale(1.15);
}

.lm-filter-price-range__input::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: var(--lm-border-color);
  border-radius: 2px;
}

.lm-filter-price-range__input::-moz-range-track {
  width: 100%;
  height: 4px;
  background: var(--lm-border-color);
  border-radius: 2px;
}

/* ===== Responsive Design ===== */

/* Desktop large */
@media (min-width: 1200px) {
  .lm-toolbar__helper {
    display: block;
  }

  .lm-filters-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Tablet */
@media (max-width: 1024px) {
  .lm-filters-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .lm-toolbar__helper {
    display: none;
  }
}

/* Mobile */
@media (max-width: 720px) {
  .lm-archive-toolbar {
    padding: var(--lm-spacing-sm) var(--lm-spacing-md);
    gap: var(--lm-spacing-sm);
  }

  .lm-toolbar__left {
    gap: var(--lm-spacing-sm);
  }

  .lm-toolbar__helper {
    display: none;
  }

  .lm-toolbar__sort-label {
    display: none;
  }

  .lm-toolbar__filters-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .lm-toolbar__sort-select {
    padding: 8px 30px 8px 14px;
    font-size: 13px;
    background-position: right 10px center;
  }

  .lm-archive-filters-panel {
    padding: var(--lm-spacing-md);
  }

  .lm-filters-grid {
    grid-template-columns: 1fr;
    gap: var(--lm-spacing-sm);
  }

  .lm-filters-card {
    padding: var(--lm-spacing-md);
  }

  .lm-filter-pills {
    gap: 6px;
  }

  .lm-filter-pill {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* ===== Focus States (Accessibility) ===== */
.lm-toolbar__filters-btn:focus-visible,
.lm-toolbar__sort-select:focus-visible,
.lm-filters-header__clear:focus-visible,
.lm-filter-pill:focus-visible,
.lm-filter-visual-item:focus-visible {
  outline: 2px solid var(--lm-active-bg);
  outline-offset: 2px;
}

/* ===== Loading State ===== */
.lm-archive-filters.is-loading::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 9999;
  cursor: wait;
}
