/* ============================================
   Sidebar - Panel de navegación GBM+
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-sidebar);
    z-index: 999;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
    animation: slideInLeft 0.5s ease-out;
}

.sidebar-header {
    padding: var(--space-xl) var(--space-lg);
    border-bottom: 1px solid var(--border-sidebar);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.sidebar-title {
    font-size: 1.25rem;
    margin: 0;
    color: var(--text);
    font-weight: 600;
    text-align: center;
    width: 100%;
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.sidebar-close:active {
    transform: rotate(90deg) scale(0.9);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-lg) 0;
    overflow-y: auto;
}

/* Toggle Modo Oscuro */
.sidebar-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border-sidebar);
    margin-top: auto;
}

.dark-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dark-mode-toggle:hover {
    background: var(--border-light);
}

.dark-mode-switch {
    width: 44px;
    height: 24px;
    background: var(--border-light);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s ease;
}

.dark-mode-switch::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: var(--text-inverse);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-card);
}

[data-theme="dark"] .dark-mode-switch {
    background: var(--primary);
}

[data-theme="dark"] .dark-mode-switch::after {
    transform: translateX(20px);
    background: var(--text-inverse);
    border-color: var(--primary);
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    border-left: 3px solid transparent;
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.nav-item i,
.nav-item .material-icons,
.nav-item .material-icons-outlined {
    font-size: 1.125rem;
    width: 20px;
    height: 20px;
    line-height: 20px;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.nav-item:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.nav-item:hover::before {
    transform: scaleY(1);
}

.nav-item:hover i,
.nav-item:hover .material-icons,
.nav-item:hover .material-icons-outlined {
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-input);
    border-left-color: var(--primary);
    color: var(--text-primary);
}

.nav-item.active::before {
    transform: scaleY(1);
}

.nav-item.active i,
.nav-item.active .material-icons,
.nav-item.active .material-icons-outlined {
    color: var(--text-primary);
}

.nav-group-arrow {
    margin-left: auto;
    font-size: 1.25rem !important;
    transition: transform 0.2s ease;
}

.nav-group-header.active .nav-group-arrow {
    transform: rotate(180deg);
    color: var(--text-primary);
}

/* Grupos de navegación (padres) */
.nav-group {
    margin-bottom: 0.5rem;
}

.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    border-left: 3px solid transparent;
    position: relative;
}

.nav-group-header:hover {
    background: var(--bg-input);
}

.nav-group-header i,
.nav-group-header .material-icons {
    font-size: 1rem;
    width: 20px;
    height: 20px;
    text-align: center;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.nav-group-header .material-icons {
    font-size: 1rem;
    width: 20px;
    height: 20px;
    line-height: 20px;
    color: #94a3b8;
    transition: all 0.3s ease;
}


.nav-group-content {
    overflow: hidden;
    max-height: 1000px;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 1;
}

.nav-group-content[style*="display: none"] {
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}

.nav-group-content .nav-item {
    padding-left: 3rem;
    font-size: 0.80rem;
    position: relative;
}

.nav-group-content .nav-item::before {
    content: '';
    position: absolute;
    left: 2.5rem;
    top: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    transform: translateY(-50%);
    transition: all 0.3s ease;
}

.nav-group-content .nav-item:hover::before,
.nav-group-content .nav-item.active::before {
    background: var(--primary);
    width: 8px;
    height: 8px;
}

/* Animación escalonada para items del nav */
.nav-item:nth-child(1) { animation: fadeInUp 0.4s ease-out 0.1s backwards; }
.nav-item:nth-child(2) { animation: fadeInUp 0.4s ease-out 0.2s backwards; }
.nav-item:nth-child(3) { animation: fadeInUp 0.4s ease-out 0.3s backwards; }
.nav-item:nth-child(4) { animation: fadeInUp 0.4s ease-out 0.4s backwards; }

/* Contenido principal */
.main-content {
    margin-left: 260px;
    min-height: 100vh;
    padding: var(--space-2xl);
    transition: margin-left 0.3s ease;
}

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 0;
}

.main-content .container:has(.home-screen) {
    max-width: 1280px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    animation: fadeIn 0.6s ease;
}

.main-content h1 {
    display: none;
}

.home-screen header h1 {
    display: block !important;
    text-align: left !important;
    font-size: 2.25rem !important;
}

/* Botón hamburguesa para móvil */
.menu-toggle {
    display: none;
    position: fixed;
    top: var(--space-lg);
    left: var(--space-lg);
    z-index: 1001;
    background: var(--primary);
    color: var(--text-inverse);
    border: none;
    border-radius: 6px;
    padding: var(--space-md) var(--space-lg);
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
    animation: fadeInDown 0.5s ease-out 0.2s backwards;
}

.menu-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: var(--shadow-card-hover);
}

.menu-toggle:active {
    transform: scale(0.98);
}

/* Overlay para móvil */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.menu-overlay.show {
    display: block;
}

.sidebar.show {
    transform: translateX(0);
}

/* Contenido principal */
.main-content {
    padding-top: var(--space-xl);
}

/* Responsive: sidebar oculto en móvil */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .menu-toggle {
        z-index: 1200;
    }

    .main-content {
        padding-top: 64px;
    }
}
