/* ================================================
   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: #283F80;
    --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: flex-start;
    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: 5px;
    display: inline-block;
    width: 100%;
}

/* Estilo por defecto (Terminal - como en Marcas) */
.uniderma-menu-section.is-terminal .section-title {
    display: inline-block;
    font-size: 13px;
    font-weight: 400;
    color: var(--umm-text-secondary);
    margin-bottom: 0px;
    padding: 0px 0;
    border: none;
    transition: color 0.1s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Estilo cuando TIENE submenú (Título de grupo - como en Facial) */
.uniderma-menu-section.has-subs .section-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--umm-text-primary);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid #f0f0f0;
}

.uniderma-menu-section .section-title:hover {
    color: var(--umm-text-hover);
    font-weight: 600;
}

/* 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;
}

/* ================================================
   TOGGLE SWITCH STYLES
   ================================================ */
.uniderma-menu-wrapper .uniderma-custom-menu .menu-toggle-item {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 20px !important;
    margin-right: 10px !important;
    border-right: 1px solid rgba(40, 63, 128, 0.1) !important;
    height: 45px !important;
    /* Altura fija para coincidir con los links del menú */
    list-style: none !important;
    vertical-align: middle !important;
}

.uniderma-switch-container {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    flex-direction: row !important;
    height: 100% !important;
}

.switch-label {
    font-size: 13px;
    /* Un poco más grande para mejor legibilidad */
    font-weight: 700;
    color: var(--umm-text-primary);
    opacity: 0.5;
    transition: var(--umm-transition);
    cursor: pointer;
    white-space: nowrap;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
}

.uniderma-menu-wrapper.mode-catalog .switch-label.left,
.uniderma-menu-wrapper.mode-characteristic .switch-label.right {
    opacity: 1;
    color: var(--umm-text-primary);
}

.uniderma-switch {
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    width: 38px;
    height: 20px;
    flex-shrink: 0;
    margin: 0 4px;
}

.uniderma-switch input {
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    position: absolute;
    margin: 0 !important;
}

.uniderma-switch .slider {
    position: absolute !important;
    cursor: pointer !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: #bbbbbb !important;
    /* Gris más oscuro para estado inactivo */
    transition: .4s !important;
    display: block !important;
    border-radius: 20px !important;
}

.uniderma-switch .slider:before {
    position: absolute !important;
    content: "" !important;
    height: 14px !important;
    width: 14px !important;
    left: 3px !important;
    bottom: 3px !important;
    background-color: #ffffff !important;
    transition: .4s !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
    border-radius: 50% !important;
    display: block !important;
    z-index: 2 !important;
}

.uniderma-switch input:checked~.slider {
    background-color: var(--umm-text-primary) !important;
    /* Azul Uniderma */
}

.uniderma-switch input:checked~.slider:before {
    transform: translateX(18px) !important;
}

/* ================================================
   VISIBILITY LOGIC
   ================================================ */
.uniderma-menu-wrapper.mode-catalog .item-char-only {
    display: none !important;
}

.uniderma-menu-wrapper.mode-characteristic .item-catalog-only {
    display: none !important;
}

/* ================================================
   BADGES (Nuevo)
   ================================================ */
.badge-new {
    background: #e9e9e9;
    color: #333333;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 8px;
    font-weight: 600;
    vertical-align: middle;
    display: inline-block;
    line-height: 1.2;
}

.is-new-item>a {
    position: relative;
}