/* ========================================
   SIDEBAR-CUSTOM.CSS
   Estilos completos da Barra Lateral (Sidebar)
======================================== */

/* 1. ESTRUTURA PRINCIPAL
======================================== */

.sidebar {
    position: fixed;
    top: 10px;
    left: 10px;
    height: calc(100vh - 20px);
    width: var(--sidebar-width-expanded);
    background-color: var(--primary-color);
    color: var(--text-color);
    padding: 20px 0px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    border-radius: 12px;
    transition: width 0.4s ease, transform 0.4s ease;
}

/* 2. CABEÇALHO E LOGO DA SIDEBAR
======================================== */

.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-logo-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
}

.sidebar-logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* 3. NAVEGAÇÃO E MENU
======================================== */

.sidebar-nav {
    flex-grow: 1;
    overflow-x: hidden;
    overflow-y: scroll;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav ul a {
    display: flex;
    align-items: center;
    height: 50px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text-color);
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    transition: background-color 0.3s;
    margin-left: 14px;
    margin-right: 8px;
}

.sidebar-nav ul a:hover,
.sidebar-nav > ul > li > a.active {
    background-color: var(--secondary-color);
}

.sidebar-nav > ul > li > a > i:first-child {
    font-size: 20px;
    min-width: 60px;
    text-align: center;
}

.sidebar-nav ul a .link-text {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.sidebar-nav .arrow {
    margin-left: auto;
    margin-right: 20px;
    font-size: 14px;
    transition: transform 0.3s ease, opacity 0.2s ease;
}

.sidebar-nav li.open > a .arrow {
    transform: rotate(-180deg);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    padding: 0 10px;
}

.submenu a {
    background-color: rgba(255, 255, 255, 0.4);
    height: 45px;
    text-align: center;
}

.submenu a i {
    min-width: 40px;
    font-size: 0.8em;
    opacity: 0.8;
}

/* 4. DIVISOR E RODAPÉ DA SIDEBAR
======================================== */

.sidebar-divider {
    height: 1px;
    background-color: rgba(140, 80, 97, 0.2);
    border: 0;
    margin: 1rem 10%;
    width: 80%;
    transition: opacity 0.3s ease;
}

.sidebar-footer {
    text-align: center;
    font-size: 0.8rem;
    padding: 10px;
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.sidebar-footer span {
    display: block;
}


/* 5. ESTADO RECOLHIDO (COLLAPSED)
======================================== */

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .link-text,
body.sidebar-collapsed .arrow,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .sidebar-divider {
    opacity: 0;
    pointer-events: none;
}

body.sidebar-collapsed .sidebar-header {
    margin-bottom: 15px;
}
body.sidebar-collapsed .sidebar-logo-img {
    width: 48px;
    height: 48px;
}
body.sidebar-collapsed .sidebar-nav > ul > li > a > i:first-child {
    width: 100%;
}

body.sidebar-collapsed .submenu {
    display: none;
}

/* 6. BOTÃO DE FECHAR (MOBILE)
======================================== */

.sidebar-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 20px;
    background-color: rgba(255,255,255,0.5);
    border: none;
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: none; /* Escondido por padrão */
    align-items: center;
    justify-content: center;
    z-index: 1001; /* Adicionado para garantir que fique na frente */
}

/* 7. ESTILOS MOBILE
======================================== */
@media (max-width: 767.98px) {
    .sidebar {
        left: 0;
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    
    body.mobile-sidebar-open .sidebar {
        transform: translateX(0);
    }
    
    /* Seletor mais específico para garantir que a regra seja aplicada */
    body.mobile-sidebar-open .sidebar-close-btn {
        display: flex; 
    }
}

/* 8. BARRA DE ROLAGEM PERSONALIZADA
======================================== */

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

.sidebar-nav::-webkit-scrollbar-button {
    display: none;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: var(--primary-color);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: var(--secondary-color);
    border-radius: 10px;
    border: 2px solid var(--primary-color);
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background-color: #e3a2b6;
}


/**/
.sidebar-nav ul a.active {
    background-color: var(--secondary-color);
    color: #fff; /* opcional para realce */
    font-weight: bold; /* opcional */
}


/* Tema Lux Spa Premium */
.sidebar {
    background: linear-gradient(180deg, #8F1A18 0%, #5B1F24 100%) !important;
    color: #F7F1EA !important;
    box-shadow: 0 18px 45px rgba(91, 31, 36, .25);
}
.sidebar-logo-text,
.sidebar-nav ul a,
.sidebar-footer,
.sidebar-close-btn { color: #F7F1EA !important; }
.sidebar-nav ul a:hover,
.sidebar-nav ul a.active,
.sidebar-nav > ul > li > a.active {
    background: rgba(200, 164, 122, .24) !important;
    color: #fff !important;
}
.submenu a { background-color: rgba(255, 253, 249, .10) !important; }
.sidebar-divider { background-color: rgba(200, 164, 122, .45) !important; }
.sidebar-nav::-webkit-scrollbar-track { background: #5B1F24 !important; }
.sidebar-nav::-webkit-scrollbar-thumb { background-color: #C8A47A !important; border-color: #5B1F24 !important; }
.sidebar-close-btn { background-color: rgba(200, 164, 122, .28) !important; }
