/* BM Instant Loop — Clean Minimal Styles */

/* Container */
.bm-instant-loop {
  display: block;
  width: 100%;
  margin: 0 auto;
  font-family: inherit;
}

/* Filters row (host form) */
.bm-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}

/* Filters template wrapper (when filters_template_id is used) */
.bm-filters-template {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
  align-items: flex-start;
}

/* Elementor NEW Accordion (n-accordion) — make items tile across the row */
.bm-filters-template .elementor-widget-n-accordion {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
}
.bm-filters-template .elementor-widget-n-accordion > details.e-n-accordion-item {
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
}
.bm-filters-template .elementor-widget-n-accordion > details.e-n-accordion-item > summary {
  display: block;
  width: 100%;
}
.bm-filters-template .elementor-widget-n-accordion > details.e-n-accordion-item > [role="region"] {
  width: 100%;
}

/* Each filter block (either default controls or items inside filters template) */
.bm-filters-template > *,
.bm-controls > * {
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
}

/* Default controls layout */
.bm-controls,
.bm-control {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 160px;
}
.bm-control label {
  font-weight: 600;
  font-size: 0.95em;
  color: var(--e-global-color-text, #111);
}
.bm-control input[type="search"],
.bm-control select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  font-size: 1rem;
  min-height: 44px;
  box-sizing: border-box;
}
.bm-simple select {
  min-width: 220px;
}
.bm-search {
  width: 100%;
  max-width: 450px;
  flex: 1 1 450px;
}
.bm-search-standalone {
  margin: 0 0 1rem 0;
}

/* Checkbox option */
.bm-opt {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
/* Hide the native checkbox but keep it accessible */
.bm-opt input[type="checkbox"],
.bm-opt input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
/* Visual box */
.bm-opt span {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.bm-opt span::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid var(--e-global-color-text, rgba(0,0,0,0.6));
  border-radius: 3px;
  background: #fff;
  margin-right: 6px;
  box-sizing: border-box;
}
.bm-opt span::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  left: 9px;
  top: 50%;
  transform: translate(-50%, -60%) rotate(45deg);
  opacity: 0;
  pointer-events: none;
}
/* Tick mark */
.bm-opt input[type="checkbox"]:checked + span::before,
.bm-opt input[type="radio"]:checked + span::before {
  background: var(--e-global-color-accent, #0073aa);
  border-color: var(--e-global-color-accent, #0073aa);
}
.bm-opt input[type="checkbox"]:checked + span::after,
.bm-opt input[type="radio"]:checked + span::after {
  opacity: 1;
}
/* Focus state for accessibility */
.bm-opt input[type="checkbox"]:focus-visible + span::before,
.bm-opt input[type="checkbox"]:focus + span::before,
.bm-opt input[type="radio"]:focus-visible + span::before,
.bm-opt input[type="radio"]:focus + span::before {
  outline: 2px solid var(--e-global-color-accent, #0073aa);
  outline-offset: 2px;
}

/* Neater option lists inside each filter */
.bm-checklist,
.bm-tax-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  column-gap: 1.25rem;
  row-gap: 0.5rem;
  align-items: center;
}

/* Utility row */
.bm-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* Buttons */
.bm-load-more,
.bm-reset {
  background: var(--e-global-color-accent, #0073aa);
  border: none;
  color: #fff;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 3px;
  transition: background 0.2s ease;
}
.bm-load-more:hover,
.bm-reset:hover {
  background: var(--e-global-color-secondary, #005a8c);
}

/* Sidebar layout */
.bm-instant-loop[data-layout="sidebar"] .bm-layout {
  display: grid;
  grid-template-columns: minmax(220px, var(--bm-sidebar-width, 280px)) minmax(0, 1fr);
  gap: var(--bm-sidebar-gap, 2rem);
  align-items: start;
}
.bm-instant-loop[data-layout="sidebar"] .bm-main {
  min-width: 0;
}
@media (max-width: 900px) {
  .bm-instant-loop[data-layout="sidebar"] .bm-layout {
    grid-template-columns: 1fr;
  }
}

/* Sort select should fill its block */
.bm-instant-loop select[data-sort] {
  width: 100%;
  min-width: 240px;
}

/* Results grid uses CSS Grid; default 1-col */
.bm-loop-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
}

/* Price range slider (dual) */
.bm-dual-slider {
  position: relative;
  height: 28px;
  margin-top: 8px;
}
.bm-dual-slider::before,
.bm-dual-slider::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 6px;
  border-radius: 999px;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
}
.bm-dual-slider::after {
  left: var(--range-start-pct, 0%);
  right: calc(100% - var(--range-end-pct, 100%));
  background: var(--e-global-color-accent, #0073aa);
}
.bm-dual-slider input[type="range"] {
  position: absolute;
  left: 0; right: 0;
  top: 0; bottom: 0;
  width: 100%;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.bm-dual-slider input[data-handle="min"] { z-index: 2; }
.bm-dual-slider input[data-handle="max"] { z-index: 3; }
.bm-dual-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px; height: 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--e-global-color-accent, #0073aa);
}
.bm-dual-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px; height: 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--e-global-color-accent, #0073aa);
}
.bm-range-display {
  display: inline-block;
  font-size: 0.9em;
  opacity: 0.9;
}
/* Make Elementor loop items play nicely inside grid */
.bm-loop-grid > .elementor-post.elementor-grid-item {
  width: auto;
}
/* Per-instance product grid column control */
.bm-instant-loop[data-results-cols="1"] .bm-loop-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.bm-instant-loop[data-results-cols="2"] .bm-loop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bm-instant-loop[data-results-cols="3"] .bm-loop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bm-instant-loop[data-results-cols="4"] .bm-loop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Meta line under results */
.bm-loop-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--e-global-color-text, #333);
}
.bm-count { opacity: 0.8; }

/* Price history modal */
.bm-history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 9999;
}
.bm-history-overlay.is-open { display: flex; }
.bm-history-modal {
  position: relative;
  width: min(720px, 100%);
  max-height: 90vh;
  background: #fff;
  color: #111;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.16);
  overflow: hidden;
}
.bm-history-body {
  padding: 1.5rem;
  overflow: auto;
  max-height: 90vh;
}
.bm-history-close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  border: none;
  background: transparent;
  color: #444;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.5rem;
}
.bm-history-head {
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--e-global-color-text, #111);
}
.bm-history-title {
  display: inline-flex;
  gap: 0.35rem;
  align-items: baseline;
}
.bm-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.bm-history-table th,
.bm-history-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e5e5e5;
}
.bm-history-table th {
  background: #f8f8f8;
  font-weight: 600;
}
.bm-history-table tr:nth-child(even) td {
  background: #fbfbfb;
}
.bm-history-loading,
.bm-history-error,
.bm-history-empty {
  padding: 1rem;
  text-align: center;
  color: var(--e-global-color-text, #333);
}
.bm-history-error { color: #b00020; }

/* Empty state */
.bm-empty {
  text-align: center;
  opacity: 0.7;
  padding: 2rem;
  font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
  .bm-control { min-width: 100%; }
  .bm-filters-template { flex-direction: column; }
  .bm-filters-template .bm-checklist,
  .bm-filters-template .bm-tax-checklist {
    grid-template-columns: repeat(2, 1fr);
  }
  .bm-search {
    max-width: 100%;
    flex-basis: 100%;
  }
  .bm-filters-template > *,
  .bm-controls > * { flex: 1 1 auto; min-width: 0; }
  .bm-instant-loop .bm-loop-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .bm-instant-loop[data-results-cols-mobile="1"] .bm-loop-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .bm-instant-loop[data-results-cols-mobile="2"] .bm-loop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bm-instant-loop[data-results-cols-mobile="3"] .bm-loop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bm-instant-loop[data-results-cols-mobile="4"] .bm-loop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Dynamic column layout for filter checklists (meta + tax) */
.bm-instant-loop[data-columns="1"] .bm-checklist,
.bm-instant-loop[data-columns="1"] .bm-tax-checklist { grid-template-columns: repeat(1, 1fr); }
.bm-instant-loop[data-columns="2"] .bm-checklist,
.bm-instant-loop[data-columns="2"] .bm-tax-checklist { grid-template-columns: repeat(2, 1fr); }
.bm-instant-loop[data-columns="3"] .bm-checklist,
.bm-instant-loop[data-columns="3"] .bm-tax-checklist { grid-template-columns: repeat(3, 1fr); }
.bm-instant-loop[data-columns="4"] .bm-checklist,
.bm-instant-loop[data-columns="4"] .bm-tax-checklist { grid-template-columns: repeat(4, 1fr); }
.bm-instant-loop[data-columns="5"] .bm-checklist,
.bm-instant-loop[data-columns="5"] .bm-tax-checklist { grid-template-columns: repeat(5, 1fr); }
.bm-instant-loop[data-columns="6"] .bm-checklist,
.bm-instant-loop[data-columns="6"] .bm-tax-checklist { grid-template-columns: repeat(6, 1fr); }
