/* =====================================================
   Timeless Filters – Bricks Builder
   Design: Figma node 6073:991
   ===================================================== */

:root {
  --tw-filter-border:       #e5e6e8;
  --tw-filter-active-bg:    #fff1e8;
  --tw-filter-text:         #000c22;
  --tw-filter-muted:        rgba(0, 12, 34, 0.5);
  --tw-filter-drop-bg:      #ffffff;
  --tw-filter-drop-shadow:  0 8px 24px rgba(0, 0, 0, 0.12);
  --tw-filter-checked-bg:   #fff1e8;
  --tw-filter-checked-dot:  #f2a371;
  --tw-filter-btn-h:        46px;
  --tw-filter-radius:       0;
}

/* ── Filter wrapper (each individual filter cell) ── */

.tw-filter-wrap {
  position: relative;
  border: 1px solid var(--tw-filter-border);
  /* Collapsed-border grid: margin-left trick handled via flex/grid in Bricks */
}

/* Active state: warm peach background (Brand "Rolex" selected in Figma) */
.tw-filter-wrap--active {
  background-color: var(--tw-filter-active-bg);
  border-color: var(--tw-filter-border);
}

/* ── Trigger button ── */

.tw-filter-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: var(--tw-filter-btn-h);
  padding: 8px 24px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tw-filter-text);
  font-size: 18px;
  font-weight: 500;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}

.tw-filter-btn:focus-visible {
  outline: 2px solid var(--tw-filter-checked-dot);
  outline-offset: -2px;
}

/* Remove (×) icon – top-left, shown only when active */
.tw-filter-btn__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.tw-filter-btn__remove svg {
  pointer-events: none;
}

/* Label text */
.tw-filter-btn__label {
  color: var(--tw-filter-text);
  font-size: 18px;
  font-weight: 500;
}

/* Selected value (e.g. "Rolex") – muted, shown after label */
.tw-filter-btn__value {
  color: var(--tw-filter-muted);
  font-size: 18px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chevron – pushed to right */
.tw-filter-btn__chevron {
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.tw-filter-btn[aria-expanded="true"] .tw-filter-btn__chevron {
  transform: rotate(180deg);
}

/* ── Dropdown panel ── */

.tw-filter-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: -1px;
  min-width: calc(100% + 2px);
  max-height: 320px;
  overflow-y: auto;
  background: var(--tw-filter-drop-bg);
  border: 1px solid var(--tw-filter-border);
  box-shadow: var(--tw-filter-drop-shadow);
  z-index: 9999;
  padding: 8px 0;
}

.tw-filter-dropdown.is-open {
  display: block;
}

/* Scrollbar styling */
.tw-filter-dropdown::-webkit-scrollbar {
  width: 4px;
}
.tw-filter-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.tw-filter-dropdown::-webkit-scrollbar-thumb {
  background: var(--tw-filter-border);
  border-radius: 2px;
}

/* ── Option rows (checkbox / radio) ── */

.tw-filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-size: 15px;
  font-weight: 500;
  color: var(--tw-filter-text);
}

.tw-filter-option:hover {
  background-color: var(--tw-filter-active-bg);
}

.tw-filter-option--checked {
  background-color: var(--tw-filter-checked-bg);
}

/* Hide the native input, show a custom dot/tick */
.tw-filter-option input[type="radio"],
.tw-filter-option input[type="checkbox"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  display: block;         /* block so flex cannot stretch it */
  flex-shrink: 0;
  flex-grow: 0;
  width: 16px !important;
  min-width: 16px !important;
  height: 16px !important;
  min-height: 16px !important;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  border: 1.5px solid var(--tw-filter-border);
  border-radius: 3px;
  background: #fff;
  position: relative;
  cursor: pointer;
  margin: 0;
  padding: 0;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.tw-filter-option input[type="radio"] {
  border-radius: 50% !important;
}

.tw-filter-option input[type="radio"]:checked,
.tw-filter-option input[type="checkbox"]:checked {
  background-color: var(--tw-filter-checked-dot);
  border-color: var(--tw-filter-checked-dot);
}

.tw-filter-option input[type="radio"]:checked::after,
.tw-filter-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
}

.tw-filter-option input[type="radio"]:checked::after {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

.tw-filter-option input[type="checkbox"]:checked::after {
  width: 9px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* Disabled term (0 results given current filters) */
.tw-filter-option--disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.tw-filter-option--disabled input {
  cursor: not-allowed;
}

/* Separator between available and disabled terms */
.tw-filter-option-separator {
  height: 1px;
  background: var(--tw-filter-border);
  margin: 4px 16px;
}

/* Term count badge */
.tw-filter-option__count {
  margin-left: auto;
  color: var(--tw-filter-muted);
  font-size: 13px;
  font-weight: 400;
}

/* ── Attribute search box ── */

.tw-filter-search {
  position: sticky;
  top: 0;
  background: var(--tw-filter-drop-bg);
  padding: 10px 16px;
  border-bottom: 1px solid var(--tw-filter-border);
  z-index: 1;
}

.tw-filter-search__wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.tw-filter-search__input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  padding: 7px 32px 7px 10px;
  border: 1px solid var(--tw-filter-border);
  background: #fafafa;
  font-size: 14px;
  font-weight: 400;
  color: var(--tw-filter-text);
  outline: none;
  border-radius: 3px;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.tw-filter-search__input:focus {
  border-color: var(--tw-filter-checked-dot);
  background: #fff;
}

.tw-filter-search__icon {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tw-filter-muted);
  pointer-events: none;
  display: flex;
}

/* Empty state */
.tw-filter-empty {
  padding: 10px 24px;
  color: var(--tw-filter-muted);
  font-size: 14px;
}

/* ── Price filter specific ── */

.tw-filter-dropdown--price {
  padding: 20px 24px;
  min-width: 280px;
}

.tw-filter-price__labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tw-filter-text);
}

/*
 * The track container height matches the thumb size (18px).
 * The visual 4px line is drawn via ::before, centered with translateY(-50%).
 * The fill bar is also centered the same way.
 * This guarantees the thumbs (18px) sit exactly on the center line.
 */
.tw-filter-price__track {
  position: relative;
  height: 18px;        /* = thumb height, so thumbs sit flush */
  margin-bottom: 16px;
}

/* Grey background track line – centered vertically */
.tw-filter-price__track::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  height: 4px;
  background: var(--tw-filter-border);
  border-radius: 2px;
  pointer-events: none;
}

/* Coloured fill bar between the two thumbs – also centered */
.tw-filter-price__range-fill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: var(--tw-filter-checked-dot);
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
  /* left / right set by JS directly on the element */
}

.tw-filter-price__range {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 18px;        /* same as container = thumbs sit at vertical center */
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none;
  margin: 0;
  padding: 0;
  z-index: 2;
}

.tw-filter-price__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--tw-filter-checked-dot);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  pointer-events: all;
}

.tw-filter-price__range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--tw-filter-checked-dot);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  pointer-events: all;
  border: 2px solid #fff;
}

/* Individual native tracks: transparent – the ::before handles the visuals */
.tw-filter-price__range::-webkit-slider-runnable-track {
  height: 18px;
  background: transparent;
}

.tw-filter-price__range::-moz-range-track {
  height: 18px;
  background: transparent;
}

.tw-filter-price__apply {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--tw-filter-text);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
  text-align: center;
}

.tw-filter-price__apply:hover {
  opacity: 0.85;
}

/* ══════════════════════════════════════════
   Results container (AJAX loading state)
   Add class "tw-filter-results" to the Bricks
   Div that wraps your query loop.
══════════════════════════════════════════ */

.tw-filter-results {
  position: relative;
  transition: opacity 0.25s ease;
  min-height: 100px;
}

.tw-filter-results--loading {
  opacity: 0.4;
  pointer-events: none;
  user-select: none;
}

/* Spinner overlay */
.tw-filter-results--loading::before {
  content: '';
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  border: 3px solid var(--tw-filter-border);
  border-top-color: var(--tw-filter-checked-dot);
  border-radius: 50%;
  animation: twSpin 0.75s linear infinite;
  z-index: 20;
}

@keyframes twSpin {
  to { transform: translateX(-50%) rotate(360deg); }
}

/* ── Clear All button ── */

.tw-filter-clear-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* Use rgba instead of opacity so framework a:hover can't override text color */
  color: rgba(0, 12, 34, 0.5) !important;
  font-size: 18px;
  font-weight: 500;
  text-decoration: none !important;
  cursor: pointer;
  transition: color 0.2s ease;
  white-space: nowrap;
  background: none !important;
}

.tw-filter-clear-all:hover,
.tw-filter-clear-all:focus {
  color: rgba(0, 12, 34, 0.85) !important;
  text-decoration: none !important;
  background: none !important;
}

.tw-filter-clear-all--hidden {
  visibility: hidden;
  pointer-events: none;
}

.tw-filter-clear-all__icon {
  flex-shrink: 0;
}

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

/* 991px – tablet */
@media (max-width: 991px) {
  .tw-filter-btn {
    font-size: 16px;
    padding: 8px 16px;
  }

  .tw-filter-btn__label,
  .tw-filter-btn__value {
    font-size: 16px;
  }

  .tw-filter-clear-all {
    font-size: 16px;
  }
}

/* 767px – large mobile */
@media (max-width: 767px) {
  .tw-filter-wrap {
    border-left: 1px solid var(--tw-filter-border);
    width: 100%;
  }

  .tw-filter-btn {
    font-size: 15px;
    padding: 10px 16px;
    height: auto;
    min-height: var(--tw-filter-btn-h);
  }

  .tw-filter-dropdown {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    min-width: 100%;
    max-height: 60vh;
    border: none;
    border-top: 1px solid var(--tw-filter-border);
    border-radius: 16px 16px 0 0;
    padding: 16px 0 32px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  }

  .tw-filter-dropdown--price {
    padding: 20px 24px 32px;
  }
}

/* ── Show More button ── */

.tw-show-more--loading {
  opacity: 0.7 !important;
  cursor: wait !important;
}

/* ── AJAX results loading state ── */

.tw-filter-results--loading {
  position: relative;
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.tw-filter-results--loading::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 10;
}

/* 478px – small mobile */
@media (max-width: 478px) {
  .tw-filter-btn {
    font-size: 14px;
    padding: 10px 12px;
  }

  .tw-filter-option {
    font-size: 14px;
    padding: 10px 16px;
  }
}
