/* ================================================
   MENÚ PERSONALIZADO UNIDERMA - PREMIUM STYLES
   ================================================ */

:root {
    /* Variables de Tema */
    --umm-bg-wrapper: #F6F8FF;
    --umm-bg-dropdown: #ffffff;
    --umm-text-primary: #283F80;
    --umm-text-secondary: #555555;
    --umm-text-hover: #ff6633;
    --umm-border-light: rgba(255, 255, 255, 0.2);
    --umm-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --umm-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Sobrescribir estilos de Flatsome */
.header-bottom {
    overflow: visible !important;
}

.header-bottom .hide-for-medium {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
}

/* ================================================
   WRAPPER PRINCIPAL
   ================================================ */
.uniderma-menu-wrapper {
    width: 100%;
    width: 100dvw;
    /* Moderno: Viewport dinámico */
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    background: var(--umm-bg-wrapper);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.uniderma-menu-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* ================================================
   MENÚ NIVEL 1 (Raíz)
   ================================================ */
.uniderma-custom-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
}

.uniderma-custom-menu>li {
    position: static;
    /* Clave para el full-width dropdown */
    margin: 0;
}

.uniderma-custom-menu>li>a {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--umm-text-primary);
    font-size: 15px;
    font-weight: 600;
    /* text-transform: uppercase; REMOVED per user request */
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.uniderma-custom-menu>li>a:hover {
    background: rgba(40, 63, 128, 0.05);
    color: var(--umm-text-hover);
}

/* Flecha Indicadora */
.uniderma-custom-menu>li.has-dropdown>a::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    margin-left: 8px;
    opacity: 0.6;
    transform: translateY(1px);
}

/* ================================================
   MEGA DROPDOWN (Nivel 2+)
   ================================================ */
.uniderma-dropdown-wrapper {
    position: fixed;
    top: 100%;
    /* Fallback */
    left: 0;
    right: 0;
    width: 100%;
    max-height: 65vh;
    /* Ligeramente más alto */
    background: var(--umm-bg-dropdown);
    box-shadow: var(--umm-shadow);

    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--umm-transition);
    z-index: 9999;

    /* Scroll Logic */
    overflow-y: auto;
    overscroll-behavior: contain;
    /* CRITICAL: Evita scroll del body */

    display: flex;
    justify-content: center;
    border-top: 1px solid #f0f0f0;
}

/* Interacción Hover */
.uniderma-custom-menu>li.has-dropdown:hover .uniderma-dropdown-wrapper {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Contenedor Interno */
.uniderma-dropdown {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 20px;
}

/* Grid Layout Inteligente */
.uniderma-dropdown-grid {
    column-count: 4;
    column-gap: 20px;
    width: 100%;
}

/* Reglas especiales para pocos items (Flexbox en lugar de Columns) */
.uniderma-dropdown-grid.is-small-layout {
    display: flex;
    justify-content: center;
    column-count: unset;
    gap: 30px;
}

/* Sección (Nivel 2) */
.uniderma-menu-section {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 15px;
    display: inline-block;
    /* Fix para column-count */
    width: 100%;
}

.uniderma-menu-section .section-title {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--umm-text-primary);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 2px solid #f0f0f0;
}

/* Lista de Links (Nivel 3) */
.uniderma-submenu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.uniderma-submenu-list li {
    margin-bottom: 4px;
}

.uniderma-submenu-list li a {
    font-size: 14px;
    color: var(--umm-text-secondary);
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-block;
}

.uniderma-submenu-list li a:hover {
    color: var(--umm-text-hover);
    transform: translateX(4px);
    /* Pequeña animación de desplazamiento */
}

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 1024px) {
    .uniderma-dropdown-grid {
        column-count: 3;
    }
}

@media (max-width: 768px) {

    /* Mobile Override */
    .uniderma-custom-menu {
        flex-direction: column;
        align-items: stretch;
    }

    .uniderma-custom-menu>li {
        width: 100%;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .uniderma-custom-menu>li>a {
        justify-content: space-between;
    }

    .uniderma-dropdown-wrapper {
        position: static;
        box-shadow: none;
        max-height: 0;
        overflow: hidden;
        transform: none;
        display: block;
        /* Normal block flow en mobile */
        transition: max-height 0.3s ease;
        padding: 0;
    }

    .uniderma-custom-menu>li.mobile-open .uniderma-dropdown-wrapper {
        max-height: 1000px;
        /* Suficiente para contenido */
        opacity: 1;
        visibility: visible;
    }

    .uniderma-dropdown-grid {
        column-count: 1;
        display: block;
    }

    .uniderma-dropdown-grid.is-small-layout {
        display: block;
    }
}

/* ================================================
   SCROLL LOCK LOGIC (CRITICAL)
   ================================================ */

/* La clase se agrega al HTML por JS */
html.uniderma-no-scroll {
    overflow: hidden;
    scrollbar-gutter: stable;
    /* Reserva el espacio */
}