/**
 * Huawei Solar Menu Styles for WordPress
 * Bootstrap 5 Compatible
 * VERSIÓN FINAL - Header SIEMPRE visible, submenú DEBAJO
 */

/* ========================================
   VARIABLES
   ======================================== */
:root {
    --huawei-red: #f1872d;
    --huawei-red-dark: #f1872d;
    --huawei-gray: #666;
    --huawei-light-gray: #f8f9fa;
}

/* ========================================
   HEADER TOP BAR
   ======================================== */
.header-top-bar a:hover,
.language-switcher-custom a:hover {
    opacity: 0.8;
    transition: opacity 0.3s;
}

.border-radius-100px {
    border-radius: 100px !important;
}

.lh-36 {
    line-height: 36px;
}

/* ========================================
   NAVBAR
   ======================================== */
.navbar {
    transition: box-shadow 0.3s ease;
}

.navbar.shadow-lg {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.navbar-brand img {
    transition: opacity 0.3s;
}

.navbar-brand:hover img {
    opacity: 0.8;
}

/* ========================================
   NAV LINKS
   ======================================== */
.nav-link {
    font-weight: 500;
    font-size: 15px;
    padding: 0.5rem 1rem !important;
    transition: color 0.3s;
    color: #333;
}

.nav-link:hover {
    color: var(--huawei-red) !important;
}

.nav-link.dropdown-toggle::after {
    vertical-align: 0.15em;
    margin-left: 0.4em;
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-left: 0.3em solid transparent;
}

/* ========================================
   MEGA MENU
   ======================================== */
.mega-dropdown {
    position: static;
}

.mega-dropdown .dropdown-menu {
    width: 100%;
    max-width: 1200px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    border-radius: 0.5rem;
    border: none;
}

.mega-menu {
    padding: 0 !important;
    animation: fadeInDown 0.3s ease;
}

.mega-menu a:not(.btn) {
    transition: color 0.3s;
}

.mega-menu a:not(.btn):hover {
    color: var(--huawei-red) !important;
}

/* Desktop: Mostrar mega menu al hover */
@media (min-width: 992px) {
    .mega-dropdown:hover .dropdown-menu {
        display: block;
    }
}

/* ========================================
   PRODUCT CARDS (dentro del mega menu)
   ======================================== */
.product-card {
    transition: all 0.3s;
}

.product-card:hover {
    border-color: var(--huawei-red) !important;
    box-shadow: 0 4px 12px rgba(230, 0, 18, 0.1);
}

.product-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

/* ========================================
   OFFCANVAS MOBILE - HEADER SIEMPRE VISIBLE
   ======================================== */

/* Estructura del offcanvas */
.offcanvas {
    display: flex !important;
    flex-direction: column !important;
}

.offcanvas.w-100 {
    max-width: 100% !important;
}

/* HEADER FIJO - Logo y botón cerrar SIEMPRE VISIBLE POR ENCIMA DE TODO */
.offcanvas-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1080 !important; /* MÁS ALTO que submenu (1070) */
    background: white !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    padding: 1rem 1.5rem !important;
    min-height: 70px !important;
    flex-shrink: 0 !important;
}

/* BODY del offcanvas - Espacio para header fijo */
.offcanvas-body {
    padding-top: 80px !important;
    padding-bottom: 2rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 !important;
}

/* ========================================
   MOBILE MAIN MENU
   ======================================== */
.mobile-main-menu {
    position: relative;
    z-index: 1;
}

.mobile-main-menu a {
    transition: background-color 0.2s;
}

.mobile-main-menu a:hover {
    background-color: var(--huawei-light-gray);
}

.mobile-main-menu .bi-chevron-right {
    transition: transform 0.3s;
}

.mobile-main-menu a:hover .bi-chevron-right {
    transform: translateX(5px);
}

/* ========================================
   MOBILE SUBMENUS - DEBAJO DEL HEADER
   ======================================== */

/* Estructura del submenu - EMPIEZA DEBAJO DEL HEADER */
.mobile-submenu {
    position: fixed;
    top: 70px !important; /* Empieza DEBAJO del header del offcanvas */
    left: 100%;
    width: 100%;
    height: calc(100vh - 70px) !important; /* Altura menos el header */
    background: white;
    transition: left 0.3s ease;
    z-index: 1070 !important; /* MENOR que el header del offcanvas (1080) */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-submenu.active {
    left: 0;
}

/* HEADER DEL SUBMENU - Botón volver y título */
.submenu-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: var(--huawei-light-gray) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    padding: 1rem 1.5rem !important;
    min-height: 100px !important;
    flex-shrink: 0 !important;
}

/* CONTENIDO DEL SUBMENU */
.submenu-content {
    padding: 1.5rem !important;
    padding-bottom: 3rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 !important;
}

/* Botón volver al menú principal */
.back-to-main {
    font-size: 14px;
    transition: all 0.3s;
    color: var(--huawei-red) !important;
    margin-bottom: 0.75rem !important;
    display: flex !important;
    align-items: center !important;
}

.back-to-main:hover {
    text-decoration: none !important;
}

.back-to-main i {
    font-size: 20px;
    margin-right: 0.5rem;
}

/* Título del submenu */
.submenu-header h5 {
    margin: 0 !important;
}

/* ========================================
   PREVENIR SCROLL DEL BODY
   ======================================== */
body.submenu-open,
body.offcanvas-open {
    overflow: hidden !important;
}

/* ========================================
   SEARCH MODAL
   ======================================== */
.modal-fullscreen .form-control-lg {
    font-size: 1.5rem;
    padding-right: 3.5rem !important;
}

.modal-fullscreen .btn-close {
    filter: invert(1);
    opacity: 1;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideInFromRight {
    from {
        left: 100%;
    }
    to {
        left: 0;
    }
}

.mobile-submenu.active {
    animation: slideInFromRight 0.3s ease;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */
.offcanvas-body::-webkit-scrollbar,
.mobile-submenu::-webkit-scrollbar,
.submenu-content::-webkit-scrollbar {
    width: 6px;
}

.offcanvas-body::-webkit-scrollbar-track,
.mobile-submenu::-webkit-scrollbar-track,
.submenu-content::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.offcanvas-body::-webkit-scrollbar-thumb,
.mobile-submenu::-webkit-scrollbar-thumb,
.submenu-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.offcanvas-body::-webkit-scrollbar-thumb:hover,
.mobile-submenu::-webkit-scrollbar-thumb:hover,
.submenu-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Prevent bounce scroll en iOS */
.offcanvas-body,
.submenu-content {
    overscroll-behavior: contain;
}

/* ========================================
   FOCUS STATES
   ======================================== */
.btn:focus,
.form-control:focus {
    box-shadow: 0 0 0 0.25rem rgba(230, 0, 18, 0.25);
    border-color: var(--huawei-red);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.gap-2 {
    gap: 0.5rem !important;
}

.gap-10 {
    gap: 0.625rem !important;
}

.me-25px {
    margin-right: 25px !important;
}

.w-35px {
    width: 35px;
}

.h-35px {
    height: 35px;
}

.fs-12 {
    font-size: 12px !important;
}

.fs-13 {
    font-size: 13px !important;
}

.fs-15 {
    font-size: 15px !important;
}

.h-30px {
    height: 30px !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {
    .nav-link {
        padding: 0.75rem 1rem !important;
    }
    
    .header-top-bar {
        display: none;
    }
}

/* Pantallas pequeñas */
@media (max-width: 575.98px) {
    .product-card > div {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .offcanvas-header {
        min-height: 65px !important;
        padding: 0.75rem 1rem !important;
    }
    
    .offcanvas-body {
        padding-top: 75px !important;
    }
    
    .mobile-submenu {
        top: 65px !important;
        height: calc(100vh - 65px) !important;
    }
    
    .submenu-header {
        min-height: 95px !important;
        padding: 0.75rem 1rem !important;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 375px) {
    .offcanvas-header {
        min-height: 60px !important;
    }
    
    .offcanvas-body {
        padding-top: 70px !important;
    }
    
    .mobile-submenu {
        top: 60px !important;
        height: calc(100vh - 60px) !important;
    }
    
    .submenu-header {
        min-height: 90px !important;
    }
}

/* ========================================
   WORDPRESS SPECIFIC
   ======================================== */
/* Admin bar adjustment */
.admin-bar .sticky-top {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .sticky-top {
        top: 46px;
    }
}

/* Widget text compatibility */
.widget-text {
    display: inline-block;
}

/* Current menu item */
.current-menu-item > a,
.current-page-ancestor > a {
    color: var(--huawei-red) !important;
}

/* Menu alignment */
.navbar-nav {
    align-items: center;
}

/* Dropdown menu positioning */
.dropdown-menu {
    margin-top: 0;
}

/* Bootstrap Icons alignment */
.bi {
    vertical-align: -0.125em;
}

/* ========================================
   ADDITIONAL HELPERS
   ======================================== */
.text-huawei-red {
    color: var(--huawei-red) !important;
}

.bg-huawei-red {
    background-color: var(--huawei-red) !important;
}

.bg-current-language {
    background-color: var(--huawei-red) !important;
}

.bg-base-color {
    background-color: #f1872d !important;
}

/* Link hover effects in lists */
.list-unstyled a {
    transition: all 0.2s;
    display: inline-block;
}

.list-unstyled a:hover {
    transform: translateX(5px);
}

/* Sticky navbar enhancement */
.sticky-top {
    transition: all 0.3s ease;
}

/* Mega menu title styling */
.mega-menu h6 {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Ensure proper spacing */
.mega-menu .container {
    padding-left: 2rem;
    padding-right: 2rem;
}

/* ========================================
   MEJORAS VISUALES
   ======================================== */

/* Sombra cuando hay scroll */
.offcanvas-header.scrolled,
.submenu-header.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.offcanvas-header,
.submenu-header {
    transition: box-shadow 0.3s ease;
}

/* Logo en offcanvas header */
.offcanvas-header img {
    max-height: 40px;
}

/* Botón cerrar */
.offcanvas-header .btn-close {
    position: relative;
    z-index: 1;
}

/* Fix para iOS Safari */
@supports (-webkit-touch-callout: none) {
    .mobile-submenu {
        height: -webkit-fill-available;
    }
}

/* ========================================
   Z-INDEX HIERARCHY (IMPORTANTE)
   ======================================== */
/*
1055 - Offcanvas base (Bootstrap)
1070 - Mobile submenu
1080 - Offcanvas header (SIEMPRE POR ENCIMA)

Esto asegura que el logo y botón X siempre están visibles
*/