/* Moffatt Taxonomy — filter sidebar groups + FacetWP hierarchical checkbox styling.
   Design intent (SOW: within existing design): same coloured heading bars as today's sidebar, made collapsible;
   nested checkboxes with expand toggles (competitor reference behaviour), no new visual language. */

.mgtx-filter-group { margin: 0 0 12px; border: 1px solid rgba(0,0,0,.08); border-radius: 6px; overflow: hidden; background: #fff; }
.mgtx-filter-group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; min-height: 48px; font-weight: 600; font-size: 1.125rem; line-height: 1.3;
  background: var(--mgtx-bg, transparent); color: var(--mgtx-fg, inherit); user-select: none;
}
.mgtx-filter-group > summary::-webkit-details-marker { display: none; }
.mgtx-filter-group > summary:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.mgtx-filter-chevron { width: 10px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform .2s ease; margin-right: 4px; flex-shrink: 0; }
.mgtx-filter-group[open] > .mgtx-filter-chevron, .mgtx-filter-group[open] > summary .mgtx-filter-chevron { transform: rotate(-135deg); margin-top: 6px; }
.mgtx-filter-body { padding: 8px 12px 10px; max-height: 520px; overflow-y: auto; }

/* FacetWP checkbox rows */
.mgtx-filter-body .facetwp-facet { margin-bottom: 0; }
.mgtx-filter-body .facetwp-checkbox {
  position: relative; display: flex; align-items: center; min-height: 36px; padding: 0 0 0 26px; margin: 0;
  background: none !important; font-size: .95rem; line-height: 1.3; color: inherit; cursor: pointer;
}
.mgtx-filter-body .facetwp-checkbox::before {
  content: ""; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; border: 2px solid #cbd5e1; border-radius: 4px; background: #fff; transition: all .15s ease;
}
.mgtx-filter-body .facetwp-checkbox.checked::before { background: currentColor; border-color: currentColor; }
.mgtx-filter-body .facetwp-checkbox.checked::after {
  content: ""; position: absolute; left: 7px; top: 50%; width: 5px; height: 9px; margin-top: -6px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.mgtx-filter-body .facetwp-checkbox.checked { font-weight: 600; }
.mgtx-filter-body .facetwp-display-value { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mgtx-filter-body .facetwp-counter { flex: 0 0 auto; margin-left: 6px; font-size: .8em; opacity: .6; }
.mgtx-filter-body .facetwp-checkbox.disabled { opacity: .45; cursor: default; }

/* Hierarchy: nested levels + expand toggle */
.mgtx-filter-body .facetwp-depth { margin-left: 18px; padding-left: 8px; border-left: 1px solid rgba(0,0,0,.08); }
.mgtx-filter-body .facetwp-expand {
  flex: 0 0 auto; order: 2; margin-left: 6px; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0; color: inherit; border-radius: 4px;
}
.mgtx-filter-body .facetwp-expand:hover { background: rgba(0,0,0,.06); }
.mgtx-filter-body .facetwp-expand::before {
  content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); margin-top: -3px; transition: transform .15s ease; opacity: .7;
}
.mgtx-filter-body .facetwp-checkbox .facetwp-expand.facetwp-expanded::before,
.mgtx-filter-body .facetwp-depth.facetwp-visible ~ .facetwp-expand::before { transform: rotate(-135deg); margin-top: 3px; }

/* Search / reset facets inside groups or standalone keep theme styling */
.mgtx-filter-body .facetwp-type-search .facetwp-search { width: 100%; }

/* Empty-state preview of a taxonomy's term tree (e.g. Collections before any product is tagged) */
.mgtx-empty-preview { opacity: .6; font-size: .9rem; }
.mgtx-preview-note { margin: 4px 0 8px; font-size: .8rem; font-style: italic; }
.mgtx-preview-list { list-style: none; margin: 0; padding: 0; }
.mgtx-preview-list li { padding: 5px 0 5px 22px; position: relative; line-height: 1.3; }
.mgtx-preview-list li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 14px; height: 14px; border: 2px solid #d1d5db; border-radius: 4px; background: #fff; }
.mgtx-preview-list .mgtx-preview-list { margin-left: 10px; padding-left: 8px; border-left: 1px solid rgba(0,0,0,.08); }
.mgtx-preview-list li.has-children { padding-left: 0; }
.mgtx-preview-list li.has-children::before { display: none; }
.mgtx-preview-list details > summary { list-style: none; cursor: pointer; position: relative; padding: 0 28px 0 22px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.mgtx-preview-list details > summary::-webkit-details-marker { display: none; }
.mgtx-preview-list details > summary::before { content: ""; position: absolute; left: 2px; top: 3px; width: 14px; height: 14px; border: 2px solid #d1d5db; border-radius: 4px; background: #fff; }
.mgtx-preview-chevron { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: .7; transition: transform .15s; margin-right: 6px; }
.mgtx-preview-list details[open] > summary .mgtx-preview-chevron { transform: rotate(-135deg); margin-top: 6px; }

/* Color / Black & White pill toggle (placed next to the sort control above the grid) */
.mgtx-color-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.mgtx-color-toggle .mgtx-color-toggle-label { font-size: .9rem; font-weight: 600; margin-right: 4px; opacity: .8; }
.mgtx-color-toggle .facetwp-facet { display: inline-flex; gap: 6px; margin: 0; }
.mgtx-color-toggle .facetwp-checkbox { padding: 6px 14px; margin: 0; border: 1.5px solid rgba(0,0,0,.18); border-radius: 999px;
  background: #fff !important; font-size: .9rem; line-height: 1.2; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.mgtx-color-toggle .facetwp-checkbox::before, .mgtx-color-toggle .facetwp-checkbox::after { display: none; }
.mgtx-color-toggle .facetwp-checkbox.checked { background: var(--global-palette1, #333) !important; color: #fff; border-color: transparent; }
.mgtx-color-toggle .facetwp-checkbox .facetwp-counter { font-size: .8em; opacity: .7; }
.mgtx-color-toggle .facetwp-checkbox.disabled { opacity: .4; }
.mgtx-color-toggle:not(:has(.facetwp-checkbox)) { display: none; } /* hidden until products carry a colour */

/* Mobile: full-width groups, slightly denser rows */
@media (max-width: 719px) {
  .mgtx-filter-body { max-height: none; }
  .mgtx-filter-body .facetwp-checkbox { min-height: 40px; }
}
