/* =====================================
   ESTILOS DEL MENÚ HAMBURGUESA
   ===================================== */

/* Icono de Hamburguesa (oculto por defecto en PC) */
.hamburger-icon {
  display: none;
  font-size: 28px;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
}

/* Contenedores del menú móvil (ocultos por defecto) */
.mobile-menu-trigger,
#mobile-nav-panel {
  display: none;
}

/* Estilos móviles del menú hamburguesa */
@media (max-width: 1023px) {

  /* Botón del menú hamburguesa moderno */
  .mobile-menu-trigger {
    flex-direction: column;
    justify-content: space-around;
    width: 32px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    z-index: 1003;
    position: relative;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  }

  /* Hover del botón hamburguesa */
  .mobile-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  }

  /* Barras del icono hamburguesa con diseño moderno */
  .mobile-menu-trigger .bar {
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
    border-radius: 2px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
  }

  /* Animación moderna cuando el menú está activo (X) */
  .mobile-menu-trigger.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
  }

  .mobile-menu-trigger.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
    background: linear-gradient(45deg, #ffffff 0%, #e0e0e0 100%);
  }

  .mobile-menu-trigger.active .bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }

  .mobile-menu-trigger.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
    background: linear-gradient(-45deg, #ffffff 0%, #e0e0e0 100%);
  }

  /* Panel de navegación móvil moderno */
  #mobile-nav-panel {
    display: block;
    position: fixed;
    top: 50px;
    right: 0;
    width: 320px;
    height: calc(100vh - 50px);
    background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    padding: 0;
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(20px);
    overflow-y: auto;
  }

  /* Panel activo (visible) con entrada suave */
  #mobile-nav-panel.active {
    transform: translateX(0);
  }

  .mobile-nav-panel {
    z-index: 999;
    /* Debe ser mayor que mobile-menu-overlay (998) pero menor que centralized-menu (10000) */
  }

  /* Navegación del panel móvil */
  .mobile-nav-panel nav {
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    height: calc(100% - 80px);
  }

  /* Enlaces dentro del panel móvil con diseño moderno */
  #mobile-nav-panel nav a {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    padding: 16px 24px;
    margin: 2px 16px;
    border-radius: 12px;
    border-bottom: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    letter-spacing: 0.3px;
  }

  /* Efecto hover moderno de los enlaces */
  #mobile-nav-panel nav a:hover {
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.15) 0%, rgba(0, 123, 255, 0.08) 100%);
    color: #ffffff;
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
  }

  /* Indicador lateral en hover */
  #mobile-nav-panel nav a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, #007bff, #0056b3);
    border-radius: 0 3px 3px 0;
    transform: translateY(-50%);
    transition: height 0.3s ease;
  }

  #mobile-nav-panel nav a:hover::before {
    height: 70%;
  }

  /* Bloquea el scroll del body con blur */
  body.menu-open {
    overflow: hidden;
  }

  body.menu-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 999;
  }

  /* Link de login móvil con estilo especial */
  #mobileLinkLogin {
    margin-top: auto;
    display: flex;
    align-items: center;
    padding: 18px 24px;
    margin: 16px;
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Hover especial del login */
  #mobileLinkLogin:hover {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.8) 0%, rgba(0, 100, 200, 0.9) 100%);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.3);
    color: #ffffff;
  }

  /* Separador moderno del menú */
  .menu-separator {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    margin: 16px 24px;
  }

  /* Animación de entrada escalonada para los elementos */
  #mobile-nav-panel.active nav a {
    animation: slideInRight 0.6s ease forwards;
    opacity: 0;
  }

  #mobile-nav-panel.active nav a:nth-child(1) {
    animation-delay: 0.1s;
  }

  #mobile-nav-panel.active nav a:nth-child(2) {
    animation-delay: 0.15s;
  }

  #mobile-nav-panel.active nav a:nth-child(3) {
    animation-delay: 0.2s;
  }

  #mobile-nav-panel.active nav a:nth-child(4) {
    animation-delay: 0.25s;
  }

  #mobile-nav-panel.active nav a:nth-child(5) {
    animation-delay: 0.3s;
  }

  @keyframes slideInRight {
    from {
      opacity: 0;
      transform: translateX(30px);
    }

    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  #mobileCerrarSecion i {
    margin-right: 8px;
    /* <-- Esto crea un espacio de 8 píxeles a la derecha del icono */
  }



}

.mobile-menu-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

.mobile-menu-overlay.active {
  display: block;
}






#mobile-logout-button {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 10px 0;
  cursor: pointer;
  color: #ffffff;
  font-weight: 500;
  font-size: 1em;
  display: flex;
  align-items: center;
  transition: background-color 0.2s;
  margin-left: 36px;
  margin-top: 12px;
}

#mobile-logout-button:hover {
  background-color: #ffebee;
}

#mobile-logout-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#mobile-logout-button i {
  margin-right: 8px;
}

.mobile-nav-divider {
  margin: 10px 0;
  border: none;
  border-top: 1px solid #e0e0e0;
}








/* =====================================
   BARRA DE BÚSQUEDA MÓVIL EN HEADER
   ===================================== */

/* Ocultar por defecto en desktop */
.mobile-search-header {
  display: none;
}

@media (max-width: 1023px) {

  /* Ocultar la barra de búsqueda de escritorio en móvil */
  .search-box {
    display: none !important;
  }

  /* Ajustar el header para layout móvil */
  .header-z {
    position: sticky;
    /* Fija el header en la ventana */
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    width: auto;
    top: 0;
    /* Ocupa todo el ancho */
    z-index: 1000;
    /* Evita transparencia si hay scroll */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    /* Opcional: sombra sutil */
  }

  /* Logo a la izquierda */
  .logo-block {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  .logo-block img {
    max-height: 35px;
    width: auto;
  }

  .logo-info {
    display: none;
    /* Ocultar info de contacto en móvil */
  }

  /* Menú hamburguesa a la derecha */
  .mobile-menu-trigger {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    width: 45px;
  }

  /* Barra de búsqueda en el centro */
  .mobile-search-header {
    display: flex;
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    width: 100%;
    padding: 0 8px;
  }

  /* Wrapper del input */
  .mobile-search-wrapper-header {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
  }

  /* Input de búsqueda compacto */
  .mobile-search-input-header {
    width: 100%;
    padding: 8px 32px 8px 32px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.95);
    font-size: 16px;
    /* ✅ CAMBIO: de 13px a 16px */
    outline: none;
    transition: all 0.3s ease;
  }

  .mobile-search-input-header::placeholder {
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    /* ✅ CAMBIO: de 13px a 16px */
  }

  /* Focus del input */
  .mobile-search-input-header:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(0, 123, 255, 0.6);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
  }

  /* Icono de búsqueda (izquierda) */
  .mobile-search-icon-header {
    position: absolute;
    left: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    /* ✅ OPCIONAL: ajustar de 13px a 15px para que combine mejor */
    pointer-events: none;
  }

  .mobile-search-input-header:focus~.mobile-search-icon-header {
    color: rgba(0, 123, 255, 0.9);
  }

  /* Botón limpiar (X) */
  .mobile-search-clear-header {
    position: absolute;
    right: 6px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
  }

  .mobile-search-clear-header.visible {
    display: flex;
  }

  .mobile-search-clear-header:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
  }

  .mobile-search-clear-header:active {
    transform: scale(0.9);
  }

  /* Ocultar nav-links en móvil */
  .nav-links {
    display: none !important;
  }
}

/* Ajuste para pantallas muy pequeñas */
@media (max-width: 400px) {

  .mobile-search-input-header {
    font-size: 12px;
    padding: 6px 28px 6px 28px;
  }

  .mobile-search-input-header::placeholder {
    font-size: 12px;
  }

  .logo-block img {
    max-height: 30px;
  }
}









#mobile-search-results-counter {
  display: none;
}

/* =====================================
   COMPORTAMIENTO DEL LOGO AL BUSCAR
   (Con detección de teclado mejorada)
   ===================================== */

@media (max-width: 1023px) {

  /* Transición suave del logo */
  .logo-block {
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
      transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
      width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    transform: scale(1) translateX(0);
    transform-origin: left center;
  }

  /* Ocultar logo cuando la búsqueda está activa */
  .header-z.search-active .logo-block {
    opacity: 0;
    transform: scale(0.85) translateX(-20px);
    width: 0;
    overflow: hidden;
    pointer-events: none;
  }

  /* Ajuste del grid cuando la búsqueda está activa */
  .header-z.search-active {
    grid-template-columns: 0 1fr auto;
  }

  /* Expandir la barra de búsqueda cuando está activa */
  .header-z.search-active .mobile-search-header {
    max-width: 100%;
    padding-left: 8px;
    padding-right: 8px;
  }

  /* Hacer el input más grande cuando está activo */
  .header-z.search-active .mobile-search-input-header {
    font-size: 16px;
    /* ✅ CAMBIO: de 14px a 16px */
    padding: 10px 34px 10px 34px;
  }

  .header-z.search-active .mobile-search-icon-header {
    color: rgba(0, 123, 255, 0.9);
    font-size: 16px;
    /* ✅ CAMBIO: de 14px a 16px */
    left: 14px;
  }

  /* Asegurar que el header mantenga su altura */
  .header-z {
    min-height: 50px;
    align-items: center;
  }

  /* Prevenir saltos visuales durante la transición */
  .header-z * {
    box-sizing: border-box;
  }
}


/* =====================================
   DROPDOWN DE RESULTADOS - SCROLLABLE
   Con contador de resultados visible
   ===================================== */

@media (max-width: 1023px) {

  /* Contenedor principal de resultados */
  #mobile-search-results-header {
    position: fixed;
    top: 58px;
    left: 12px;
    right: 12px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    /* Redondeado completo por defecto */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);

    /* ⭐ ALTURA FIJA para 7 elementos */
    max-height: 350px;

    /* ⭐ SCROLL visible */
    overflow-y: auto;
    overflow-x: hidden;

    z-index: 9999;
    display: none;
    scroll-behavior: smooth;

    /* ⭐ SCROLLBAR VISIBLE Y MODERNO */
    /* Para Firefox */
    scrollbar-width: auto;
    scrollbar-color: rgba(0, 123, 255, 0.4) rgba(0, 0, 0, 0.05);
  }

  /* Cuando el contador está visible, ajustar border-radius */
  #mobile-search-results-header.has-counter {
    border-radius: 12px 12px 0 0;
    /* Sin redondeo abajo */
    border-bottom-color: rgba(0, 123, 255, 0.2);
  }

  /* ⭐ SCROLLBAR WEBKIT (Chrome, Safari, Edge) - MÁS VISIBLE */
  #mobile-search-results-header::-webkit-scrollbar {
    width: 10px;
    /* Más ancho para mejor visibilidad */
  }

  #mobile-search-results-header::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 0 12px 0 0;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
  }

  #mobile-search-results-header::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg,
        rgba(0, 123, 255, 0.5) 0%,
        rgba(0, 123, 255, 0.7) 100%);
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
  }

  #mobile-search-results-header::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg,
        rgba(0, 123, 255, 0.7) 0%,
        rgba(0, 123, 255, 0.9) 100%);
    border-color: rgba(255, 255, 255, 0.5);
  }

  /* Efecto activo al hacer scroll */
  #mobile-search-results-header::-webkit-scrollbar-thumb:active {
    background: rgba(0, 100, 200, 0.9);
  }

  /* Cada item de resultado */
  #mobile-search-results-header .search-result-item {
    padding: 12px 20px 12px 15px;
    /* Más padding-right para el scrollbar */
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    min-height: 48px;
  }

  #mobile-search-results-header .search-result-item:last-child {
    border-bottom: none;
  }

  #mobile-search-results-header .search-result-item:hover,
  #mobile-search-results-header .search-result-item:active {
    background-color: #f5f5f5;
  }

  /* Texto del resultado */
  #mobile-search-results-header .result-text {
    flex: 1;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    padding-right: 8px;
  }

  #mobile-search-results-header .result-text strong {
    color: #007bff;
    font-weight: 600;
  }

  /* Etiqueta de tipo */
  #mobile-search-results-header .result-type {
    font-size: 11px;
    color: #888;
    background: #eee;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 500;
    white-space: nowrap;
    margin-left: 8px;
    flex-shrink: 0;
  }

  /* Mensaje de "sin resultados" */
  #mobile-search-results-header .no-results {
    text-align: center;
    padding: 20px;
    min-height: 60px;
  }

  /* ⭐ CONTADOR DE RESULTADOS (POSICIÓN DINÁMICA) */
  #mobile-search-results-counter {
    position: fixed;
    /* ⭐ NUEVO: La posición top se calculará dinámicamente con JS */
    top: 58px;
    /* Valor inicial, será sobrescrito */
    left: 12px;
    right: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 0 0 12px 12px;
    padding: 10px 15px;
    z-index: 9998;
    /* Justo debajo del contenedor de resultados */
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);

    /* Texto del contador */
    font-size: 13px;
    color: #495057;
    font-weight: 500;
    text-align: center;
    letter-spacing: 0.3px;

    /* Transiciones suaves */
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.3s ease, transform 0.3s ease, top 0.2s ease;
    /* ⭐ Agregamos transición para top */
  }

  /* Mostrar el contador cuando hay resultados */
  #mobile-search-results-counter.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
  }

  /* Icono opcional en el contador */
  #mobile-search-results-counter i {
    margin-right: 6px;
    color: #007bff;
    font-size: 12px;
  }

  /* Estilo especial cuando hay muchos resultados */
  #mobile-search-results-counter.many-results {
    background: linear-gradient(135deg, #e7f3ff 0%, #cfe7ff 100%);
    border-color: rgba(0, 123, 255, 0.2);
    border-top-color: rgba(0, 123, 255, 0.4);
  }

  #mobile-search-results-counter.many-results i {
    animation: pulse 2s infinite;
  }

  @keyframes pulse {

    0%,
    100% {
      opacity: 1;
      transform: scale(1);
    }

    50% {
      opacity: 0.6;
      transform: scale(1.1);
    }
  }

  /* Ajustar el wrapper para que sea relativo */
  .mobile-search-header {
    position: relative;
  }
}

/* Ajuste para pantallas muy pequeñas */
@media (max-width: 400px) {

  .mobile-search-input-header {
    font-size: 16px;  /* ✅ Evita zoom en iOS */
    padding: 6px 28px 6px 28px;
  }

  .mobile-search-input-header::placeholder {
    font-size: 16px;  /* ✅ Evita zoom en iOS */
  }

  /* LOGO */
  .logo-block img {
    max-height: 30px;
  }

  /* DROPDOWN DE RESULTADOS */
  #mobile-search-results-header {
    max-height: 300px;
  }

  /* CONTADOR DE RESULTADOS */
  #mobile-search-results-counter {
    /* top se calcula dinámicamente con JS */
    font-size: 13px;
    padding: 8px 12px;
  }
}

/* Ajustes para pantallas más grandes (pero aún móviles) */
@media (min-width: 400px) and (max-width: 768px) {
  #mobile-search-results-header {
    max-height: 400px;
  }

  #mobile-search-results-counter {
    top: calc(58px + 400px + 1px);
    /* Ajustar según la altura del dropdown */
  }
}


/* 🔹 Ícono de carrito móvil */
.mobile-cart-icon {
  display: none; /* Oculto por defecto */
  color: white; /* color del ícono */
  font-size: 20px;
  margin-left: 10px;
  text-decoration: none;
}

/* 🔹 Mostrar solo en vista móvil */
@media (max-width: 767px) {
  .mobile-cart-icon {
    display: inline-flex;
    align-items: center;
  }

  /* Alineación con el menú hamburguesa */
  #mobileMenuTrigger {
    margin-right: 6px;
  }

  header.header-z {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
