/* tech-merch filter sidebar + mobile bottom-sheet + FAB + results header */

/* When mounted into Electro's #sidebar slot, drop the widget-area chrome
   so our own panel border/padding rules apply cleanly. */
#sidebar.tm-filter-sidebar-slot { padding: 0; }

.tm-filter-sidebar {
  font-size: 14px;
  color: #222;
  position: relative;
}

.tm-filter-panel {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 0;
  position: relative;
}

.tm-filter-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e5e5e5;
  font-weight: 600;
}
.tm-filter-panel > summary::-webkit-details-marker { display: none; }
.tm-filter-panel > summary h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.tm-clear-all {
  font-size: 12px;
  color: #c00;
  text-decoration: underline;
}

.tm-filter-form {
  padding: 12px 16px;
}

.tm-applied-chips {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #c00;
  border-radius: 12px;
  font-size: 12px;
  color: #c00;
}
.tm-chip-x {
  color: #c00;
  text-decoration: none;
  font-weight: bold;
  line-height: 1;
}
.tm-chip-x:hover { color: #f00; }

.tm-facet {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}
.tm-facet:last-of-type { border-bottom: none; }
.tm-facet > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tm-facet > summary::-webkit-details-marker { display: none; }
.tm-facet > summary::after {
  content: "\25BE"; /* ▾ */
  color: #999;
  font-size: 12px;
  transition: transform 0.15s ease;
}
.tm-facet[open] > summary::after { transform: rotate(180deg); }
.tm-facet > summary > h3 { margin: 0; }
.tm-facet h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
}
.tm-facet ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tm-facet li { margin: 0; padding: 2px 0; }

.tm-facet-overflow > summary {
  font-size: 12px;
  color: #4DAAA7;
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
}
.tm-facet-overflow > summary::-webkit-details-marker { display: none; }
.tm-facet-overflow[open] > summary { color: #999; }
.tm-facet-overflow[open] > summary > .label { display: none; }
.tm-facet-overflow[open] > summary::before { content: "Show less"; }
.tm-facet label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: normal;
}
.tm-facet input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
}
.tm-facet-name { flex: 1; }
.tm-facet .count {
  color: #999;
  font-size: 12px;
}

.tm-facet-price .tm-price-range {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tm-facet-price input[type="number"] {
  width: 80px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
}
.tm-price-sep { color: #999; }
.tm-price-bounds {
  font-size: 11px;
  color: #999;
  margin-top: 6px;
}

/* Search-within-facet: shown on desktop for facets with >10 values (rendered
   conditionally by SidebarRenderer). Mobile users get the long scrollable list. */
.tm-facet-search {
  margin: 4px 0 8px;
}
.tm-facet-search-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  box-sizing: border-box;
  background: #fff;
}
.tm-facet-search-input:focus {
  border-color: #4DAAA7;
  outline: none;
}

.tm-apply-btn {
  display: none; /* hidden on desktop -- auto-submit on change */
  width: 100%;
  padding: 12px;
  background: #4DAAA7;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.tm-apply-btn:hover { background: #3D8C89; }

/* FAB and bottom-sheet (mobile only) */
.tm-filter-fab {
  display: none;
}

/* Mobile X close button — hidden on desktop */
.tm-filter-close { display: none; }

/* Infinite-scroll loading row */
.tm-scroll-loader {
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 13px;
}
.tm-load-sentinel { height: 1px; pointer-events: none; }

/* T-044: belt-and-suspenders. The primary fix is in Bootstrap::renderPageTitle
   which replaces Electro's electro_wc_loop_title callback so the page-header no
   longer contains a .woocommerce-result-count. This CSS catches any other plugin
   that hooks a similar page-header result-count. Scoped to .page-header so any
   other valid usage of .woocommerce-result-count is untouched. */
.page-header .woocommerce-result-count { display: none !important; }

/* Results header */
.tm-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
}
.tm-results-count { color: #555; }
.tm-orderby-form { display: flex; align-items: center; gap: 8px; }
.tm-orderby-label { font-size: 13px; color: #555; }
.tm-orderby-form select {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 13px;
  background: #fff;
}

@media (max-width: 767px) {
  /* Hide Electro's own handheld filter toggle that opens an empty drawer.
     Our FAB + bottom-sheet is the only filter affordance on mobile. */
  .handheld-sidebar-toggle,
  .electro-handheld-sidebar-toggle,
  #electro-handheld-sidebar,
  .handheld-sidebar {
    display: none !important;
  }

  /* T-043: desktop-only search-within-facet. Mobile users prefer scrolling. */
  .tm-facet-search { display: none; }

  .tm-filter-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    z-index: 9999;
    background: rgba(0,0,0,0.5);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    overflow: hidden;
    /* Don't block touches when closed -- otherwise the still-positioned
       (translated off-screen) overlay intercepts FAB taps. */
    pointer-events: none;
  }
  body.tm-filter-open .tm-filter-sidebar {
    transform: translateY(0);
    pointer-events: auto;
  }

  .tm-filter-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
  }
  .tm-filter-panel > summary {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    border-bottom: 1px solid #e5e5e5;
    padding-right: 56px; /* leave room for the X */
  }

  /* T-048: leave room at bottom for the fixed Apply so the last facet isn't
     hidden behind it. */
  .tm-filter-form {
    padding-bottom: 96px;
  }
  /* T-048: position:fixed escapes the form/panel containing context entirely;
     left/right percentages anchor to viewport so the pill stays centered on
     any mobile width (320, 360, 414, 480, ...). z-index 10002 sits above the
     sidebar overlay (9999) and FAB (10000). */
  .tm-apply-btn {
    display: block;
    position: fixed;
    bottom: 16px;
    left: 10%;
    right: 10%;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 14px 0;
    background: #4DAAA7;
    color: #fff;
    border: 0;
    border-radius: 28px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    z-index: 10002;
    cursor: pointer;
  }
  body:not(.tm-filter-open) .tm-apply-btn {
    display: none;
  }
  .tm-apply-btn:hover,
  .tm-apply-btn:active {
    background: #3D8C89;
  }
  .tm-results-header { flex-direction: column; align-items: stretch; gap: 8px; }

  /* T-044: defeat Electro `.btn` + `.handheld-*` rules that set right:16px alongside
     left:16px (which stretches the button across the full viewport). The `html body`
     prefix raises specificity above Electro's own selectors, and the `inset` shorthand
     resets top/right/bottom/left in one declaration — any individual `right:` rule
     at the same specificity level loses to a shorthand. width:max-content shrinks
     the button to fit its label+badge instead of filling max-width. */
  html body button.tm-filter-fab,
  html body .tm-filter-fab.tm-filter-fab {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    position: fixed !important;
    inset: auto auto 80px 16px !important; /* top right bottom left */
    transform: none !important;
    width: max-content !important;
    max-width: calc(100vw - 32px) !important;
    z-index: 10000 !important;
    padding: 10px 16px;
    background: #4DAAA7 !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
  }
  button.tm-filter-fab:hover,
  button.tm-filter-fab:focus,
  button.tm-filter-fab:active,
  .tm-filter-fab.tm-filter-fab:hover,
  .tm-filter-fab.tm-filter-fab:focus,
  .tm-filter-fab.tm-filter-fab:active {
    background: #3D8C89 !important;
    color: #fff !important;
  }
  .tm-filter-fab .tm-count-badge {
    background: #fff !important;
    color: #4DAAA7 !important;
    border-radius: 12px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
  }

  /* T-056: hide FAB while the filter sheet is open — the sheet's Apply pill is
     the only filter affordance in that state. Re-uses body.tm-filter-open which
     SidebarRenderer toggles on open/close. !important defeats the !important on
     the FAB display rule above. */
  body.tm-filter-open button.tm-filter-fab,
  body.tm-filter-open .tm-filter-fab.tm-filter-fab {
    display: none !important;
  }

  /* X close lives inside summary; sticky-positioned summary keeps it visible
     during scroll. Sized as a circular hit area for thumb-friendly tapping. */
  .tm-filter-close {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    color: #333;
    cursor: pointer;
    z-index: 3;
    padding: 0;
  }
  .tm-filter-close:hover { background: #e5e5e5; color: #c00; }
}

/* T-050: header icon visibility on the orange brand-color navbar.
 * Electro defaults these to #EC6E4D (orange) which matches our brand color
 * = invisible against the orange bar background. White by default,
 * teal accent on hover. */
.electro-navbar-inner .header-icon .ec,
.electro-navbar-inner .header-icon a,
.electro-navbar-inner .header-icon i,
.electro-navbar-inner .header-icon-link,
.electro-navbar-inner .header-icon__cart .ec,
.electro-navbar-inner .yith-woocompare-open .ec {
  color: #fff !important;
}
.electro-navbar-inner .header-icon:hover .ec,
.electro-navbar-inner .header-icon:hover a,
.electro-navbar-inner .header-icon:hover i,
.electro-navbar-inner .header-icon:hover .header-icon-link {
  color: #4DAAA7 !important;
}

/* T-050: hide non-functional "Shop By Department" element. No WP menu is
 * assigned to Electro's Departments slot so it just shows a dead label.
 * If we want it back later, assign a menu in Appearance > Menus > Display Locations. */
.electro-navbar .departments-menu-v2,
.departments-menu-v2 {
  display: none !important;
}
/* Reclaim its horizontal space so the search bar can stretch to the left */
.electro-navbar .electro-navbar-inner > .secondary-search,
.electro-navbar-inner .secondary-search {
  flex: 1 1 auto;
}
