/**
 * Ecomlabs Advanced Search — front styles.
 * Scoped under .eladvs-* to avoid clashing with the active theme.
 *
 * @author Ecomlabs <info@ecomlabs.es>
 */

.eladvs-overlay {
  --eladvs-primary: #111111;
  --eladvs-accent: #e30613;
  --eladvs-bar-bg: #ffffff;
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: block;
}

.eladvs-overlay[hidden] {
  display: none;
}

html.eladvs-locked {
  overflow: hidden;
}

.eladvs-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.eladvs-overlay.is-open .eladvs-overlay__backdrop {
  opacity: 1;
}

.eladvs-panel {
  position: relative;
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  max-height: 100vh;
  background: #fff;
  border-radius: 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  transform: translateY(-16px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.eladvs-overlay.is-open .eladvs-panel {
  transform: translateY(0);
  opacity: 1;
}

/* Full-width background, content constrained to a centered container. */
.eladvs-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 10px;
}

/* --- top bar --- */
/* Same height as the storefront #header on desktop. The exact height is measured
   from #header by the JS and exposed as --eladvs-bar-h (fallback 75px). */
.eladvs-panel__bar {
  height: var(--eladvs-bar-h, 75px);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0;
  border-bottom: 1px solid #eee;
  background: var(--eladvs-bar-bg, #fff);
}

.eladvs-bar__inner {
  display: flex;
  align-items: center;
  gap: 16px;
}

.eladvs-logo {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.eladvs-logo img {
  display: block;
  /* Matched at runtime to the #header logo (see syncLogoSize in advsearch.js). */
  height: var(--eladvs-logo-h, 44px);
  width: var(--eladvs-logo-w, auto);
}

.eladvs-searchbox {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}

.eladvs-searchbox__icon {
  position: absolute;
  left: 12px;
  color: #888;
  pointer-events: none;
}

.eladvs-input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 42px;
  font-size: 16px;
  border: 2px solid #e6e6e6;
  border-radius: 25px;
  outline: none;
  color: var(--eladvs-primary);
  background: #fafafa;
}

.eladvs-input:focus {
  border-color: var(--eladvs-accent);
  background: #fff;
}

.eladvs-clear {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: #999;
  cursor: pointer;
}

.eladvs-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.eladvs-close:hover {
  background: transparent;
}

/* --- body --- */
.eladvs-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
}

/* Flex item of .eladvs-body: stretches to the body's (capped) height so the
   facets/main columns inside can scroll. No height:100% (it does not resolve
   against a flex-sized parent). */
.eladvs-body__inner {
  display: flex;
  min-height: 0;
}

.eladvs-facets {
  flex: 0 0 260px;
  min-height: 0;
  border-right: 1px solid #eee;
  overflow-y: auto;
  padding: 16px;
  background: #fafafa;
}

.eladvs-facets[hidden] {
  display: none;
}

/* "Buscador avanzado" toggle — only used on mobile to reveal the filters panel
   (hidden on desktop, where the filters are always visible). */
.eladvs-facets-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 20px;
  margin-bottom: 12px;
  padding: 11px 14px;
  border: 1px solid var(--eladvs-primary);
  border-radius: 8px;
  background: #fff;
  color: var(--eladvs-primary);
  font-family: 'Unbounded';
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.eladvs-facets-toggle svg {
  flex: 0 0 auto;
}

.eladvs-facets__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.eladvs-clearfilters {
  border: 0;
  background: transparent;
  color: var(--eladvs-accent);
  font-size: 12px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.eladvs-facet {
  margin-bottom: 18px;
}

.eladvs-facet__title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 300;
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--eladvs-primary);
}

.eladvs-facet__values {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.eladvs-facet__value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.eladvs-facet__label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eladvs-facet__count {
  flex: 0 0 auto;
  color: #999;
  font-size: 12px;
}

.eladvs-facet__price {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eladvs-facet__price input {
  width: 80px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
}

/* --- dropdown style (native select with custom chevron, menu look) --- */
.eladvs-facet__control {
  position: relative;
}

.eladvs-facet__select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  padding: 9px 34px 9px 12px;
  background: #fff;
  border: 1px solid #d4d4d4;
  border-radius: 5px;
  font-size: 13px;
  color: var(--eladvs-primary);
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.eladvs-facet__select:hover {
  border-color: #a8a8a8;
}

.eladvs-facet__select:focus {
  outline: none;
  border-color: var(--eladvs-accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.eladvs-facet__select.has-value {
  border-color: var(--eladvs-accent);
}

.eladvs-facet__control::after {
  content: '';
  position: absolute;
  right: 13px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--eladvs-accent);
  border-bottom: 2px solid var(--eladvs-accent);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

/* --- chips style (toggle pills) --- */
.eladvs-facet__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.eladvs-chip {
  appearance: none;
  border: 1px solid #d4d4d4;
  background: #fff;
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--eladvs-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.eladvs-chip:hover {
  border-color: #a8a8a8;
}

.eladvs-chip.is-active {
  border-color: var(--eladvs-accent);
  background: var(--eladvs-accent);
  color: #fff;
}

/* --- dimensions group (Largo/Ancho/Alto + Exterior/Interior toggle) --- */
.eladvs-dims__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.eladvs-dims__title {
  margin-bottom: 0;
}

/* Pill toggle: Exterior / Interior. */
.eladvs-dims__tabs {
  display: inline-flex;
  flex: 0 0 auto;
  background: #f0f0f2;
  border-radius: 999px;
  padding: 3px;
}

.eladvs-dims__tab {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--eladvs-primary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.eladvs-dims__tab.is-active {
  background: var(--eladvs-primary);
  color: #fff;
}

.eladvs-dims__cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.eladvs-dims__col {
  min-width: 0;
}

.eladvs-dims__axis {
  font-size: 12px;
  color: var(--eladvs-primary);
  margin-bottom: 6px;
  font-family: 'Poppins';
  font-weight: 500;
}

/* Free numeric measure input (the user types the quantity). */
.eladvs-dims__measure {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid #d4d4d4;
  border-radius: 5px;
  font-size: 13px;
  color: var(--eladvs-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.eladvs-dims__measure::placeholder {
  color: #8a8a8a;
}

.eladvs-dims__measure:hover {
  border-color: #a8a8a8;
}

.eladvs-dims__measure:focus {
  outline: none;
  border-color: var(--eladvs-accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.eladvs-dims__measure.has-value {
  border-color: var(--eladvs-accent);
}

/* Tolerance: "+ Añadir tolerancia" link and its ± mm editor. */
.eladvs-dims__tol {
  margin-top: 6px;
}

.eladvs-dims__tol-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 2px 0;
  font-size: 12.5px;
  color: var(--eladvs-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.eladvs-dims__tol-toggle:hover {
  color: var(--eladvs-accent);
}

.eladvs-dims__tol-plus {
  font-size: 15px;
  line-height: 1;
}

.eladvs-dims__tol-editor {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--eladvs-primary);
}

.eladvs-dims__tol-pm {
  font-size: 14px;
}

.eladvs-dims__tol-input {
  width: 64px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #d4d4d4;
  border-radius: 5px;
  font-size: 13px;
}

.eladvs-dims__tol-input:focus {
  outline: none;
  border-color: var(--eladvs-accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.eladvs-dims__tol-unit {
  color: #777;
}

.eladvs-dims__tol-remove {
  appearance: none;
  border: 0;
  background: transparent;
  color: #999;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.eladvs-dims__tol-remove:hover {
  color: var(--eladvs-accent);
}

/* --- main --- */
.eladvs-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
}

.eladvs-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.eladvs-count {
  font-size: 14px;
  color: #555;
}

.eladvs-sort {
  height: 38px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
}

.eladvs-results {
  display: grid;
  grid-template-columns: repeat(var(--eladvs-cols-desktop, 4), minmax(0, 1fr));
  gap: 16px;
}

/* Each result fills its grid cell; neutralise any Bootstrap column classes the
   storefront miniature may carry (col-xs-6 col-xl-3) since our grid owns the
   columns. */
.eladvs-results > * {
  min-width: 0;
  max-width: 100%;
}

.eladvs-results > [class*="col-"] {
  width: 100%;
  max-width: 100%;
  flex: 0 0 100%;
  float: none;
  padding-left: 0;
  padding-right: 0;
}

/* Same card framing as the storefront listing
   (#js-product-list .products article.elementor-section-wrap). */
.eladvs-results article.elementor-section-wrap {
  border: 1px solid #d4d4d4;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 20px;
}

.eladvs-results article .elementor-widget-wrap .elementor-widget {
  margin-bottom: 0px !important;
}

/* Tablet column count. */
@media (max-width: 1024px) {
  .eladvs-results {
    grid-template-columns: repeat(var(--eladvs-cols-tablet, 3), minmax(0, 1fr));
  }
}

.eladvs-card {
  display: flex;
  flex-direction: column;
  border: 1px solid #eee;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--eladvs-primary);
  background: #fff;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.eladvs-card:hover {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.eladvs-card__media {
  aspect-ratio: 1 / 1;
  background: #f7f7f7;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.eladvs-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.eladvs-card__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 14px;
}

.eladvs-card__brand {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #999;
}

.eladvs-card__name {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.eladvs-card__ref {
  font-size: 11px;
  color: #aaa;
}

.eladvs-card__price {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--eladvs-accent);
}

/* --- results meta: "xx productos" (left) + sort dropdown (right) --- */
.eladvs-sortwrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
}

.eladvs-sortwrap__label {
  font-size: 13px;
  color: #555;
}

/* --- states --- */
.eladvs-state {
  padding: 32px 12px;
  text-align: center;
  color: #777;
  font-size: 15px;
}

.eladvs-state[hidden] {
  display: none;
}

.eladvs-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 0 4px;
}

.eladvs-loadmore {
  height: 42px;
  padding: 0 22px;
  border: 2px solid var(--eladvs-primary);
  background: #fff;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'Unbounded';
}

.eladvs-loadmore[hidden] {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- responsive --- */
@media (max-width: 768px) {
  .eladvs-panel {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }

  .eladvs-container {
    padding: 0 16px;
  }

  .eladvs-panel__bar {
    height: auto;
    padding: 10px 0;
  }

  /* Logo + buscador + cerrar en una sola fila, alineados verticalmente. */
  .eladvs-bar__inner {
    flex-wrap: nowrap;
    gap: 10px;
  }

  .eladvs-searchbox {
    min-width: 0;
  }

  /* En móvil no se muestra el logo (se prioriza la caja de búsqueda). */
  .eladvs-logo {
    display: none;
  }

  /* Mobile: the whole body scrolls as a single column (filters stacked above
     results), instead of two independently-scrolling columns. */
  .eladvs-body {
    display: block;
    overflow-y: auto;
  }

  .eladvs-body__inner {
    flex-direction: column;
  }

  .eladvs-facets,
  .eladvs-main {
    overflow: visible;
  }

  .eladvs-main {
    padding: 0;
  }

  .eladvs-facets {
    flex: 1 1 auto;
    border-right: 0;
    border-bottom: 1px solid #eee;
  }

  /* Filters collapsed by default; the "Buscador avanzado" button reveals them. */
  .eladvs-facets-toggle {
    display: flex;
  }

  .eladvs-facets {
    display: none;
  }

  .eladvs-overlay.is-facets-open .eladvs-facets {
    display: block;
  }

  .eladvs-results {
    grid-template-columns: repeat(var(--eladvs-cols-mobile, 2), minmax(0, 1fr));
  }

  .eladvs-results article.elementor-section-wrap {
    margin-bottom: 0px;
  }
}
