/* ==========================================================================
   css_header.css – cabecera global (Creative Elements + Classic)
   ==========================================================================
   Partes modificadas:
   - Sticky sin salto (sustituye fixed de fixedheader)
   - Modo compacto al scroll (.dil-header-compact): topbar, logo, búsqueda,
     cuenta/carrito y menú con transición suave
   - Compatibilidad con clase .header_omg_im_scrolled del módulo fixedheader
   - Autocompletado AJAX search (CE): input + listado productos

   Responsive:
   - Desktop ≥ 992px: compacto al scroll en 3 filas CE
   - Tablet/móvil ≤ 991px: fijo arriba, tamaño completo (sin compactar)
   ========================================================================== */

#header {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  transition: box-shadow 0.35s ease;
}

#header.dil-header-compact,
#header.header_omg_im_scrolled {
  position: sticky !important;
  top: 0 !important;
  left: auto !important;
  width: 100% !important;
  z-index: 1000;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.08) !important;
}

body.omg_im_fixed {
  padding-top: 0 !important;
}

body.omg_im_fixed .modal-dialog {
  margin-top: 1.75rem !important;
}

/* CE header: 3 filas (topbar / logo+búsqueda / menú) */
#header .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section {
  transition:
    max-height 0.35s ease,
    opacity 0.3s ease,
    padding 0.35s ease,
    margin 0.35s ease;
}

/* Fila 1 – barra negra (teléfono / envío) */
#header .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:first-child {
  max-height: 4.5rem;
  overflow: hidden;
}

#header.dil-header-compact .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:first-child,
#header.header_omg_im_scrolled .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:first-child {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  pointer-events: none;
}

/* Fila 2 – logo, búsqueda, cuenta, carrito (alineado con #wrapper) */
#header .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(2) .elementor-container {
  max-width: var(--dil-layout-max-width, 1460px);
  margin-left: auto;
  margin-right: auto;
  transition: padding 0.35s ease;
}

/* Fila 3 – menú categorías: 100% ancho (sin límite logo↔carrito) */
#header .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(3) .elementor-container {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

/* Anula fixedheader (jQuery): no fixed ni padding extra al scroll */
@media (min-width: 992px) {
  #header.header_omg_im_scrolled {
    position: sticky !important;
    top: 0 !important;
    left: auto !important;
    width: 100% !important;
  }

  #header.header_omg_im_scrolled .header-top {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
}

#header.dil-header-compact .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(2),
#header.header_omg_im_scrolled .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(2) {
  padding-top: 0.35rem !important;
  padding-bottom: 0.35rem !important;
}

#header .elementor-widget-theme-site-logo img {
  display: block;
  width: auto;
  max-height: 5.25rem;
  height: auto;
  transition: max-height 0.35s ease, transform 0.35s ease;
}

#header.dil-header-compact .elementor-widget-theme-site-logo img,
#header.header_omg_im_scrolled .elementor-widget-theme-site-logo img {
  max-height: 2.65rem;
}

/* Texto “SOLOIMPALA / Est.” junto al logo */
#header .elementor-top-section:nth-child(2) .elementor-column:first-child .elementor-widget-heading {
  max-height: 6rem;
  overflow: hidden;
  transition:
    max-height 0.35s ease,
    opacity 0.3s ease,
    margin 0.35s ease;
}

#header.dil-header-compact .elementor-top-section:nth-child(2) .elementor-column:first-child .elementor-widget-heading,
#header.header_omg_im_scrolled .elementor-top-section:nth-child(2) .elementor-column:first-child .elementor-widget-heading {
  max-height: 0 !important;
  opacity: 0;
  margin: 0 !important;
  pointer-events: none;
}

#header .elementor-search__container,
#header .elementor-search__input {
  transition:
    min-height 0.35s ease,
    height 0.35s ease,
    padding 0.35s ease,
    font-size 0.35s ease;
}

#header.dil-header-compact .elementor-search__input,
#header.header_omg_im_scrolled .elementor-search__input {
  min-height: 2.15rem;
  font-size: 0.84rem;
}

#header.dil-header-compact .elementor-search__container,
#header.header_omg_im_scrolled .elementor-search__container {
  min-height: 2.15rem;
}

#header .elementor-widget-shopping-cart .elementor-cart__toggle a.elementor-button,
#header .elementor-widget-sign-in .ce-user-menu .elementor-item {
  transition:
    min-height 0.35s ease,
    height 0.35s ease,
    padding 0.35s ease,
    font-size 0.35s ease,
    gap 0.35s ease;
}

/* Cuenta: dropdown en lista simple (sin columnas del menú catálogo) */
#header .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(2) {
  position: relative;
  z-index: 4;
  overflow: visible !important;
}

#header .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(3) {
  position: relative;
  z-index: 3;
}

#header .elementor-widget-sign-in {
  position: relative;
  z-index: 6;
}

#header .elementor-widget-sign-in > .elementor-widget-container,
#header .elementor-widget-sign-in .ce-user-menu,
#header .elementor-widget-sign-in .ce-user-menu > .elementor-nav {
  overflow: visible !important;
}

#header .elementor-widget-sign-in .ce-user-menu > .elementor-nav > .menu-item-has-children {
  position: relative;
  z-index: 7;
}

#header .elementor-widget-sign-in .ce-user-menu > .elementor-nav > .menu-item-has-children > .sub-menu.elementor-nav--dropdown {
  column-count: 1 !important;
  column-width: auto !important;
  position: absolute !important;
  z-index: 8 !important;
  min-width: 12.5rem;
  max-width: 16rem;
  padding: 0.35rem 0 !important;
  background: var(--dil-white, #fff) !important;
  border: 1px solid var(--dil-line, #ddd8ce);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

#header .elementor-widget-sign-in .ce-user-menu .sub-menu.elementor-nav--dropdown > .menu-item {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  float: none !important;
  margin: 0;
}

#header .elementor-widget-sign-in .ce-user-menu .sub-menu.elementor-nav--dropdown .elementor-sub-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.85rem !important;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--dil-ink, #151515);
  white-space: nowrap;
}

#header .elementor-widget-sign-in .ce-user-menu .sub-menu.elementor-nav--dropdown .elementor-sub-item:hover,
#header .elementor-widget-sign-in .ce-user-menu .sub-menu.elementor-nav--dropdown .elementor-sub-item:focus {
  background: var(--dil-cream, #faf5eb);
  color: var(--dil-black, #000) !important;
}

#header.dil-header-compact .elementor-widget-sign-in .ce-user-menu .menu-item-has-children,
#header.header_omg_im_scrolled .elementor-widget-sign-in .ce-user-menu .menu-item-has-children {
  display: block !important;
  height: auto !important;
}

#header.dil-header-compact .elementor-widget-shopping-cart .elementor-cart__toggle a.elementor-button,
#header.dil-header-compact .elementor-widget-sign-in .ce-user-menu .elementor-item,
#header.header_omg_im_scrolled .elementor-widget-shopping-cart .elementor-cart__toggle a.elementor-button,
#header.header_omg_im_scrolled .elementor-widget-sign-in .ce-user-menu .elementor-item {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.45em !important;
  box-sizing: border-box !important;
  min-height: 2.15rem !important;
  height: 2.15rem !important;
  padding: 0.4rem 0.85rem !important;
  font-size: 0.72rem !important;
  line-height: 1 !important;
}

#header.dil-header-compact .elementor-widget-sign-in .ce-user-menu .elementor-item i,
#header.header_omg_im_scrolled .elementor-widget-sign-in .ce-user-menu .elementor-item i {
  font-size: 0.95em !important;
  line-height: 1 !important;
}

#header.dil-header-compact .elementor-widget-sign-in > .elementor-widget-container,
#header.header_omg_im_scrolled .elementor-widget-sign-in > .elementor-widget-container {
  margin-top: 0 !important;
  display: flex !important;
  align-items: stretch !important;
}

#header.dil-header-compact .elementor-widget-sign-in .ce-user-menu,
#header.dil-header-compact .elementor-widget-sign-in .ce-user-menu > .elementor-nav,
#header.dil-header-compact .elementor-widget-sign-in .ce-user-menu .menu-item,
#header.header_omg_im_scrolled .elementor-widget-sign-in .ce-user-menu,
#header.header_omg_im_scrolled .elementor-widget-sign-in .ce-user-menu > .elementor-nav,
#header.header_omg_im_scrolled .elementor-widget-sign-in .ce-user-menu .menu-item {
  display: flex !important;
  align-items: stretch !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 100% !important;
}

#header.dil-header-compact .elementor-widget-sign-in .ce-user-menu .elementor-item,
#header.header_omg_im_scrolled .elementor-widget-sign-in .ce-user-menu .elementor-item {
  flex: 1 1 auto !important;
  width: 100% !important;
}

#header.dil-header-compact .elementor-widget-shopping-cart .elementor-cart__toggle .elementor-button-icon,
#header.header_omg_im_scrolled .elementor-widget-shopping-cart .elementor-cart__toggle .elementor-button-icon {
  position: relative !important;
  font-size: 1rem !important;
  line-height: 1 !important;
}

#header.dil-header-compact .elementor-widget-shopping-cart .elementor-cart__toggle .elementor-button-icon i,
#header.dil-header-compact .elementor-widget-shopping-cart .elementor-cart__toggle .elementor-button-icon svg,
#header.header_omg_im_scrolled .elementor-widget-shopping-cart .elementor-cart__toggle .elementor-button-icon i,
#header.header_omg_im_scrolled .elementor-widget-shopping-cart .elementor-cart__toggle .elementor-button-icon svg {
  font-size: 1rem !important;
  width: 1rem !important;
  height: 1rem !important;
}

#header.dil-header-compact .elementor-cart--items-indicator-bubble .elementor-cart__toggle .elementor-button-icon[data-counter]::before,
#header.header_omg_im_scrolled .elementor-cart--items-indicator-bubble .elementor-cart__toggle .elementor-button-icon[data-counter]::before {
  font-size: 8px !important;
  min-width: 13px !important;
  width: 13px !important;
  height: 13px !important;
  line-height: 13px !important;
  top: -4px !important;
  right: -5px !important;
}

/* Fila 3 – menú categorías */
#header .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(3) .elementor-item {
  transition:
    padding 0.35s ease,
    font-size 0.35s ease;
}

#header.dil-header-compact .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(3),
#header.header_omg_im_scrolled .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(3) {
  padding-top: 0.15rem !important;
  padding-bottom: 0.15rem !important;
}

#header.dil-header-compact .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(3) .elementor-item,
#header.header_omg_im_scrolled .elementor[data-elementor-type='header'] > .elementor-section-wrap > .elementor-top-section:nth-child(3) .elementor-item {
  padding-top: 0.3rem !important;
  padding-bottom: 0.3rem !important;
  font-size: 0.68rem !important;
}

/* Classic (por si alguna página no usa CE en header) */
#header.dil-header-compact .header-nav,
#header.header_omg_im_scrolled .header-nav {
  display: block !important;
}

#header.dil-header-compact .header-top,
#header.header_omg_im_scrolled .header-top {
  padding-top: 0.35rem !important;
  padding-bottom: 0.35rem !important;
}

/* Tablet + móvil: header fijo arriba, sin modo compacto */
@media (max-width: 991px) {
  #header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1000;
  }

  body.dil-header-mobile-fixed {
    padding-top: var(--dil-header-offset, 0) !important;
  }

  #header .elementor-widget-theme-site-logo img {
    max-height: 3.5rem;
  }
}

@media (max-width: 767px) {
  #header .elementor-widget-theme-site-logo img {
    max-height: 3.25rem;
  }
}

/* ==========================================================================
   Búsqueda AJAX (Creative Elements) – input + resultados
   ========================================================================== */

#header .elementor-widget-ajax-search {
  position: relative;
  /* Por encima de cuenta/carrito: si no, el borde de «LUIS» se ve encima del listado */
  z-index: 20;
  overflow: visible !important;
}

#header .elementor-widget-shopping-cart {
  position: relative;
  z-index: 5;
}

#header .elementor-widget-ajax-search > .elementor-widget-container,
#header .elementor-search,
#header .elementor-search__container {
  overflow: visible !important;
}

#header .elementor-search__container {
  border: 1px solid var(--dil-line, #ddd8ce) !important;
  border-radius: 0 !important;
  background: var(--dil-white, #fff) !important;
  min-height: 2.75rem;
}

#header .elementor-search--focus .elementor-search__container {
  border-color: var(--dil-black, #000) !important;
}

#header .elementor-search__icon {
  color: var(--dil-ink, #151515) !important;
  opacity: 1;
  padding-left: 0.75rem !important;
  padding-right: 0.35rem !important;
}

#header .elementor-search__input {
  color: var(--dil-ink, #151515) !important;
  font-family: var(--dil-font, Montserrat, system-ui, sans-serif);
  font-size: 0.88rem;
  font-weight: 500;
  padding-left: 0.35rem !important;
  padding-right: 2rem !important;
}

#header .elementor-search__input::placeholder {
  color: var(--dil-muted, #7a7a7a);
  opacity: 1;
}

#header .elementor-search__clear {
  padding-right: 0.65rem !important;
  color: var(--dil-muted, #7a7a7a) !important;
}

#header .elementor-search__clear:hover {
  color: var(--dil-black, #000) !important;
}

/* Listado (jQuery UI suele anexarlo al body) */
.elementor-search__products.ui-autocomplete,
ul.elementor-search__products {
  position: absolute !important;
  box-sizing: border-box;
  z-index: 10050 !important;
  isolation: isolate;
  max-width: min(36rem, calc(100vw - 1.5rem));
  max-height: min(28rem, 70vh);
  margin: 0.35rem 0 0 !important;
  padding: 0.35rem 0 !important;
  overflow-x: hidden;
  overflow-y: auto;
  list-style: none;
  background: #fff !important;
  background: var(--dil-white, #fff) !important;
  border: 1px solid var(--dil-line, #ddd8ce) !important;
  border-radius: 0 !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
  font-family: var(--dil-font, Montserrat, system-ui, sans-serif);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.elementor-search__products .elementor-search__product {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.elementor-search__products .elementor-search__product + .elementor-search__product {
  border-top: 1px solid var(--dil-line, #ddd8ce);
}

.elementor-search__products .elementor-search__product a.elementor-search__product-link,
.elementor-search__products .elementor-search__product a.elementor-search__product-link.ui-menu-item-wrapper {
  display: flex !important;
  align-items: flex-start;
  gap: 0.85rem;
  width: 100%;
  margin: 0 !important;
  padding: 0.75rem 1rem !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: inherit;
  text-decoration: none;
  box-sizing: border-box;
}

.elementor-search__products .elementor-search__product a.elementor-search__product-link:hover,
.elementor-search__products .elementor-search__product a.elementor-search__product-link.ui-state-focus,
.elementor-search__products .elementor-search__product a.elementor-search__product-link.ui-state-active {
  background: var(--dil-cream, #faf5eb) !important;
}

.elementor-search__products .elementor-search__product-image {
  flex: 0 0 3.5rem;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 !important;
  object-fit: contain;
  background: var(--dil-cream-soft, #fefcf7);
  border: 1px solid var(--dil-line, #ddd8ce);
  padding: 0.2rem;
  box-sizing: border-box;
}

.elementor-search__products .elementor-search__product-details {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.elementor-search__products .elementor-search__product-name {
  color: var(--dil-ink, #151515) !important;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.35;
  text-transform: uppercase;
}

.elementor-search__products .elementor-search__product-category {
  color: var(--dil-muted, #7a7a7a) !important;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.3;
}

.elementor-search__products .elementor-search__product-description {
  color: var(--dil-muted, #7a7a7a) !important;
  font-size: 0.72rem;
  line-height: 1.35;
}

.elementor-search__products .elementor-search__product-price {
  margin-top: 0.15rem;
  color: var(--dil-red, oklch(55% 0.19 27)) !important;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
}

.elementor-search__products .elementor-search__product-price del {
  margin-right: 0.35rem;
  color: #9a9488 !important;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 1;
}

@media (max-width: 991px) {
  .elementor-search__products.ui-autocomplete,
  ul.elementor-search__products {
    max-width: calc(100vw - 1.5rem) !important;
    width: calc(100vw - 1.5rem) !important;
    max-height: min(24rem, 60vh);
    left: 0.75rem !important;
    right: 0.75rem !important;
  }

  #header .elementor-search__container {
    min-height: 2.55rem;
  }

  #header .elementor-search__input {
    font-size: 0.84rem;
  }
}

@media (max-width: 767px) {
  #header .elementor-search__icon {
    padding-left: 0.65rem !important;
  }

  #header .elementor-search__clear {
    padding-right: 0.55rem !important;
  }

  .elementor-search__products.ui-autocomplete,
  ul.elementor-search__products {
    max-width: calc(100vw - 1rem) !important;
    width: calc(100vw - 1rem) !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    padding: 0.25rem 0 !important;
  }

  .elementor-search__products .elementor-search__product a.elementor-search__product-link,
  .elementor-search__products .elementor-search__product a.elementor-search__product-link.ui-menu-item-wrapper {
    gap: 0.7rem;
    padding: 0.7rem 0.85rem !important;
  }

  .elementor-search__products .elementor-search__product-image {
    flex-basis: 3.1rem;
    width: 3.1rem;
    height: 3.1rem;
  }

  .elementor-search__products .elementor-search__product-name {
    font-size: 0.74rem;
  }

  .elementor-search__products .elementor-search__product-price {
    font-size: 0.86rem;
  }
}
