@layer utilities {
  /* Estilos para asegurar que el logo tenga el tamaño correcto */
  .ushop-header-logo img {
    max-height: 70px !important;
    width: auto !important;
  }
  
  /* Añadiendo soporte explícito para las clases responsivas de Tailwind */
  /* Esto aumenta la especificidad para asegurar que no sea sobrescrito */
  button.md\:hidden {
    display: block !important;
  }
  
  @media (min-width: 768px) {
    button.md\:hidden {
      display: none !important;
    }
  }
  
  /* Estilos del botón toggle para hamburguesa */
  .ushop-mobile-toggle {
    display: block !important;
  }
  
  /* Estilos base mejorados para la nav */
  .ushop-main-nav {
    display: none !important;
    transition: all 0.3s ease-in-out !important;
  }
  
  /* Estilo para menú activo */
  .ushop-menu-item.active .main-link {
    color: #df0000 !important;
    position: relative !important;
  }
  
  .ushop-menu-item.active .main-link::after {
    content: '' !important;
    position: absolute !important;
    bottom: -6px !important;
    left: 0 !important;
    width: 100% !important;
    height: 3px !important;
    background-color: #df0000 !important;
  }
  
  /* Mejoras para desktop */
  @media (min-width: 768px) {
    /* Ocultar el botón hamburguesa en desktop */
    .ushop-mobile-toggle {
      display: none !important;
    }
    
    .ushop-main-nav {
      display: flex !important;
      position: static !important;
      width: auto !important;
      height: auto !important;
      background: transparent !important;
      z-index: auto !important;
      transform: none !important;
      padding: 0 !important;
    }
    
    .ushop-main-nav ul {
      justify-content: flex-end !important;
    }
    
    .ushop-menu-item {
      position: relative !important;
    }
    
    .ushop-menu-item .main-link {
      padding: 12px 0 !important;
      font-weight: 500 !important;
      letter-spacing: 0.02em !important;
      transition: color 0.2s !important;
    }
    
    .ushop-menu-item .main-link:hover {
      color: #df0000 !important;
    }
    
    .ushop-mobile-controls {
      display: none !important;
    }
    
    .ushop-desktop-cart {
      display: flex !important;
      margin-left: 20px !important;
    }
    
    /* Efectos de hover mejorados para submenús */
    .ushop-submenu {
      top: 100% !important;
      transform: translateY(0) !important;
      opacity: 0 !important;
      visibility: hidden !important;
      transition: all 0.3s !important;
      border-radius: 6px !important;
      border: 1px solid #f0f0f0 !important;
      z-index: 100 !important;
      padding-top: 10px !important;
      margin-top: -10px !important;
    }
    
    /* Creamos un área invisible para evitar que se pierda el hover */
    .ushop-menu-item::after {
      content: '' !important;
      display: block !important;
      position: absolute !important;
      height: 20px !important;
      width: 100% !important;
      bottom: -20px !important;
      left: 0 !important;
      z-index: 90 !important;
    }
    
    .ushop-menu-item:hover .ushop-submenu {
      display: block !important;
      opacity: 1 !important;
      visibility: visible !important;
    }
    
    /* Aseguramos que el submenu permanezca visible cuando el mouse está sobre él */
    .ushop-submenu:hover {
      display: block !important;
      opacity: 1 !important;
      visibility: visible !important;
    }
    
    .ushop-submenu-item a:hover {
      color: #df0000 !important;
      background-color: #f9f9f9 !important;
    }
    
    /* Estilos específicos para los toggles en desktop */
    button.ushop-submenu-toggle.md\:hidden {
      display: none !important;
    }
  }
  
  /* Mejoras para mobile */
  @media (max-width: 767px) {
    body.menu-open {
      overflow: hidden !important;
    }
    
    .ushop-main-nav {
      transform: translateX(-100%) !important;
    }
    
    .ushop-main-nav.open {
      display: block !important;
      position: fixed !important;
      top: 0 !important;
      left: 0 !important;
      width: 100% !important;
      height: 100% !important;
      z-index: 50 !important;
      background-color: white !important;
      padding: 5rem 1.5rem 1.5rem 1.5rem;
      overflow-y: auto !important;
      transform: translateX(0) !important;
    }
    
    .ushop-main-nav ul {
      flex-direction: column !important;
      align-items: stretch !important;
      gap: 0 !important;
    }
    
    .ushop-menu-item {
      border-bottom: 1px solid #f0f0f0 !important;
      padding: 8px 0 !important;
    }
    
    .ushop-menu-item:last-child {
      border-bottom: none !important;
    }
    
    .ushop-menu-item .main-link {
      padding: 8px 0 !important;
      width: 100% !important;
      display: flex !important;
      justify-content: space-between !important;
      align-items: center !important;
    }
    
    /* Importante: Estos estilos son clave para que el submenu se muestre */
    .ushop-submenu {
      display: none !important;
      position: static !important;
      box-shadow: none !important;
      border: none !important;
      padding-left: 20px !important;
      margin-top: 8px !important;
      margin-bottom: 8px !important;
      background-color: #f9f9f9 !important;
      border-radius: 4px !important;
      padding: 8px !important;
    }
    
    /* Este es el selector clave que necesita sobrescribir la propiedad display */
    .ushop-menu-item.open .ushop-submenu {
      display: block !important;
    }
    
    .ushop-submenu-item {
      margin-bottom: 4px !important;
    }
    
    .ushop-submenu-item:last-child {
      margin-bottom: 0 !important;
    }
    
    .ushop-menu-arrow {
      transition: transform 0.3s !important;
    }
    
    .ushop-menu-item.open .ushop-menu-arrow {
      transform: rotate(180deg) !important;
    }
    
    .ushop-menu-item.open .fa-chevron-down {
      transform: rotate(180deg) !important;
    }
    
    .mobile-menu-close {
      display: block !important;
      position: absolute !important;
      top: 20px !important;
      right: 20px !important;
      font-size: 24px !important;
      cursor: pointer !important;
      z-index: 55 !important;
    }
    
    .ushop-desktop-cart {
      display: none !important;
    }
    
    .ushop-mobile-title {
      display: block !important;
      font-size: 18px !important;
      font-weight: 600 !important;
      margin-bottom: 20px !important;
      padding-bottom: 10px !important;
      border-bottom: 1px solid #eee !important;
    }
    
    /* Asegurar que los toggles de submenú se muestran en mobile */
    button.ushop-submenu-toggle.md\:hidden {
      display: flex !important;
    }
  }
}

/* Estilos para el header */
.ushop-header {
  @apply fixed top-0 left-0 w-full bg-white shadow-md z-10 py-3;
}

.ushop-header-inner {
  @apply flex items-center justify-between w-full;
}

.ushop-logo img {
  @apply h-auto max-h-12 w-auto;
}

/* Estilos para navegación principal */
.ushop-main-nav {
  @apply hidden md:block;
}

@media (max-width: 767px) {
  .ushop-main-nav {
    @apply fixed inset-0 bg-white p-4 pt-16 z-20 transform -translate-x-full transition-transform duration-300 overflow-y-auto;
    opacity: 0;
  }

  .ushop-main-nav.open {
    @apply translate-x-0;
    opacity: 1;
  }

  .ushop-main-nav > ul {
    @apply flex-col gap-y-4 gap-x-0;
  }

  body.menu-open {
    @apply overflow-hidden;
  }

  .mobile-menu-close {
    @apply absolute top-4 right-4 block;
  }
}

/* Estilos para desktop nav */
@media (min-width: 768px) {
  .ushop-desktop-cart {
    @apply flex;
  }
}

/* Estilos para items del menú */
.ushop-menu-item {
  @apply relative;
}

.ushop-menu-item .main-link {
  @apply relative font-medium text-gray-800 hover:text-[#df0000] transition-colors duration-200;
}

.ushop-menu-item.active .main-link {
  @apply text-[#df0000];
}

/* Estilos para submenús */
.ushop-submenu {
  min-width: 260px;
  @apply hidden;
  z-index: 100 !important;
}

@media (min-width: 768px) {
  .ushop-menu-item:hover .ushop-submenu {
    @apply block;
  }
  
  /* Selector adicional para asegurar que el submenú se mantiene visible */
  .ushop-submenu:hover {
    display: block !important;
  }
}

@media (max-width: 767px) {
  .ushop-menu-item {
    @apply border-b border-gray-200 pb-2;
  }

  .ushop-menu-item.open .ushop-submenu {
    display: block !important;
    position: static !important;
    box-shadow: none !important;
    min-width: 0 !important;
    padding-left: 1rem !important;
    margin-top: 0.5rem !important;
    border-top: 1px solid #f0f0f0 !important;
    padding-top: 0.5rem !important;
  }

  .ushop-submenu-item {
    @apply mb-2;
  }

  .ushop-menu-item.open .ushop-menu-arrow {
    transform: rotate(180deg) !important;
  }

  .ushop-submenu-toggle {
    @apply p-2 text-gray-500;
    min-width: 40px !important;
    text-align: center !important;
  }
}

/* Animaciones y transiciones */
.ushop-menu-arrow {
  transition: transform 0.2s ease;
}

/* Cotización */
.cart-count {
  @apply font-bold;
}

/* Estilos adicionales para el menú móvil */
@media (max-width: 767px) {
  .ushop-submenu-toggle {
    min-width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background-color: #f5f5f5 !important;
    transition: background-color 0.2s !important;
    margin-left: 8px !important;
    z-index: 5 !important;
  }
  
  .ushop-submenu-toggle:hover {
    background-color: #e5e5e5 !important;
  }
  
  .ushop-submenu-toggle:active {
    background-color: #d5d5d5 !important;
  }
} 

@media (max-width: 767px) {
  .sm_hidden{
    display: none;
  }
}

@media (max-width: 767px) {
  .top-bar,
  .header-container,
  .header-content {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .ushop-mobile-controls {
    gap: 12px !important;
  }

  .mobile-menu-toggle,
  #mobile-menu-close {
    width: 44px !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    background: #df0000 !important;
    color: #ffffff !important;
    border: 0 !important;
    padding: 0 !important;
  }

  .ushop-main-nav {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }

  .ushop-main-nav.open {
    padding: 76px 20px 24px 20px !important;
  }

  .ushop-main-nav > ul {
    width: 100% !important;
    max-width: 100% !important;
  }

  .ushop-menu-item .main-link,
  .ushop-submenu-item a {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  body.menu-open {
    position: fixed !important;
    width: 100% !important;
  }
}
