/*
 * AWTFilter frontend styles
 * Milestone 6: UX polish (non-AJAX)
 * - Card container + header (Filter title + Clear All)
 * - Active filter chips
 * - Collapsible sections (accordion)
 * - Theme-friendly, minimal CSS (prefixed)
 */

.awtfilter {
  position: relative;
}

.awtfilter-card {
  position: sticky;
  top: var(--awtfilter-sticky-top, 16px);
  max-height: var(--awtfilter-sticky-max-height, 80vh);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-sizing: border-box;
}

/*
 * In widget/sidebar usage (Flatsome left sidebar), make the entire widget sticky
 * so the widget title + divider + filter card stay together while the card body
 * keeps its own inner scroll. Outside widgets, the card itself remains sticky.
 *
 * IMPORTANT:
 * Flatsome rows are flex-based. The sidebar column needs to remain stretched to the
 * row height, otherwise sticky elements have no vertical travel room. So we keep the
 * row/column stretched and only control overflow visibility here.
 */
.widget.awtfilter_widget {
  position: sticky;
  top: var(--awtfilter-sticky-top, 16px);
  overflow: visible !important;
  align-self: stretch !important;
  width: 100%;
  z-index: 5;
}

.widget.awtfilter_widget .awtfilter-card {
  position: relative;
  top: auto;
}

.page-left-sidebar,
.page-left-sidebar > .row,
.page-left-sidebar > .row > .col,
.page-left-sidebar > .row > .large-3.col.col-first.col-divided,
.page-left-sidebar > .row > .large-3.col.col-first.col-divided #secondary,
.page-left-sidebar > .row > .large-3.col.col-first.col-divided .widget.awtfilter_widget,
.page-left-sidebar > .row > .large-3.col.col-first.col-divided .awtfilter {
  overflow: visible !important;
}

.page-left-sidebar > .row {
  align-items: stretch !important;
}

.page-left-sidebar > .row > .large-3.col.col-first.col-divided {
  align-self: stretch !important;
  display: flex;
  flex-direction: column;
}

.page-left-sidebar > .row > .large-3.col.col-first.col-divided #secondary {
  position: relative;
  align-self: stretch !important;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
}

.widget.awtfilter_widget.awtfilter-sticky-fixed {
  position: fixed !important;
  top: var(--awtfilter-sticky-top, 16px) !important;
  left: var(--awtfilter-sticky-left, auto) !important;
  width: var(--awtfilter-sticky-width, auto) !important;
  margin-top: 0 !important;
}

.widget.awtfilter_widget.awtfilter-sticky-bottom {
  position: absolute !important;
  top: var(--awtfilter-sticky-bottom-top, 0px) !important;
  left: 0 !important;
  width: 100% !important;
  margin-top: 0 !important;
}

.awtfilter-sticky-placeholder {
  display: none;
  width: 100%;
  pointer-events: none;
}

.awtfilter-card__header {
  flex: 0 0 auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, #f5f6f8 0%, #e9ebf0 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
	
}

.awtfilter-card__header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.awtfilter-card__mobile-toggle {
  display: none;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px;
  margin: 0;
  width: 34px;
  height: 34px;
  cursor: pointer;
  color: inherit;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

.awtfilter-card__mobile-toggle svg {
  transition: transform 140ms ease;
}

.awtfilter-card__mobile-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.awtfilter-card__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
}

.awtfilter-card__title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.15;
}

.awtfilter-card__title-text {
  display: inline-block;
  line-height: 1.15;
}

.awtfilter-card__title-icon {
  display: none;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: currentColor;
}

.awtfilter-card__title-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.awtfilter-card__clear {
  height: auto;
	padding: 8px 12px;
	border: 0;
	border-radius: 10px !important;
	background: #fff;
	color: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: normal;
	box-shadow: none;
	cursor: pointer;
	color: black !important;
}

.awtfilter-card__clear:hover {
  opacity: 0.8;
}

.awtfilter-chips {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  max-height: 140px;
  overflow-y: auto;
  overflow-x: hidden;
}

.awtfilter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.02);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.2;
}

.awtfilter-chip:hover {
  text-decoration: none;
}

.awtfilter-chip__x {
  font-size: 16px;
  line-height: 1;
  opacity: 0.65;
}

.awtfilter-card__body {
  padding: 0 16px 16px 16px;
}

.awtfilter-form {
  margin: 0;
  min-height: 100%;
}

.awtfilter-groups {
  display: block;
}

.awtfilter-group {
  padding: 12px 0;
  margin: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.awtfilter-group:first-child {
  border-top: 0;
}

.awtfilter-group__header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.awtfilter-group__title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.awtfilter-group__title-text {
  font-weight: 800;
  font-size: 16px;
  line-height: 1.2;
}

.awtfilter-group-toggle {
	margin-bottom:0px !important;
  margin-left: auto;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  min-height:auto;
}

.awtfilter-group-toggle svg {
  transition: transform 140ms ease;
}

/* Rotate chevron up when expanded */
.awtfilter-group-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.awtfilter-group__content {
  margin-top: 12px;
}

/* Optional description text shown under a group title (e.g., Bath Space) */
.awtfilter-group__desc {
  margin: 0 0 12px 0;
  color: rgba(0, 0, 0, 0.55);
  font-size: 16px;
  line-height: 1.35;
}

.awtfilter-group__content[hidden] {
  display: none !important;
}

/* Tooltip */
.awtfilter-tooltip {
  display: inline-flex;
  align-items: center;
}

.awtfilter-tooltip-btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #114165;
  opacity: 0.95;
}

.awtfilter-tooltip-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.awtfilter-tooltip-btn:hover {
  opacity: 1;
}

.awtfilter-tooltip-btn:focus {
  outline: 2px solid rgba(0, 0, 0, 0.25);
  outline-offset: 2px;
}

.awtfilter-tooltip-portal {
  position: fixed;
  z-index: 999999;
  min-width: 180px;
  max-width: 300px;
  background: #111;
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: pre-line;
  pointer-events: none;
}

.awtfilter-tooltip-portal[hidden] {
  display: none !important;
}

/* Options */
.awtfilter-options {
  list-style: none;
  margin: 0;
  padding: 0;
}

.awtfilter-option {
  margin: 0 0 10px 0;
}

.awtfilter-option__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.awtfilter-option__left {
  display: inline-flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.awtfilter-option__label {
  font-weight: 400;
	font-size: 16px;
	line-height:20px
}

.awtfilter-option__count {
  opacity: 0.55;
  font-weight: 700;
}

/* Checkbox sizing (requested UI polish) */
.awtfilter-option input[type="checkbox"],
.awtfilter-tree-label input[type="checkbox"],
.awtfilter-option__left input[type="checkbox"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  box-sizing: border-box !important;
  display: inline-block !important;
  position: relative !important;
  width: 20px !important;
  max-width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  flex: 0 0 20px !important;
  -webkit-box-flex: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
  margin-left: 0 !important;
  margin-top: 0 !important;
  align-self: flex-start !important;
  border: 1.5px solid rgba(0, 0, 0, 0.35) !important;
  border-radius: 4px !important;
  background: #fff !important;
  box-shadow: none !important;
  vertical-align: top !important;
  cursor: pointer;
}

.awtfilter-option input[type="checkbox"]:checked,
.awtfilter-tree-label input[type="checkbox"]:checked,
.awtfilter-option__left input[type="checkbox"]:checked {
  background: #2b7cff !important;
  border-color: #2b7cff !important;
}

.awtfilter-option input[type="checkbox"]:checked::after,
.awtfilter-tree-label input[type="checkbox"]:checked::after,
.awtfilter-option__left input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 11px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.awtfilter-option input[type="checkbox"]:focus,
.awtfilter-tree-label input[type="checkbox"]:focus,
.awtfilter-option__left input[type="checkbox"]:focus {
  outline: 2px solid rgba(17, 65, 101, 0.28);
  outline-offset: 2px;
}

.awtfilter-actions {
  margin-top: 14px;
}

.awtfilter-apply {
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 800;
}

.awtfilter-group__empty,
.awtfilter-note {
  opacity: 0.75;
  font-size: 0.95em;
}

/*
 * Meta (custom field) inputs (Milestone 5)
 */

.awtfilter-input,
.awtfilter-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.awtfilter-range {
  display: flex;
  gap: 10px;
}

.awtfilter-range .awtfilter-input {
  flex: 1;
}

/*
 * Product category tree
 * - Collapsible nested categories with plus/minus toggle (SVG)
 */

.awtfilter-tree,
.awtfilter-tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.awtfilter-tree-node {
  margin: 0 0 10px 0;
}

.awtfilter-tree-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.awtfilter-tree-label {
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: flex-start;
  gap: 12px;
}

.awtfilter-tree-toggle {
  -webkit-appearance: none;
  appearance: none;
  border: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  border-radius: 0;
  line-height: 1;
  opacity: 0.9;
  box-shadow: none !important;
  flex: 0 0 20px;
  align-self: flex-start;
}

.awtfilter-tree-toggle:hover {
  opacity: 1;
  background: transparent !important;
}

.awtfilter-tree-toggle:active {
  background: transparent !important;
}

.awtfilter-tree-toggle .awtfilter-icon {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  width: 20px;
  height: 20px;
  line-height: 0;
}

.awtfilter-tree-toggle svg {
  display: block;
}

.awtfilter-tree-toggle:focus {
  outline: 2px solid rgba(0, 0, 0, 0.25);
  outline-offset: 2px;
}

.awtfilter-tree-toggle .awtfilter-icon--minus {
  display: none;
}

.awtfilter-tree-toggle[aria-expanded="true"] .awtfilter-icon--plus {
  display: none;
}

.awtfilter-tree-toggle[aria-expanded="true"] .awtfilter-icon--minus {
  display: inline-flex;
}

.awtfilter-tree-spacer {
  display: inline-block;
  width: 20px;
  height: 20px;
}

.awtfilter-tree-children {
  margin-top: 10px;
  margin-left: 20px !important;
}


@media (max-width: 849px) {
  .awtfilter-card {
    position: relative;
    top: auto;
    max-height: none;
  }

  .widget.awtfilter_widget,
  .widget.awtfilter_widget.awtfilter-sticky-fixed,
  .widget.awtfilter_widget.awtfilter-sticky-bottom {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    margin-top: 0 !important;
  }

  .awtfilter-sticky-placeholder {
    display: none !important;
    height: 0 !important;
  }

  .awtfilter-card__header {
    cursor: pointer;
    user-select: none;
		background: #114165 !important;
  }
	.awtfilter-card__mobile-toggle{
		color:white;
	}
	.awtfilter-card__title{
		color:white;
	}

  .awtfilter-card__mobile-toggle {
    display: inline-flex;
  }

  .awtfilter-card__title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .awtfilter-card__body,
  .awtfilter-chips {
    overflow: visible !important;
    max-height: none !important;
  }

  .awtfilter-card--mobile-collapsed .awtfilter-chips,
  .awtfilter-card--mobile-collapsed .awtfilter-card__body {
    display: none !important;
  }
}

/*
 * Shortcode instances are never sticky (the sticky JS targets .widget.awtfilter_widget),
 * so the 80vh cap that keeps a sticky card in view serves no purpose here — it only
 * produces an inner scrollbar. Let the card size to its content and scroll with the page.
 */
.awtfilter--shortcode .awtfilter-card {
  position: static;
  max-height: none;
}

.awtfilter--shortcode .awtfilter-card__body,
.awtfilter--shortcode .awtfilter-chips {
  max-height: none;
  overflow: visible;
}
