/* ===================================================================
   SIDEBAR.CSS - Estilos para a nova sidebar interativa (VERSÃO CORRIGIDA)
   ===================================================================*/

:root {
    --sidebar-width-collapsed: 88px;
    --sidebar-width-expanded: 260px;
    --sidebar-bg-color: var(--card-bg-color);
    --sidebar-border-color: var(--card-border-color);
}

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--sidebar-width-collapsed);
    background: var(--sidebar-bg-color);
    border-right: 1px solid var(--sidebar-border-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    overflow-x: hidden;
}

/* --- Estados da Sidebar --- */
body.sidebar-expanded #sidebar,
body.sidebar-pinned #sidebar {
    width: var(--sidebar-width-expanded);
}

/* =================================================================== */
/* HEADER DA SIDEBAR - LÓGICA DE VISIBILIDADE CORRIGIDA */
/* =================================================================== */
#sidebar .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    margin-bottom: 1.5rem;
    min-height: 60px;
}

.logo-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    position: relative; /* Necessário para o posicionamento dos filhos */
}

/* Ícone do logo (visível por padrão quando recolhido) */
.logo-icon {
    font-size: 1.8rem;
    color: var(--text-title);
    transition: opacity 0.2s ease, transform 0.3s ease;
    opacity: 1;
    transform: scale(1);
}

/* Texto do logo (invisível por padrão quando recolhido) */
.logo-text {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-primary);
    white-space: nowrap;
    transition: opacity 0.2s ease, transform 0.3s ease;
    opacity: 0;
    transform: scale(0);
    width: 0; /* Colapsa o espaço */
}
.logo-text strong {
    font-weight: 700;
    color: var(--text-title);
}

/* Lógica de troca ao expandir */
body.sidebar-expanded .logo-icon,
body.sidebar-pinned .logo-icon {
    opacity: 0;
    transform: scale(0);
}
body.sidebar-expanded .logo-text,
body.sidebar-pinned .logo-text {
    opacity: 1;
    transform: scale(1);
    width: auto; /* Restaura o espaço */
}


/* --- Menu Principal --- */
#sidebar .sidebar-menu {
    list-style: none;
    padding: 0 1rem;
    flex-grow: 1;
}

#sidebar .sidebar-menu .menu-item {
    margin-bottom: 0.5rem;
}

#sidebar .sidebar-menu .menu-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 1rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}
body.sidebar-expanded #sidebar .sidebar-menu .menu-link,
body.sidebar-pinned #sidebar .sidebar-menu .menu-link {
    justify-content: flex-start;
}

#sidebar .sidebar-menu .menu-link:hover {
    background-color: var(--hover-bg-color);
    color: var(--text-primary);
}

#sidebar .sidebar-menu .menu-link.active {
    background-color: var(--accent-color);
    color: #fff;
    font-weight: 500;
}

#sidebar .sidebar-menu .menu-link .menu-icon {
    font-size: 1.2rem;
    min-width: 30px;
    text-align: center;
    transition: margin-right 0.3s ease;
}
body.sidebar-expanded #sidebar .sidebar-menu .menu-link .menu-icon,
body.sidebar-pinned #sidebar .sidebar-menu .menu-link .menu-icon {
    margin-right: 1rem;
}

#sidebar .sidebar-menu .menu-link .menu-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.2s ease, width 0.3s ease;
}
body.sidebar-expanded #sidebar .sidebar-menu .menu-link .menu-text,
body.sidebar-pinned #sidebar .sidebar-menu .menu-link .menu-text {
    opacity: 1;
    width: auto;
}

/* --- Título da Página --- */
#page-title-container {
    padding: 0 1rem 1rem 1rem;
    text-align: center;
}
#page-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.2s ease;
}
body.sidebar-expanded #page-title,
body.sidebar-pinned #page-title {
    opacity: 1;
}

/* =================================================================== */
/* FOOTER DA SIDEBAR - ATUALIZADO COM VISIBILIDADE CONDICIONAL */
/* =================================================================== */
#sidebar .sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--sidebar-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Estilo para os botões do footer (tema e sair) */
.btn-theme-toggle, .menu-link-footer {
    background: var(--hover-bg-color);
    color: var(--text-secondary);
    border: 1px solid transparent;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-theme-toggle:hover, .menu-link-footer:hover {
    color: var(--text-primary);
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

/* --- LÓGICA DE VISIBILIDADE --- */
/* 1. Esconde o botão de tema por padrão */
#theme-toggle {
    opacity: 0;
    transform: scale(0);
    width: 0; /* Garante que não ocupe espaço */
    padding: 0;
    border: none;
    transition: all 0.3s ease;
}

/* 2. Mostra o botão de tema apenas quando a sidebar estiver expandida ou fixada */
body.sidebar-expanded #theme-toggle,
body.sidebar-pinned #theme-toggle {
    opacity: 1;
    transform: scale(1);
    width: 40px; /* Volta ao tamanho normal */
}

/* --- Ajuste do Conteúdo Principal --- */
#main-content {
    position: relative;
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
    transition: margin-left 0.3s ease, width 0.3s ease;
    padding-top: 0;
}

body.sidebar-expanded #main-content,
body.sidebar-pinned #main-content {
    margin-left: var(--sidebar-width-expanded);
    width: calc(100% - var(--sidebar-width-expanded));
}