/* ============================================================
   VARIABLES Y CONFIGURACIÓN
   ============================================================ */
:root {
    --drawer-width: 300px;
    --drawer-bg: #ffffff;
    --drawer-text: #333333;
    --drawer-accent: #274633;       /* color principal / hover */
    --drawer-border: #eeeeee;
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --hamburger-color: #333333;
    --transition-speed: 0.3s;
    --z-drawer: 99999;
}


/* ============================================================
   OCULTAR todo en desktop explícitamente
   ============================================================ */
@media (min-width: 1025px) {
    .mobile-menu-toggle,
    .mobile-drawer,
    .mobile-menu-overlay,
    .mobile-header-logo,
    .mobile-header-cita {
        display: none !important;
    }
}



@media (max-width: 1024px) {

    /* ajustes generales elementos existentes */
    header#site-header {
        background-color: #274633 !important;
        max-width: 100% !important;   
        min-height: 3.5rem !important;
    }
    
    
    
    /* ============================================================
       BOTÓN HAMBURGER
       Solo visible en mobile (< 1024px, ajusta al breakpoint de tu web)
       ============================================================ */
    .mobile-menu-toggle {
        display: none;
        flex-direction: column;
        justify-content: space-between;
        width: 30px;
        height: 22px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        position: fixed;
        top: 16px;
        right: 16px;
        z-index: calc(var(--z-drawer) + 1);
    }
    
    .hamburger-bar {
        display: block;
        width: 100%;
        height: 3px;
        background: var(--hamburger-color);
        border-radius: 3px;
        transition: transform var(--transition-speed), opacity var(--transition-speed);
    }
    
    /* Animación a X cuando está abierto */
    .mobile-menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(1) {
        transform: translateY(9.5px) rotate(45deg);
    }
    .mobile-menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(2) {
        opacity: 0;
    }
    .mobile-menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(3) {
        transform: translateY(-9.5px) rotate(-45deg);
    }
    
    /* ============================================================
       OVERLAY
       ============================================================ */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: var(--overlay-bg);
        z-index: calc(var(--z-drawer) - 1);
        opacity: 0;
        transition: opacity var(--transition-speed);
    }
    
    .mobile-menu-overlay.is-visible {
        opacity: 1;
    }
    
    /* ============================================================
       DRAWER LATERAL (se desliza desde la derecha)
       ============================================================ */
    .mobile-drawer {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--drawer-width);
        max-width: 85vw;
        height: 100%;
        background: var(--drawer-bg);
        z-index: var(--z-drawer);
        transform: translateX(-100%);
        transition: transform var(--transition-speed) ease;
        overflow-y: auto;
        overscroll-behavior: contain;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15); 
        
        margin-top: 3.75rem;
    }
    
    .mobile-drawer.is-open {
        transform: translateX(0);
    }
    
    /* Botón cerrar (X) dentro del drawer */
    .mobile-drawer-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        font-size: 28px;
        cursor: pointer;
        color: var(--drawer-text);
        margin: 12px 12px 12px auto;
        line-height: 1;
    }
    
    /* ============================================================
       LISTA DE NAVEGACIÓN
       ============================================================ */
    .mobile-nav-list {
        list-style: none;
        margin: 0;
        padding: 0.25rem 0rem;
    }   
    
    .mobile-nav-list ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    
    /* Item de primer nivel */
    .mobile-nav-list > li {
        border-bottom: 1px solid var(--drawer-border);
        position: relative;
    }
    
    /* Items anidados */
    .mobile-nav-list li li {
        border-bottom: none;
    }
    
    /* Enlace */
    .mobile-nav-list a {
        display: block;
        padding: 10px 15px !important;
        color: var(--drawer-text);
        text-decoration: none;
        font-size: 1rem !important;
        font-weight: 600 !important;
        font-family: "Montserrat", Sans-serif !important;
        transition: color 0.2s, background 0.2s;
    }
    
    .mobile-nav-list a:hover,
    .mobile-nav-list a:focus {
        color: var(--drawer-accent) !important;
        background: #f8f8f8;
    }
    
    /* Enlace activo */
    .mobile-nav-list .current-menu-item > a,
    .mobile-nav-list .current-menu-ancestor > a {
        text-shadow: 1px 1px 1px #81E6A8 !important;
        font-weight: 700 !important;
    }
    
    /* ============================================================
       BOTÓN ACORDEÓN (toggle de submenú)
       ============================================================ */
    .mobile-submenu-toggle, 
    .elementor-kit-8 #mobile-drawer button {
        position: absolute;
        right: 0;
        top: 0;
        height: 42; 
        background: transparent;
        border: none;
        border-left: 1px solid var(--drawer-border);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--drawer-text);
        border-width: 0px !important;
        padding: 8px 15px 0px 0px !important;
        width: 1.5rem !important;
        background-color: #ffffff !important;
    }
    
    .mobile-submenu-toggle:hover,
    .elementor-kit-8 #mobile-drawer button:hover { 
        color: var(--drawer-accent) !important;
        background-color: #ffffff !important;
        border-color: #ffffff !important;
    
    }
    
    .mobile-submenu-toggle .toggle-icon {
        display: inline-block;
        font-size: 30px;
        line-height: 1;
        transform: rotate(270deg); /* apunta hacia abajo */
        transition: transform var(--transition-speed);
    }
    
    .mobile-submenu-toggle[aria-expanded="true"] .toggle-icon {
        transform: rotate(90deg); /* apunta hacia arriba cuando abierto */
    }
    
    /* ============================================================
       SUBMENÚ (acordeón)
       ============================================================ */
    .mobile-nav-list .sub-menu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
        background: #f5f5f5;
    }
    
    .mobile-nav-list .sub-menu.is-open {
        max-height: 1000px; /* valor alto suficiente */
        background: #eee8dd !important;
    }
    
    .mobile-nav-list .sub-menu a {
        padding-left: 36px;
        font-size: 14px;
        font-weight: 400;
    }
    
    /* Sub-submenú: más indentado */
    .mobile-nav-list .sub-menu .sub-menu a {
        padding-left: 52px;
    }
    
    
    /* ============================================================
   RESET FORZADO - Neutralizar CSS global de Elementor
   sobre el botón hamburger
   ============================================================ */
    button#mobile-hamburger,
    button.mobile-menu-toggle,
    button.mobile-menu-toggle:hover,
    button.mobile-menu-toggle:focus {
        all: unset;                        /* resetea TODO lo heredado */
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 30px !important;
        height: 22px !important;
        background: transparent !important;
        background-color: transparent !important;
        border: none !important;
        cursor: pointer !important;
        padding: 0 !important;
        /* position: fixed !important;
        top: 3% !important;
        left: 20px !important;
        transform: translateY(-50%) !important; */
        z-index: calc(var(--z-drawer) + 1) !important;
        box-shadow: none !important;
        margin: 0 !important;
        font-size: 0 !important;           /* elimina cualquier texto residual */
        color: transparent !important;
        
        position: static !important;   /* ← ya no fixed, el padre lo posiciona */
        top: auto !important;
        left: auto !important;
        transform: none !important;
        
        pointer-events: auto !important;
    }
    
    /* Asegurar que las barras siguen siendo visibles tras el all:unset */
    button.mobile-menu-toggle .hamburger-bar {
        display: block !important;
        width: 30px !important;
        height: 3px !important;
        background: #ffffff !important;
        border-radius: 3px !important;
        transition: transform 0.3s, opacity 0.3s !important;
    }
    
    /* Animación X cuando está abierto */
    button.mobile-menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(1) {
        transform: translateY(9.5px) rotate(45deg) !important;
    }
    button.mobile-menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(2) {
        opacity: 0 !important;
    }
    button.mobile-menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(3) {
        transform: translateY(-9.5px) rotate(-45deg) !important;
    }
    
    /* Forzar transición del drawer */
    .mobile-drawer {
        transition: transform 0.3s ease !important;
        will-change: transform;
        border-radius: 0rem 0.5rem 0rem 0rem;
    }
    
    .mobile-drawer.is-open {
        transform: translateX(0) !important;
    }

    
    /* Fix buscador */
    .mobile-header-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 3.5rem;
        z-index: calc(var(--z-drawer) + 1);
        padding: 0 16px;
        pointer-events: none; /* el bar en sí no captura clicks */
    }

    /* Cada hijo del bar sí captura clicks */
    .mobile-header-bar > * {
        pointer-events: auto;
    }

    .mobile-header-logo {
        display: flex;
        align-items: center;
        height: 3.5rem;
        padding-right: 2rem !important;
    }

    .mobile-header-logo img {
        height: 36px;
        width: auto;
        display: block;
    }

    .mobile-header-search {
        display: flex;
        align-items: center;
    }

    /* Ocultar el formulario, mostrar solo el icono de lupa */
    .mobile-header-search .is-search-form {
        display: none !important;
    }

    /* El icono de la lupa */
    .mobile-header-search .search-icon {
        fill: #ffffff;
        width: 22px;
        height: 22px;
        cursor: pointer;
    }

    /* Cuando se abre el buscador, mostrar el formulario */
    .mobile-header-search li.astm-search-menu.open .is-search-form {
        display: block !important;
        position: fixed !important;
        top: 3.5rem !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: var(--z-drawer) !important;
        background: #ffffff;
        padding: 12px 16px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    }

    /* Limpiar estilos de lista heredados del plugin */
    .mobile-header-search ul,
    .mobile-header-search li {
        list-style: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .astm-search-menu-wrapper svg.search-icon,
    .astm-search-menu-wrapper svg.search-icon path {
        fill: rgb(239,239,239) !important;   /* Cambia el relleno del SVG y sus trazados */
        width: 38px !important;
        height: 35px !important;
        padding-top: 0.5rem !important;
        padding-right: 0.5rem !important;
    
    }
    
    .mobile-nav-list .menu-item-has-children > a {
        cursor: default;
    }
}

/* ============================================================
   MOSTRAR TODO SOLO EN MOBILE
   Ajusta el breakpoint al de tu web
   ============================================================ */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: flex;
    }
}

@media (min-width: 1025px) {
    .mobile-drawer,
    .mobile-menu-overlay,
    .mobile-menu-toggle,
    .mobile-header-bar .mobile-header-search {
        display: none !important;
    }
}


/* ***  CUSTOM CODE  *** */
