/* ================================================================ */
/* SHOPIFY-STYLE FACETS FOR DRUPAL - RTL COMPATIBLE                */
/* ================================================================ */

/* Remove slimScroll plugin completely - use native scroll */
.sidebar .slimScrollBar,
.sidebar .slimScrollRail,
.slimScrollBar,
.slimScrollRail {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
}

.sidebar .slimScrollDiv {
  overflow: visible !important;
  height: auto !important;
}

/* Remove sidebar borders/lines */
.sidebar,
.col-md-3.sidebar,
.sidebar .block-facets,
.sidebar .facets-widget-checkbox,
.sidebar .item-list__checkbox,
.region-sidebar-first,
.region-sidebar-first .block-facets,
.container-wrap {
  border: none !important;
  border-left: none !important;
  border-right: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* Facet block spacing */
.block-facets {
  margin-bottom: 20px;
}

/* Facet title */
.sidebar .block-facets .block-title {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: #1a1a1a !important;
  margin-bottom: 12px !important;
  padding: 0 !important;
  background: none !important;
  border: none !important;
}

/* 1. The Button Container */
.sidebar .collapsiblockTitle > button,
.collapsiblockTitle > button {
  display: flex !important;
  flex-direction: row !important; /* Arrow first, then text in RTL */
  justify-content: flex-start !important; /* Anchors everything to the right */
  align-items: center !important; /* Vertical center alignment */
  width: 100% !important;
  background: none !important;
  border: none !important;
  padding: 0;
  cursor: pointer !important;
}

/* 2. The Arrow (Pseudo-element) */
.sidebar .collapsiblockTitle > button::before,
.collapsiblockTitle > button::before {
  content: "▼" !important;
  display: inline-block !important;
  font-size: 10px !important;
  margin-left: 8px !important; /* Gap between arrow and text */
  margin-right: 0 !important;
  flex-shrink: 0 !important; /* Prevents arrow from squishing */
  transition: transform 0.2s ease !important;
  order: 0 !important;
}

/* 3. THE CRITICAL FIX: The Text Wrapper */
/* This prevents the title from expanding and pushing itself to the left */
.sidebar .collapsiblockTitle .block-title-wrap,
.collapsiblockTitle .block-title-wrap,
.sidebar .collapsiblockTitle .block-title {
  width: auto !important; /* Allows it to sit right next to the arrow */
  margin: 0 !important;
  padding: 0 !important;
  display: inline-block !important;
  text-align: right !important;
}

/* 4. Rotations for RTL */
.sidebar .collapsiblockTitleCollapsed > button::before {
  transform: rotate(90deg) !important; /* Points 'in' towards text when closed */
}

.sidebar .collapsiblockTitle:not(.collapsiblockTitleCollapsed) > button::before {
  transform: rotate(0deg) !important; /* Points down when open */
}

/* Title wrap */
.sidebar .collapsiblockTitle .block-title-wrap,
.collapsiblockTitle .block-title-wrap {
  width: auto !important;
}

/* Title wrap - add padding for arrow space */
.sidebar .collapsiblockTitle .block-title-wrap,
.collapsiblockTitle .block-title-wrap {
  padding-right: 25px !important;
  padding-left: 0 !important;
  width: 100% !important;
}

/* Facet list container - max-height with native auto scroll */
.sidebar .facets-widget-checkbox ul,
.sidebar .js-facets-checkbox-links,
.sidebar .item-list__checkbox ul,
.sidebar .item-list__checkbox,
.sidebar .facet-list {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
  height: auto !important;
  max-height: 280px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  display: block !important;
}

/* Facet item row - BLOCK to stack vertically */
.sidebar .facet-item,
.sidebar .item-list__checkbox li {
  list-style: none !important;
  display: block !important;
  float: none !important;
  width: 100% !important;
  padding: 6px 0 !important;
  margin: 0 !important;
  background: none !important;
  border: none !important;
  clear: both !important;
}

/* Remove extra space below last item */
.sidebar .facet-item:last-child,
.sidebar .item-list__checkbox li:last-child {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

/* Remove any bullets/dots from li */
.sidebar .facet-item::before,
.sidebar .facet-item::after,
.sidebar .item-list__checkbox li::before,
.sidebar .item-list__checkbox li::after {
  content: none !important;
  display: none !important;
}

/* Hide native checkbox completely */
.sidebar .facets-checkbox,
.sidebar input[type="checkbox"].facets-checkbox,
.sidebar .facet-item input[type="checkbox"] {
  position: absolute !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  visibility: hidden !important;
}

/* Label - inline-flex so checkbox + text on same line */
.sidebar .facet-item label,
.sidebar .item-list__checkbox .form-check-label,
.sidebar [type="checkbox"] + label,
.sidebar [type="checkbox"] + .form-check-label {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  width: auto !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  color: #333 !important;
  line-height: 1.4 !important;
  background: none !important;
  border: none !important;
  position: relative !important;
}

/* Remove theme's default ::after pseudo-element */
.sidebar .facet-item label::after,
.sidebar .item-list__checkbox .form-check-label::after,
.sidebar [type="checkbox"] + label::after,
.sidebar [type="checkbox"] + .form-check-label::after,
.sidebar [type="checkbox"]:checked + label::after,
.sidebar [type="checkbox"]:not(:checked) + label::after {
  content: none !important;
  display: none !important;
  background: none !important;
  border: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Simple square checkbox via ::before */
.sidebar .facet-item label::before,
.sidebar .item-list__checkbox .form-check-label::before,
.sidebar [type="checkbox"] + label::before,
.sidebar [type="checkbox"] + .form-check-label::before,
.sidebar [type="checkbox"]:not(:checked) + label::before,
.sidebar [type="checkbox"]:checked + label::before {
  content: "" !important;
  display: inline-block !important;
  position: relative !important;
  top: 0 !important;
  left: 0 !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  border: 1px solid #ccc !important;
  border-radius: 2px !important;
  background: #fff !important;
  background-image: none !important;
  margin-left: 8px !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  flex-shrink: 0 !important;
  transition: all 0.15s ease !important;
  transform: none !important;
}

/* Checked state - black square with checkmark */
.sidebar .facets-checkbox:checked + label::before,
.sidebar .facets-checkbox:checked + .form-check-label::before,
.sidebar .facet-item.is-active label::before,
.sidebar [type="checkbox"]:checked + label::before,
.sidebar [type="checkbox"]:checked + .form-check-label::before {
  background-color: #000 !important;
  border-color: #000 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-size: 10px !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

/* Hover state */
.sidebar .facet-item label:hover::before,
.sidebar .item-list__checkbox .form-check-label:hover::before {
  border-color: #999 !important;
}

/* Facet value text */
.sidebar .facet-item__value {
  display: inline !important;
}

/* Facet count */
.sidebar .facet-item__count {
  font-size: 12px !important;
  color: #888 !important;
  margin-right: 5px !important;
  margin-left: 0 !important;
  display: inline !important;
}

/* Hide deactivate link - BUT NOT for yarn_color */
.facet-item__status {
  display: none !important;
}


/* ================================================================ */
/* YARN COLOR FACET - COLOR SWATCHES (must come last to override)  */
/* ================================================================ */

/* Container - flex layout for swatches */
ul[data-drupal-facet-id="yarn_color"] {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  height: auto !important;
}

/* List items - inline for swatch grid */
ul[data-drupal-facet-id="yarn_color"] > li.facet-item,
ul[data-drupal-facet-id="yarn_color"] > li {
  float: none !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  display: inline-block !important;
  clear: none !important;
}

/* Hide checkboxes + labels for color facet */
ul[data-drupal-facet-id="yarn_color"] input[type="checkbox"],
ul[data-drupal-facet-id="yarn_color"] label,
ul[data-drupal-facet-id="yarn_color"] .form-check-label {
  display: none !important;
  visibility: hidden !important;
}

/* SHOW the link (swatch) - override any hiding */
ul[data-drupal-facet-id="yarn_color"] a,
ul[data-drupal-facet-id="yarn_color"] .facet-item a,
ul[data-drupal-facet-id="yarn_color"] li a {
  display: block !important;
  visibility: visible !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  text-decoration: none !important;
  line-height: 0 !important;
  font-size: 0 !important;
  opacity: 1 !important;
}

/* Swatch image */
ul[data-drupal-facet-id="yarn_color"] a img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  border: 1px solid #ddd !important;
  border-radius: 50% !important;
  transition: border-color 0.2s ease !important;
}

/* Selected swatch: black border */
ul[data-drupal-facet-id="yarn_color"] li.is-active a img,
ul[data-drupal-facet-id="yarn_color"] a.is-active img {
  border: 2px solid #000 !important;
}

/* Hover state for swatches */
ul[data-drupal-facet-id="yarn_color"] a:hover img {
  border-color: #666 !important;
}

/* ========================================
   MOBILE FACETS DROPDOWN
   ======================================== */

.mobile-filter-bar {
  display: none;
}

@media (max-width: 767px) {
  /* Hide original sidebar facets on mobile */
  .region-sidebar-first {
    display: none;
  }
  
  /* Show mobile filter bar */
  .mobile-filter-bar {
    display: block;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    }
  
  .mobile-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 20px;
    background: #1f2937;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    gap: 10px;
    transition: background 0.2s ease;
    }
  
  .mobile-filter-btn:active {
    background: #374151;
  }
  
  .mobile-filter-btn svg {
    width: 18px;
    height: 18px;
    stroke: #fff;
  }
  
  .mobile-filter-btn .filter-count {
    background: #10b981;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 4px;
  }
  
  /* Filter Panel */
  .mobile-filter-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .mobile-filter-panel.is-visible {
    opacity: 1;
  }
  
  .mobile-filter-panel.is-open {
    display: block;
  }
  
.mobile-filter-panel__content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  background: #fff;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

  .mobile-filter-panel.is-visible .mobile-filter-panel__content {
    transform: translateY(0);
  }
  
  /* Panel Header */
.mobile-filter-panel__header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
  z-index: 10;
  gap: 8px;
  flex-shrink: 0;
}

  .mobile-filter-panel__title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
    flex-shrink: 0;
  }
  
  .mobile-filter-panel__actions {
    display: flex;
    gap: 8px;
    margin-right: auto;
    margin-left: 8px;
  }
  
  .mobile-filter-panel__view-results {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
  }
  
  .mobile-filter-panel__view-results:active {
    background: #256829;
  }
  
  .mobile-filter-panel__reset {
    background: #f5f5f5;
    color: #666;
    border: none;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
  }
  
  .mobile-filter-panel__reset:active {
    background: #e0e0e0;
  }
  
  .mobile-filter-panel__reset.has-filters {
    color: #333;
  }
  
  .mobile-filter-panel__close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
  }
  
  .mobile-filter-panel__close:hover {
    color: #333;
  }
  
  /* Selected Tags */
  .mobile-filter-panel__selected-tags {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
  }
  
  .mobile-filter-panel__selected-tags:not(:empty) {
    display: flex;
  }
  
  .mobile-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #b8d4d8;
    color: #333;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
  }
  
  .mobile-filter-tag__text {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .mobile-filter-tag__remove {
    background: none;
    border: none;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    margin-right: -2px;
  }
  
  .mobile-filter-tag__remove:hover {
    color: #000;
  }
  
  /* Facets inside panel */
/* Facets inside panel */
.mobile-filter-panel__facets {
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

  .mobile-filter-panel__facets .block-facets {
    border-bottom: 1px solid #e0e0e0;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .mobile-filter-panel__facets .block-facets:last-child {
    border-bottom: none;
  }
  
  .mobile-filter-panel__facets .block-facets .container-wrap {
    padding: 0;
  }
  
  /* Facet accordion headers */
  .mobile-filter-panel__facets .collapsiblockTitle button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 20px;
    background: #fff;
    border: none;
    cursor: pointer;
    text-align: right;
  }
  
  .mobile-filter-panel__facets .block-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0;
  }
  
  /* Arrow icon */
  .mobile-filter-panel__facets .collapsiblockTitle button::after {
    content: '';
    width: 10px;
    height: 10px;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: 12px;
  }
  
  .mobile-filter-panel__facets .collapsiblockTitle:not(.collapsiblockTitleCollapsed) button::after {
    transform: rotate(-135deg);
  }
  
  /* Facet content - hidden by default */
  .mobile-filter-panel__facets .block-content {
    padding: 0 20px 16px;
    background: #fafafa;
    display: none;
  }
  
  .mobile-filter-panel__facets .block-content:not(.collapsiblockContentCollapsed) {
    display: block;
  }
  
  .mobile-filter-panel__facets .facet-list {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  .mobile-filter-panel__facets .facet-item {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
  }
  
  .mobile-filter-panel__facets .facet-item:last-child {
    border-bottom: none;
  }
  
  /* Remove slimscroll constraints */
  .mobile-filter-panel__facets .slimScrollDiv,
  .mobile-filter-panel__facets .facet-list {
    height: auto !important;
    overflow: visible !important;
  }
  
  .mobile-filter-panel__facets .slimScrollBar,
  .mobile-filter-panel__facets .slimScrollRail {
    display: none !important;
  }
  
  /* Color facet special styling */
  .mobile-filter-panel__facets .product_facet_color .facet-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
  }
  
  .mobile-filter-panel__facets .product_facet_color .facet-item {
    padding: 0;
    border: none;
  }
  
  /* Checkbox styling */
  .mobile-filter-panel__facets .facet-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
  }
  
  .mobile-filter-panel__facets .facets-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #2e7d32;
  }
  
  /* Prevent body scroll when panel is open */
body.mobile-filter-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

  /* Highlight facet headers with active filters */
.mobile-filter-panel__facets .collapsiblockTitle.has-active-filters {
  background: #e8f5e9;
}

.mobile-filter-panel__facets .collapsiblockTitle.has-active-filters button {
  background: #e8f5e9;
}

/* Optional: add a small indicator dot */
.mobile-filter-panel__facets .collapsiblockTitle.has-active-filters .block-title::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #2e7d32;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
/* Facet titles in mobile panel */
.mobile-filter-panel__facets .block-title-content .block-title,
.mobile-filter-panel__facets h2.block-title {
  font-size: 16px !important;
  margin: 0;
}

/* Spacing between facets */
.mobile-filter-panel__facets .block-facets {
  margin-top: 5px !important;
  margin-bottom: 5px !important;
}
}

/* ========================================
   FIX: Hide mobile filter elements on desktop
   Add this to your facets CSS file
   ======================================== */

/* Hide mobile filter bar and panel on desktop (above 767px) */
.mobile-filter-bar,
.mobile-filter-panel {
  display: none !important;
}

/* Only show on mobile */
@media (max-width: 767px) {
  /* Show mobile filter bar */
  .mobile-filter-bar {
    display: block !important;
  }
  
  /* Panel stays hidden until JS adds .is-open class */
  .mobile-filter-panel {
    display: none !important;
  }
  
  .mobile-filter-panel.is-open {
    display: block !important;
  }
}

/* ================================================================ */
/* VARIATION COLOR FACET - COLOR SWATCHES                          */
/* ================================================================ */

ul[data-drupal-facet-id="tsb_khvt_bn"] {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  height: auto !important;
}

ul[data-drupal-facet-id="tsb_khvt_bn"] > li.facet-item,
ul[data-drupal-facet-id="tsb_khvt_bn"] > li {
  float: none !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  display: inline-block !important;
  clear: none !important;
}

ul[data-drupal-facet-id="tsb_khvt_bn"] input[type="checkbox"],
ul[data-drupal-facet-id="tsb_khvt_bn"] label,
ul[data-drupal-facet-id="tsb_khvt_bn"] .form-check-label {
  display: none !important;
  visibility: hidden !important;
}

ul[data-drupal-facet-id="tsb_khvt_bn"] a,
ul[data-drupal-facet-id="tsb_khvt_bn"] .facet-item a,
ul[data-drupal-facet-id="tsb_khvt_bn"] li a {
  display: block !important;
  visibility: visible !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  text-decoration: none !important;
  line-height: 0 !important;
  font-size: 0 !important;
  opacity: 1 !important;
}

ul[data-drupal-facet-id="tsb_khvt_bn"] a img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  border: 1px solid #ddd !important;
  border-radius: 50% !important;
  transition: border-color 0.2s ease !important;
}

ul[data-drupal-facet-id="tsb_khvt_bn"] li.is-active a img,
ul[data-drupal-facet-id="tsb_khvt_bn"] a.is-active img {
  border: 2px solid #000 !important;
}

ul[data-drupal-facet-id="tsb_khvt_bn"] a:hover img {
  border-color: #666 !important;
}