/* ============================================================
   Llobregat Category Menu - menú de dos paneles (Amazon/AliExpress)
   Vanilla CSS. Sin dependencias.
   ============================================================ */

/* --- Contenedor raíz --- */
.lw-catmenu {
  position: relative;
}

/* --- Botón trigger del header (desktop) ---
   Replica el aspecto del botón "Categorías" original (title_vertical) */
.lw-catmenu-trigger {
  cursor: pointer;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #021523;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  line-height: 1.4;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
  font-family: inherit;
}
.lw-catmenu-trigger i {
  font-size: 20px;
  color: #021523;
  line-height: 1;
  transition: color 0.2s ease;
}
.lw-catmenu-trigger:hover,
.lw-catmenu-trigger:focus-visible {
  background: #fff;
  color: #047389;
  border-color: #047389;
  outline: none;
  box-shadow: 0 0 0 3px rgba(4, 115, 137, 0.15);
}
.lw-catmenu-trigger:hover i,
.lw-catmenu-trigger:focus-visible i {
  color: #047389;
}

/* --- Backdrop --- */
.lw-catmenu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1049;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}
.lw-catmenu-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* --- Panel principal --- */
.lw-catmenu-panel {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1050;
  display: flex;
  align-items: stretch;
  background: #fff;
  box-shadow: 4px 0 24px rgba(2, 21, 35, 0.1);
  transform: translateX(-100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 300ms ease-out, opacity 250ms ease, visibility 300ms ease;
}
.lw-catmenu-panel.is-open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}
.lw-catmenu-panel:focus {
  outline: none;
}

/* Bloqueo de scroll del fondo mientras el menú está abierto (desktop) */
body.lw-catmenu-lock {
  overflow: hidden;
}

/* --- Panel izquierdo: categorías de nivel 1 --- */
.lw-catmenu-left {
  width: 300px;
  flex: 0 0 300px;
  background: #fff;
  border-right: 1px solid #eee;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #047389 #f7f7f7;
}
.lw-catmenu-left::-webkit-scrollbar {
  width: 8px;
}
.lw-catmenu-left::-webkit-scrollbar-track {
  background: #f7f7f7;
}
.lw-catmenu-left::-webkit-scrollbar-thumb {
  background: #047389;
  border-radius: 8px;
}
.lw-catmenu-left::-webkit-scrollbar-thumb:hover {
  background: #036172;
}

/* --- Botón cerrar (×) --- */
.lw-catmenu-close {
  align-self: flex-end;
  margin: 12px 14px 4px 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  color: #666;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(2, 21, 35, 0.08);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.lw-catmenu-close:hover,
.lw-catmenu-close:focus-visible {
  color: #fff;
  background: #d93b2b;
  border-color: #d93b2b;
  box-shadow: 0 2px 8px rgba(217, 59, 43, 0.35);
  outline: none;
}

/* --- Enlace de ofertas --- */
.lw-catmenu-offers {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 14px 6px;
  padding: 11px 14px;
  color: #047389;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  border-radius: 8px;
  transition: color 0.2s ease, background 0.2s ease;
}
.lw-catmenu-offers::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #f5c500;
  box-shadow: 0 0 0 2px rgba(245, 197, 0, 0.25);
}
.lw-catmenu-offers span:first-of-type {
  flex: 1 1 auto;
}
.lw-catmenu-offers:hover,
.lw-catmenu-offers:focus-visible {
  color: #036172;
  background: rgba(4, 115, 137, 0.08);
  text-decoration: none;
  outline: none;
}
.lw-catmenu-offers .lw-catmenu-arrow {
  font-size: 18px;
  line-height: 1;
}

/* --- Título del panel --- */
.lw-catmenu-heading {
  margin: 0;
  padding: 14px 18px 12px;
  font-size: 16px;
  font-weight: 700;
  color: #021523;
  border-bottom: 1px solid #eee;
}

/* --- Lista de categorías --- */
.lw-catmenu-nav {
  flex: 1 1 auto;
}
.lw-catmenu-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}
.lw-catmenu-item {
  position: relative;
  border-bottom: 1px solid #f2f2f2;
}
.lw-catmenu-item:last-child {
  border-bottom: none;
}
.lw-catmenu-item-btn {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  font-size: 14px;
  color: #333;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.2s ease, color 0.2s ease;
}
.lw-catmenu-item-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #047389;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.lw-catmenu-item-btn:hover,
.lw-catmenu-item-btn:focus-visible {
  background: rgba(4, 115, 137, 0.07);
  outline: none;
}
.lw-catmenu-item-btn:hover::before,
.lw-catmenu-item-btn:focus-visible::before {
  opacity: 1;
}
.lw-catmenu-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 6px;
  object-fit: contain;
}
.lw-catmenu-icon svg {
  width: 24px;
  height: 24px;
  display: block;
  color: #021523;
}
img.lw-catmenu-icon {
  background: #fff;
  border: 1px solid #eee;
}
.lw-catmenu-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}
.lw-catmenu-caret {
  color: #999;
  font-size: 12px;
  line-height: 1;
  flex: 0 0 auto;
  transition: transform 0.2s ease, color 0.2s ease;
}
.lw-catmenu-item.is-active .lw-catmenu-item-btn {
  background: rgba(4, 115, 137, 0.07);
}
.lw-catmenu-item.is-active .lw-catmenu-item-btn::before {
  opacity: 1;
}
.lw-catmenu-item.is-active .lw-catmenu-label {
  font-weight: 700;
  color: #047389;
}
.lw-catmenu-item.is-active .lw-catmenu-caret {
  color: #f5c500;
  font-weight: 700;
}
.lw-catmenu-item-btn:hover .lw-catmenu-icon svg,
.lw-catmenu-item-btn:focus-visible .lw-catmenu-icon svg {
  color: #047389;
}
.lw-catmenu-item.is-active .lw-catmenu-icon svg {
  color: #047389;
}

/* --- Panel derecho: subcategorías --- */
.lw-catmenu-right {
  /* Oculto por defecto, se muestra con .has-selection */
  display: none;
  width: 380px;
  flex: 0 0 380px;
  background: #fff;
  overflow-y: auto;
  box-shadow: -8px 0 24px rgba(2, 21, 35, 0.08);
  scrollbar-width: thin;
  scrollbar-color: #047389 #f7f7f7;
}
.lw-catmenu-panel.has-selection .lw-catmenu-right {
  display: flex;
  flex-direction: column;
}
.lw-catmenu-right::-webkit-scrollbar {
  width: 8px;
}
.lw-catmenu-right::-webkit-scrollbar-track {
  background: #f7f7f7;
}
.lw-catmenu-right::-webkit-scrollbar-thumb {
  background: #047389;
  border-radius: 8px;
}
.lw-catmenu-right::-webkit-scrollbar-thumb:hover {
  background: #036172;
}

/* Cabecera del panel derecho */
.lw-catmenu-right-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  padding: 14px 22px 12px;
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}
.lw-catmenu-right-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: #021523;
}
.lw-catmenu-all-link {
  display: inline-block;
  color: #047389;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s ease;
}
.lw-catmenu-all-link:hover,
.lw-catmenu-all-link:focus-visible {
  color: #036172;
  text-decoration: underline;
  outline: none;
}
.lw-catmenu-back {
  display: none;
}

/* Lista de subcategorías */
.lw-catmenu-sub-list {
  list-style: none;
  margin: 0;
  padding: 0 22px 16px;
}
.lw-catmenu-sub-item > a,
.lw-catmenu-sub-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  font-size: 14px;
  color: #333;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  font-family: inherit;
  transition: color 0.15s ease;
}
.lw-catmenu-sub-item > a:hover,
.lw-catmenu-sub-toggle:hover,
.lw-catmenu-sub-item > a:focus-visible,
.lw-catmenu-sub-toggle:focus-visible {
  color: #021523;
  outline: none;
}
.lw-catmenu-sub-toggle .lw-catmenu-caret {
  margin-left: auto;
}
.lw-catmenu-sub-toggle.is-expanded .lw-catmenu-caret {
  transform: rotate(180deg);
}
.lw-catmenu-sub-sub {
  list-style: none;
  margin: 0 0 6px;
  padding-left: 16px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 300ms ease, opacity 200ms ease;
}
.lw-catmenu-sub-sub.is-open {
  max-height: 600px;
  opacity: 1;
}
.lw-catmenu-sub-sub a,
.lw-catmenu-sub-sub .lw-catmenu-sub-toggle {
  padding: 7px 0;
  font-size: 13px;
  color: #555;
}
.lw-catmenu-sub-empty {
  padding: 10px 0;
  font-size: 13px;
  color: #888;
}
.lw-catmenu-loading {
  padding: 18px 22px;
  font-size: 14px;
  color: #666;
}
.lw-catmenu-error {
  padding: 18px 22px;
  font-size: 14px;
  color: #b02a1f;
}

/* ============================================================
   RESPONSIVE / DRAWER MÓVIL (< 1024px)
   El header de escritorio se oculta y se usa el drawer móvil
   (#mobile_menu_wrapper, max-width 19rem). El panel pasa a ser
   estático dentro del drawer; el panel derecho se desliza encima.
   ============================================================ */
@media (max-width: 1023px) {
  .lw-catmenu-trigger {
    display: none;
  }

  .lw-catmenu-mobile {
    position: relative;
  }

  .lw-catmenu-panel {
    position: relative;
    inset: auto;
    transform: none;
    opacity: 1;
    visibility: visible;
    box-shadow: none;
    z-index: auto;
    width: 100%;
    height: auto;
  }

  .lw-catmenu-left {
    width: 100%;
    flex: 1 1 100%;
    border-right: none;
    max-height: none;
  }

  .lw-catmenu-close {
    display: none;
  }

  .lw-catmenu-right {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    flex: none;
    z-index: 5;
    border-left: 1px solid #eee;
    box-shadow: 6px 0 20px rgba(2, 21, 35, 0.12);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 300ms ease-out, visibility 300ms ease;
  }
  .lw-catmenu-right.is-sub-open {
    transform: translateX(0);
    visibility: visible;
  }

  /* Botón atrás visible solo en móvil dentro del panel derecho */
  .lw-catmenu-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    font-size: 18px;
    color: #666;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  }
  .lw-catmenu-back:hover,
  .lw-catmenu-back:focus-visible {
    color: #047389;
    background: #fff;
    border-color: #047389;
    outline: none;
  }

  body.lw-catmenu-lock {
    overflow: auto;
  }
}

/* Tablet intermedia (768-1023px): misma lógica que móvil */
@media (min-width: 768px) and (max-width: 1023px) {
  .lw-catmenu-trigger {
    display: none;
  }
}
