.header-top .icon-square {
  padding: 7px !important;
}

.nav-icons svg {
  fill: #333;
  max-width: 24px;
}

/* Móvil: los SVG de contacto/usuario no traen width/height y salían
       pequeños. Se fuerzan dimensiones explícitas y homogéneas.
       (Va en header.tpl porque su hook_extra sí se emite; el de
       header-mobile.tpl queda descartado por colisión de block name.) */
@media (max-width: 991px) {
  .header-top .nav-icons .icon-square {
    padding: 2px !important;
  }
  .header-top .nav-icons svg {
    width: 26px !important;
    height: 26px !important;
    max-width: none !important;
  }
}

.nav-icons div:hover > svg {
  fill: #ffdd00 !important;
}
#account-button-logged > a > svg {
  fill: #ffdd00 !important;
}

.user-dropdown-menu {

  max-width: 200px;
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--bs-gray-200);
  z-index: 1000;

}

.user-dropdown-menu {
  & > li::before {
    font-family: "Material Symbols Outlined";
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 48;
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
    font-size: 1.2rem;
    color: #333;
  }

  & > li:nth-of-type(1) {
    display: grid;
    place-items: center;
  }
  & > li:nth-of-type(3) {
    border-top: 1px solid var(--bs-gray-200);
  }

  & > li:nth-of-type(4) {
    border-top: 1px solid var(--bs-gray-200);
  }


  & > li:nth-of-type(5) {
    border-top: 1px solid var(--bs-gray-200);
  }


  & > li:nth-of-type(6) {
    border-top: 1px solid var(--bs-gray-200);
  }
  & > li:nth-of-type(7).fav::before {
    font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 48;
    color: red !important;
  }
  & > li:nth-of-type(7) {
    border-top: 1px solid var(--bs-gray-200);
  }
  & > li:nth-of-type(8) {
    border-top: 1px solid var(--bs-gray-200);
  }

}
@media(max-width: 575px) {
  .user-dropdown-menu li svg {
    max-width:24px !important
  }
  .user-dropdown-menu li:nth-of-type(6) a {
    font-size:0.82rem !important
  }
      .nav-icons div:hover > svg {
      fill: #ffdd00 !important;
    }
    #account-button-logged > a > svg {
      fill: #ffdd00 !important;
    }
    .user-dropdown-menu li::before {
      content: '' !important;
      display: none !important;
    }
    .user-dropdown-menu li svg {
      fill: #333;
      margin-right: 4px;
      max-width: 1.2rem !important;
    }
     .user-dropdown-menu li:hover > svg {
      fill: #ffdd00 !important;
    }
    svg.hasfavs {
      display:none;
      fill:red !important;
    }
    .user-dropdown-menu li.fav > svg.nofavs {
      display: none !important;
    }
    .user-dropdown-menu li.fav > svg.hasfavs {
      display: inline-block !important;
    }
}

.user-dropdown-menu li {
  padding: 0.5rem 1rem;
  color: var(--bs-primary);
  font-size: 1rem;
  text-decoration: none;
  display: block;
  text-align: left;

  & a {
    display: inline-block;
    width: max-content;
    height: 100%;
    font-size: 0.9rem;
  }
}

.user-dropdown-menu li:nth-last-of-type(1) {
  margin-bottom: 0.5rem;
}

.user-dropdown-menu.unfolded {
  display: block;
}

.user-dropdown-menu li::before {
  content: "" !important;
  display: none !important;
}
.user-dropdown-menu li svg {
  fill: #333;
  margin-right: 4px;
  max-width: 1.2rem !important;
}
.user-dropdown-menu li:hover > svg {
  fill: #ffdd00 !important;
}
svg.hasfavs {
  display: none;
  fill: red !important;
}
.user-dropdown-menu li.fav > svg.nofavs {
  display: none !important;
}
.user-dropdown-menu li.fav > svg.hasfavs {
  display: inline-block !important;
}
/* Botón: conserva el aspecto del icono */
#ml-account-trigger {
  anchor-name: --ml-account-trigger;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

#ml-account-trigger:focus-visible {
  outline: 2px solid #175cd3;
  outline-offset: 4px;
}

/* Popover */
#ml-account-popover {
  position: fixed;
  inset: 90px 16px auto auto;
  margin: 0;

  box-sizing: border-box;
  width: min(280px, calc(100vw - 24px));
  max-height: calc(100dvh - 102px);
  padding: 8px;

  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;

  border: 1px solid #e7ebf0;
  border-radius: 14px;
  background: #fff;
  color: #243044;

  box-shadow:
    0 20px 60px rgb(15 23 42 / 16%),
    0 3px 12px rgb(15 23 42 / 6%);

  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;

  scrollbar-width: thin;
  scrollbar-color: #cbd3df transparent;

  opacity: 0;
  clip-path: inset(0 0 100% 0 round 14px);

  transition:
    opacity 180ms ease,
    clip-path 280ms cubic-bezier(0.22, 1, 0.36, 1),
    display 280ms allow-discrete,
    overlay 280ms allow-discrete;
}

#ml-account-popover:popover-open {
  opacity: 1;
  clip-path: inset(0 0 0 0 round 14px);
}

@starting-style {
  #ml-account-popover:popover-open {
    opacity: 0;
    clip-path: inset(0 0 100% 0 round 14px);
  }
}

/* Anclaje al botón de usuario */
@supports (top: anchor(bottom)) {
  #ml-account-popover {
    position-anchor: --ml-account-trigger;
    inset: auto;
    margin: 0;

    top: calc(anchor(bottom, 78px) + 12px);
    right: anchor(right, 16px);

    max-height: max(0px, calc(100dvh - anchor(bottom, 78px) - 24px));
  }
}

#ml-account-popover *,
#ml-account-popover *::before,
#ml-account-popover *::after {
  box-sizing: border-box;
}

/* Saludo */
#ml-account-popover > li:first-child {
  display: block;
  margin: 0;
  padding: 12px;
  color: #243044;
  font-size: 14px;
  font-weight: 600;
}

/* Filas: icono y enlace */
#ml-account-popover > li:not(:first-child):not(.ml-account-popover__separator) {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin: 0;
  padding: 10px 12px;

  border: 0;
  border-radius: 0;
  background: transparent;

  transition: background-color 150ms ease;
}

#ml-account-popover
  > li:not(:first-child):not(.ml-account-popover__separator):hover {
  background: #f3f6fa;
}

/* SVG existentes */
#ml-account-popover > li > svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
  color: #64748b;
  pointer-events: none;
}

/* Mantiene el rojo del corazón relleno */
#ml-account-popover > li > svg.hasfavs {
  color: #dc2626;
}

/* Enlaces */
#ml-account-popover > li > a {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;

  color: #243044;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
}

/* Hace clicable toda la fila */
#ml-account-popover > li > a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
}

#ml-account-popover > li:focus-within {
  background: #f3f6fa;
}

#ml-account-popover > li > a:focus-visible {
  outline: none;
}

#ml-account-popover > li > a:focus-visible::after {
  outline: 2px solid #175cd3;
  outline-offset: -2px;
}

/* Separadores */
#ml-account-popover > .ml-account-popover__separator {
  display: block;
  height: 1px;
  min-height: 0;
  margin: 6px 12px;
  padding: 0;
  border: 0;
  background: #e7ebf0;
}

/* Cerrar sesión */
#ml-account-popover > li:last-child > a,
#ml-account-popover > li:last-child > svg {
  color: #b42318;
}

#ml-account-popover > li:last-child:hover {
  background: #fff3f2;
}

@media (max-width: 480px) {
  #ml-account-popover {
    right: 12px;
    left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  #ml-account-popover,
  #ml-account-popover * {
    transition: none;
  }
}
#search_input {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: none;
  background: white;
  + svg {
    z-index: 3;
  }
}

/* ============================================================
       Modernización cabecera 2026 — compacta + glassmorphism.
       Solo CSS; no se cambian ids/clases (menús/modales intactos).
       #header ya es sticky (top:0; z-index:99) en el tema.
       ============================================================ */
#header .header-top {
  padding: 8px 15px !important; /* compacto: 8px block / 15px inline (gana a la regla del tema) */
  background: rgba(255, 255, 255, 0.72) !important;
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid rgba(16, 18, 21, 0.06);
  box-shadow: 0 6px 22px -14px rgba(16, 18, 21, 0.45);
}

/* Logo compacto (160-180px) — solo desktop, no toca la versión móvil */
@media (min-width: 992px) {
  #header #_desktop_logo {
    width: 170px !important;
    flex: 0 0 170px !important; /* el logo es flex item con flex-basis:200px; hay que forzarlo aquí */
    max-width: 170px !important;
  }
  #header #_desktop_logo .imglogo {
    width: 100% !important;
    height: auto !important;
    display: block;
  }
}

/* Botones de navegación: SIN borde (excepto la búsqueda) */
.nav-icons .icon-square {
  border: none !important;
  border-radius: 10px;
  transition: background-color 0.16s ease;
}
.nav-icons .icon-square:hover {
  background-color: rgba(16, 18, 21, 0.05);
}
/* Búsqueda: mantiene borde, forma de píldora y recorta el input (que va absoluto por dentro) */
.nav-icons #search-icon {
  border: 1px solid rgba(16, 18, 21, 0.14) !important;
  border-radius: 50vw !important;
  overflow: hidden;
}
.nav-icons #search-icon:hover {
  border-color: rgba(16, 18, 21, 0.3) !important;
  background-color: transparent;
}

/* Contador del carrito: badge con color de marca */
#cart-on .products_in_cart {
  background: #ffdd00 !important;
  color: #101215 !important;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
  top: 8px !important;
  right: 8px !important;
}

/* ============================================================================
   CABECERA 3 NIVELES (2026-10-06) — solo escritorio (≥992px)
   .ml-hdr envuelve nivel 2 (.header-top) + nivel 3 (.header-nav) y lleva el glass.
   (El glass NO va en #header: atraparía los modales position:fixed de la cabecera.)
   ============================================================================ */
@media (min-width: 992px) {
  #header .ml-hdr {
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(8px) saturate(150%);
    backdrop-filter: blur(8px) saturate(150%);
    border-bottom: 1px solid rgba(16, 18, 21, 0.06);
    box-shadow: 0 6px 22px -14px rgba(16, 18, 21, 0.45);
  }

  /* ---- Nivel 2: logo | buscador ancho centrado | ubicación | iconos ---- */
  #header .ml-hdr .header-top {
    display: grid !important;
    grid-template-columns: 170px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: clamp(1rem, 2vw, 2.25rem);
    max-width: 1860px;
    margin-inline: auto;
    padding: 10px clamp(15px, 2vw, 30px) !important;
    background: transparent !important;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 0;
    box-shadow: none !important;
  }
  #header .ml-hdr .header-top .menu-icon {
    display: none !important;
  }

  #header .ml-hdr-search {
    display: flex;
    justify-content: center;
    min-width: 0;
  }
  #header .ml-hdr-search #search-icon {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 680px !important;
    height: 44px !important;
    padding: 0 14px !important;
    justify-content: flex-end;
    background: #fff;
    border: 1px solid rgba(16, 18, 21, 0.14) !important;
    border-radius: 50vw !important;
    overflow: hidden;
  }
  #header .ml-hdr-search #search-icon:hover {
    border-color: rgba(16, 18, 21, 0.3) !important;
  }
  #header .ml-hdr-search #search-icon::after {
    display: none !important;
  } /* se usa el placeholder (traducible) */
  /* Lupa a la izquierda (el svg trae right:0 en línea → se sobrescribe) */
  #header .ml-hdr-search #search-icon > svg {
    left: 16px !important;
    right: auto !important;
    width: 20px;
    height: 20px;
    fill: #5d6675;
    pointer-events: none;
  }
  #header .ml-hdr-search #search_input {
    padding: 0 20px 0 46px !important; /* (custom.css fuerza padding en inputs con !important) hueco a la izquierda para la lupa: placeholder y texto no se solapan */
    font-size: 0.9rem;
    color: #1a2332;
    background: transparent;
    cursor: pointer;
  }
  #header .ml-hdr-search #search_input::placeholder {
    color: #8a93a2;
  }

  #header .ml-hdr-loc {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #1a2332;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.2;
  }
  #header .ml-hdr-loc__ico {
    width: 22px;
    height: 22px;
    flex: none;
    color: #01468d;
  }
  #header .ml-hdr-loc__txt {
    display: flex;
    flex-direction: column;
  }
  #header .ml-hdr-loc__txt strong {
    font-size: 0.85rem;
    font-weight: 600;
  }
  #header .ml-hdr-loc__txt span {
    font-size: 0.72rem;
    color: #5d6675;
  }
  #header .ml-hdr-loc:hover strong {
    text-decoration: underline;
  }

  /* ---- Nivel 3: menú horizontal ---- */
  #header .ml-hdr .header-nav {
    border-top: 1px solid rgba(16, 18, 21, 0.06);
  }
  /* Misma caja que el nivel 2 (max-width 1860 con el padding dentro) → alineado con el logo */
  #header .header-nav .ml-nav {
    max-width: 1860px;
    margin-inline: auto;
    padding-inline: clamp(15px, 2vw, 30px);
  }
  /* compensa el padding del primer enlace: el icono de PRODUCTOS queda en línea con el logo */
  #header .header-nav .ml-nav__bar {
    justify-content: flex-start;
    margin-left: -14px !important;
  } /* custom.css: ul{margin:0 !important} */
  #header .header-nav .ml-nav__link {
    padding: 11px 14px;
    font-size: 13px;
  }
  #header .header-nav .ml-products-toggle__label {
    display: inline !important;
  } /* hay sitio: siempre con texto */
}

/* 992–1199px: se oculta la ubicación y se compacta el menú para que todo quepa */
@media (min-width: 992px) and (max-width: 1199px) {
  #header .ml-hdr-loc {
    display: none;
  }
  #header .ml-hdr .header-top {
    grid-template-columns: 170px minmax(0, 1fr) auto;
  }
  #header .header-nav .ml-nav__link {
    padding: 10px 9px;
    font-size: 12px;
  }
  #header .header-nav .ml-nav__bar {
    margin-left: -9px !important;
  }
}

/* Buscador: foco con borde amarillo de marca; sin contorno/borde propio del input */
@media (min-width: 992px) {
  #header .ml-hdr-search #search-icon:has(input:focus) {
    border-color: #ffdd00 !important;
  }
  #header .ml-hdr-search #search-icon input {
    outline: none !important;
    border: none !important;
  }
  /* Iconos nuevos (contacto/usuario/carrito): mismo tamaño; el de usuario no es cuadrado */
  #header .ml-hdr .nav-icons svg {
    width: 19px;
    height: 19px;
  }
  /* Botones de icono redondos */
  #header .ml-hdr .nav-icons .icon-square {
    border-radius: 50vw !important;
  }
}

/* Iconos de contorno (2026-10-06): el de usuario es un TRAZO (stroke=currentColor) →
   su color sigue los mismos estados que el fill de los otros: gris, amarillo al pasar
   el ratón y amarillo con sesión iniciada. */
@media (min-width: 992px) {
  #header .ml-hdr .nav-icons svg {
    color: #333;
  }
  #header .ml-hdr .nav-icons .icon-square:hover svg {
    color: #ffdd00;
  }
  #header .ml-hdr #account-button-logged svg {
    color: #ffdd00;
  }
}

/* ============================================================================
   CABECERA DE ESCRITORIO EN VENTANA ESTRECHA (<992px) — 2026-10-07
   header.tpl se sirve a navegadores de escritorio aunque la ventana sea pequeña
   (el móvil real recibe header-mobile.tpl, que NO tiene .ml-hdr → no le afecta).
   Todo va acotado a #header .ml-hdr.
   768–991: una fila  → ☰ | logo | buscador | iconos  (ubicación oculta)
   <768:    dos filas → ☰ | logo | · | iconos  /  buscador a todo el ancho
   ============================================================================ */
@media (max-width: 991px) {
  #header .ml-hdr .header-top {
    display: grid !important;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "burger logo search icons";
    align-items: center;
    column-gap: 14px;
    row-gap: 8px;
    padding: 8px 16px !important;
  }
  #header .ml-hdr .header-top .menu-icon {
    grid-area: burger;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 0 0 -8px;
    flex: none;
    cursor: pointer;
    color: #1a2332;
  }
  #header .ml-hdr .header-top .menu-icon svg {
    width: 26px;
    height: 26px;
  }

  #header .ml-hdr #_desktop_logo {
    grid-area: logo;
    width: 140px !important;
    max-width: 140px !important;
    flex: none !important;
    margin: 0 !important;
  }
  #header .ml-hdr #_desktop_logo .imglogo {
    width: 100% !important;
    height: auto !important;
    display: block;
  }

  #header .ml-hdr-search {
    grid-area: search;
    display: flex;
    min-width: 0;
  }
  #header .ml-hdr-search #search-icon {
    position: relative;
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: none !important;
    height: 40px !important;
    padding: 0 !important;
    background: #fff;
    border: 1px solid rgba(16, 18, 21, 0.14) !important;
    border-radius: 50vw !important;
    overflow: hidden;
  }
  #header .ml-hdr-search #search-icon::after {
    display: none !important;
  }
  #header .ml-hdr-search #search-icon:has(input:focus) {
    border-color: #ffdd00 !important;
  }
  #header .ml-hdr-search #search-icon > svg {
    left: 14px !important;
    right: auto !important;
    width: 20px;
    height: 20px;
    fill: #5d6675;
    pointer-events: none;
  }
  #header .ml-hdr-search #search_input {
    padding: 0 16px 0 42px !important;
    font-size: 0.9rem;
    color: #1a2332;
    background: transparent;
    outline: none !important;
    border: none !important;
  }
  #header .ml-hdr-search #search_input::placeholder {
    color: #8a93a2;
  }

  #header .ml-hdr .ml-hdr-loc {
    display: none !important;
  }

  #header .ml-hdr .nav-icons {
    grid-area: icons;
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0 -6px 0 0;
  }
  #header .ml-hdr .nav-icons .icon-square {
    width: 38px !important; /* el tema fija 30x30 por debajo de 576 → el svg quedaba en 12px */
    height: 38px !important;
    padding: 9px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50vw !important;
  }
  #header .ml-hdr .nav-icons svg {
    width: 20px !important;
    height: 20px !important;
    max-width: none !important;
    color: #333;
  }
  #header .ml-hdr .nav-icons .icon-square:hover svg {
    color: #ffdd00;
  }
  #header .ml-hdr #account-button-logged svg {
    color: #ffdd00;
  }
}

@media (max-width: 767px) {
  #header .ml-hdr .header-top {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "burger logo . icons"
      "search search search search";
  }
}
@media (max-width: 380px) {
  #header .ml-hdr #_desktop_logo {
    width: 112px !important;
    max-width: 112px !important;
  }
  #header .ml-hdr .header-top {
    column-gap: 8px;
    padding-inline: 12px !important;
  }
}
@media (max-width: 480px) {
  /* el badge del carrito sobresalía por la derecha con el margen negativo */
  #header .ml-hdr .nav-icons {
    margin-right: 0;
  }
}
@media (max-width: 380px) {
  /* 320–345 no cabían ☰ + logo + 3 iconos */
  #header .ml-hdr #_desktop_logo {
    width: 104px !important;
    max-width: 104px !important;
  }
  #header .ml-hdr .nav-icons .icon-square {
    width: 34px !important;
    height: 34px !important;
    padding: 7px !important;
  }
}
@media (min-width: 768px) and (max-width: 991px) {
  /* mismo logo que en escritorio (170): al cruzar 992 solo cambia el menú, no el logo */
  #header .ml-hdr #_desktop_logo {
    width: 170px !important;
    max-width: 170px !important;
  }
}
