/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--emerald-700) 0%, var(--emerald-900) 100%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

/* ==================== LOGO E HEADER ==================== */
.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    /* MUDANÇA: Adicionado position relative para posicionar o botão X dentro do header */
    position: relative;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
}

.logo-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.logo-text h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

/* ==================== MENU DE NAVEGAÇÃO ==================== */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.nav-section {
    padding: 0 1rem;
    margin-bottom: 1rem;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

/* ==================== ITENS DO MENU ==================== */
.nav-item {
    margin-bottom: 0.25rem;
    list-style-type: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: var(--transition);
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--emerald-600);
    color: white;
}

.nav-link.active {
    background: white;
    color: var(--emerald-700);
    font-weight: 600;
}

.nav-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.nav-text {
    flex: 1;
}

/* ==================== SUBMENU ==================== */
.nav-item.has-submenu .nav-link {
    position: relative;
}

.submenu-toggle {
    width: 1rem;
    height: 1rem;
    transition: transform 0.3s ease;
}

.nav-item.has-submenu.open .submenu-toggle {
    transform: rotate(180deg);
}

.submenu {
    display: none;
    padding-left: 2.5rem;
    margin-top: 0.25rem;
}

.nav-item.has-submenu.open .submenu {
    display: block;
}

.submenu .nav-link {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

/* ==================== FOOTER DA SIDEBAR ==================== */
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-link.logout {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: white;
}

/* ==================== BOTÃO MENU MOBILE (HAMBURGUER) ==================== */
/* MUDANÇA CORRETA: Botão hambúrguer fica no lado DIREITO da tela */
.menu-toggle {
    display: none; /* Escondido por padrão (desktop) */
    position: fixed;
    top: 1rem;
    right: 1rem; /* MUDANÇA: Agora fica à DIREITA (não mais à esquerda) */
    z-index: 1002; /* Acima da sidebar (z-index: 1000) */
    width: 2.5rem;
    height: 2.5rem;
    background: var(--emerald-600);
    border: none;
    border-radius: 0.5rem;
    color: white;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.menu-toggle:hover {
    background: var(--emerald-700);
    transform: scale(1.05);
}

.menu-toggle i {
    font-size: 1.25rem;
}

/* MUDANÇA CORRETA: Por padrão, mostra o ícone hamburguer ☰ e esconde o X */
.menu-toggle .close-icon {
    display: none;
}

/* MUDANÇA CORRETA: Quando menu está aberto (.active), esconde hamburguer ☰ e mostra X */
.menu-toggle.active .menu-icon {
    display: none;
}

.menu-toggle.active .close-icon {
    display: block;
}

/* ==================== BOTÃO FECHAR DENTRO DA SIDEBAR ==================== */
/* MUDANÇA: Botão X também aparece DENTRO da sidebar no canto superior direito */
.sidebar-close {
    display: none; /* Escondido no desktop */
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 2rem;
    height: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 0.375rem;
    color: white;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-close i {
    font-size: 1rem;
}

/* ==================== RESPONSIVIDADE ==================== */
@media (max-width: 768px) {
    /* No mobile, sidebar começa escondida (fora da tela à esquerda) */
    .sidebar {
        transform: translateX(-100%);
    }
    
    /* Quando tem classe .active, sidebar aparece na tela */
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* MUDANÇA: Mostra o botão hambúrguer no lado DIREITO no mobile */
    .menu-toggle {
        display: flex;
    }
    
    /* MUDANÇA: Mostra o botão X dentro da sidebar quando ela está aberta */
    .sidebar.active .sidebar-close {
        display: flex;
    }
    
    /* Quando sidebar está aberta, bloqueia scroll do body */
    body.sidebar-open {
        overflow: hidden;
    }
}

/* ==================== ANIMAÇÕES ==================== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nav-item {
    animation: slideIn 0.3s ease forwards;
}

.nav-item:nth-child(1) { animation-delay: 0.05s; }
.nav-item:nth-child(2) { animation-delay: 0.1s; }
.nav-item:nth-child(3) { animation-delay: 0.15s; }
.nav-item:nth-child(4) { animation-delay: 0.2s; }
.nav-item:nth-child(5) { animation-delay: 0.25s; }
.nav-item:nth-child(6) { animation-delay: 0.3s; }