/* ==================== CMS MENU STYLES ==================== */
/* Extraído de templates/core/menu/menu_render.html y base.html */
/* Estilos para el sistema de menús CMS: desktop dropdowns, badges, etc. */

/* Anti-FOUC: ocultar menú hasta que JS marque .loaded */
.site-menu { opacity: 0; }
.site-menu.loaded { opacity: 1; transition: opacity 0.2s ease-in; }

/* Submenús ocultos por defecto en desktop (hover los muestra) */
.menu-submenu, [class*="menu-submenu"] {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}
.menu-item:hover > .menu-submenu,
.menu-subitem:hover > .menu-submenu {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* ==================== BASE MENU ==================== */
.site-menu {
    position: relative;
    font-family: var(--font-primary, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.menu-item {
    position: relative;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    color: var(--text-primary, #1f2937);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    position: relative;
    letter-spacing: -0.01em;
}

.menu-link:hover {
    color: #0049ff;
    background: rgba(0, 73, 255, 0.05);
}

.menu-item.active > .menu-link {
    color: #0049ff;
    font-weight: 600;
    background: rgba(0, 73, 255, 0.08);
}

.menu-icon {
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-title {
    font-size: 0.9rem;
    position: relative;
}

.menu-title::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #0049ff, #0066ff);
    border-radius: 2px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-link:hover .menu-title::before {
    transform: translateX(-50%) scaleX(1);
}

.menu-item.active > .menu-link .menu-title::before {
    transform: translateX(-50%) scaleX(1);
}

/* ==================== BADGES ==================== */
.menu-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 0.25rem;
}

.menu-badge-red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.menu-badge-blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.menu-badge-green {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.menu-badge-yellow {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a1a;
    box-shadow: 0 2px 4px rgba(251, 191, 36, 0.3);
}

/* ==================== DROPDOWN ICON ==================== */
.menu-dropdown-icon {
    font-size: 0.6rem;
    margin-left: 0.25rem;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6;
}

.menu-item:hover > .menu-link .menu-dropdown-icon {
    transform: rotate(180deg);
    opacity: 1;
}

/* ==================== SUBMENU - DESKTOP DROPDOWN ==================== */
.menu-submenu {
    list-style: none;
    padding: 0.5rem;
    padding-top: 1rem;
    margin: 0;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    background: white;
    border-radius: 12px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -2px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    border: 1px solid rgba(0, 73, 255, 0.08);
}

/* Puente invisible para mantener hover */
.menu-submenu::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0.5rem;
    background: transparent;
}

.menu-item:hover > .menu-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Nested Submenus (Level 2+) */
.menu-submenu .menu-submenu {
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: 0;
    margin-top: 0;
    padding-left: 0.5rem;
}

.menu-submenu .menu-submenu::before {
    content: '';
    position: absolute;
    top: 0;
    left: -0.5rem;
    bottom: 0;
    width: 0.5rem;
    height: 100%;
    background: transparent;
}

.menu-subitem:hover > .menu-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* ==================== SUBMENU ITEMS ==================== */
.menu-subitem .menu-dropdown-icon {
    transform: rotate(-90deg);
    margin-left: auto;
}

.menu-subitem:hover > .menu-link .menu-dropdown-icon {
    transform: rotate(-90deg);
    opacity: 1;
}

.menu-subitem {
    padding: 0.15rem;
}

.menu-sublink {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    color: var(--text-primary, #374151);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    position: relative;
    letter-spacing: -0.01em;
}

.menu-sublink::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleX(0);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, #0049ff, #0066ff);
    border-radius: 0 2px 2px 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-sublink:hover {
    background: rgba(0, 73, 255, 0.06);
    color: #0049ff;
    padding-left: 1rem;
}

.menu-sublink:hover::before {
    transform: translateY(-50%) scaleX(1);
}

.menu-subitem.active > .menu-sublink {
    background: rgba(0, 73, 255, 0.1);
    color: #0049ff;
    font-weight: 600;
    padding-left: 1rem;
}

.menu-subitem.active > .menu-sublink::before {
    transform: translateY(-50%) scaleX(1);
}

/* ==================== FOOTER MENU VARIANT ==================== */
.site-menu-footer .menu-list {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.site-menu-footer .menu-link {
    padding: 0.5rem 0;
    border-radius: 0;
}

.site-menu-footer .menu-link::before {
    display: none;
}

.site-menu-footer .menu-submenu {
    position: relative;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    padding-left: 1rem;
    margin-top: 0.5rem;
    background: transparent;
}

/* ==================== MOBILE - NON-HEADER MENUS ==================== */
@media (max-width: 768px) {
    .site-menu:not(.header-menu-section .site-menu) .menu-list {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 0.5rem;
    }

    .site-menu:not(.header-menu-section .site-menu) .menu-link {
        padding: 0.75rem 1rem;
        justify-content: space-between;
    }

    .site-menu:not(.header-menu-section .site-menu) .menu-submenu {
        position: relative !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        box-shadow: none !important;
        border: none !important;
        padding-left: 1.5rem;
        margin-top: 0.5rem;
        margin-left: 0 !important;
        background: rgba(0, 73, 255, 0.02);
        left: auto !important;
        top: auto !important;
    }

    .site-menu:not(.header-menu-section .site-menu) .menu-dropdown-icon {
        margin-left: auto;
        transform: rotate(0deg) !important;
    }

    .site-menu:not(.header-menu-section .site-menu) .menu-subitem .menu-dropdown-icon {
        transform: rotate(0deg) !important;
    }

    .site-menu:not(.header-menu-section .site-menu) .menu-submenu .menu-submenu {
        padding-left: 1.5rem;
        margin-top: 0.5rem;
        background: rgba(0, 73, 255, 0.04);
    }
}

/* ==================== DARK THEME ==================== */
[data-theme="dark"] .menu-link {
    color: var(--text-primary, #e8eaed);
}

[data-theme="dark"] .menu-link:hover {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
}

[data-theme="dark"] .menu-submenu {
    background: var(--neo-surface, #1a1f2e);
    border-color: rgba(96, 165, 250, 0.15);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 10px 15px -3px rgba(0, 0, 0, 0.3),
        0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .menu-sublink {
    color: var(--text-secondary, #9aa0a6);
}

[data-theme="dark"] .menu-sublink:hover {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
}

/* ==================== MÓDULOS RESTRINGIDOS ==================== */
.module-restricted-link {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
}

.module-restricted-link:hover {
    opacity: 0.85 !important;
}

.menu-lock-icon {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-left: 0.25rem;
}
