/* Estilos gerais do sidebar */
#sidebar {
    min-width: 250px;
    max-width: 250px;
    min-height: 100vh;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 250px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1020;
}

#sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #007bff 0%, #0056b3 100%);
    z-index: 1;
}

.sidebar-header {
    background: transparent;
    padding: 1rem 0.75rem !important;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header h4 {
    color: white;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Estilos dos itens do menu */
#sidebar ul {
    padding: 0;
    margin: 0;
}

#sidebar ul li {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    position: relative;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem !important;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: #2c3e50 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-radius: 0;
    margin: 0.15rem 0.5rem;
    border-radius: 8px;
}

.menu-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, #007bff 0%, #0056b3 100%);
    border-radius: 0 3px 3px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-item:hover::before,
.menu-item.active::before {
    transform: translateY(-50%) scaleY(1);
    height: 60%;
}

.menu-item:hover {
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.1) 0%, rgba(0, 123, 255, 0.05) 100%);
    color: #007bff !important;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.menu-item.active {
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.15) 0%, rgba(0, 123, 255, 0.08) 100%);
    color: #007bff !important;
    font-weight: 600;
}

/* Ícones do menu */
.menu-icon {
    font-size: 1.2rem;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #6c757d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.menu-item:hover .menu-icon,
.menu-item.active .menu-icon {
    color: #007bff;
    transform: scale(1.15);
}

/* Texto do menu */
.menu-text {
    flex: 1;
    transition: all 0.3s ease;
}

/* Seta do submenu */
.menu-arrow {
    font-size: 0.85rem;
    margin-left: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #6c757d;
}

.menu.active .menu-arrow {
    transform: rotate(180deg);
    color: #007bff;
}

/* Submenu */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease-in-out,
                padding 0.3s ease-in-out;
    padding-left: 0;
    padding-top: 0;
    padding-bottom: 0;
    background: rgba(248, 249, 250, 0.5);
    margin: 0.25rem 0.5rem;
    border-radius: 8px;
    opacity: 0;
}

.menu.active .submenu {
    max-height: 1000px;
    opacity: 1;
    padding: 0.5rem 0;
}

.submenu-item {
    padding-left: 3rem !important;
    font-size: 0.9rem !important;
    margin: 0.1rem 0.5rem !important;
}

.submenu-item .menu-icon {
    font-size: 1rem;
    margin-right: 0.5rem;
}

.submenu-item:hover {
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.12) 0%, rgba(0, 123, 255, 0.06) 100%);
    transform: translateX(8px);
}

/* Botão de toggle */
#sidebarCollapse {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
}

#sidebarCollapse:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

#sidebarCollapse:active {
    transform: translateY(0);
}

#sidebarCollapse i {
    font-size: 1.2rem;
}

/* Quando o menu está minimizado */
#sidebar.minimized {
    min-width: 80px;
    max-width: 80px;
    width: 80px;
}

#sidebar.minimized .menu-text,
#sidebar.minimized .menu-arrow {
    display: none;
}

#sidebar.minimized .menu-item {
    justify-content: center;
    padding: 0.875rem 0.5rem !important;
}

#sidebar.minimized .menu-icon {
    margin-right: 0;
}

#sidebar.minimized .submenu {
    display: none;
}

#sidebar.minimized .sidebar-header h4 {
    font-size: 0.8rem;
    padding: 0.5rem;
}

#sidebar.minimized ~ #content,
#sidebar.minimized + #content {
    margin-left: 80px;
    width: calc(100% - 80px);
    max-width: calc(100% - 80px);
}

/* Conteúdo da página */
#content {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    margin-left: 250px;
    padding-top: 56px;
    width: calc(100% - 250px);
    max-width: calc(100% - 250px);
    overflow-x: hidden;
}

/* Remove margem extra das containers internas para evitar deslocamento visual */
#content .container {
    margin-top: 0;
}

.navbar {
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    width: calc(100% - 250px);
    z-index: 1030;
}

/* For pages using Bootstrap spacing utilities (e.g., .mt-4) inside #content,
   force no top margin so the fixed navbar aligns correctly. */
#content .container.mt-4,
#content .container.mt-3,
#content .container.mt-2,
#content .container.mt-1 {
    margin-top: 0 !important;
}

/* Ensure navbar has explicit height to match content padding. */
.navbar {
    height: 56px;
    padding-top: 6px;
    padding-bottom: 6px;
}

@media only screen and (max-width: 800px) {
    #sidebar {
        position: fixed;
        z-index: 1000;
        top: 56px;
        height: calc(100vh - 56px);
        transform: translateX(-100%);
        min-width: 85%;
        max-width: 85%;
    }
    .sidebar-header {
        padding-top: 1rem !important;
        padding-bottom: 0.7rem !important;
    }
    #sidebar-logo-placeholder,
    #sidebar-logo-image {
        max-height: 64px !important;
        min-height: 64px !important;
        margin-top: 0.25rem;
    }
    #sidebar.open {
        transform: translateX(0);
    }
    #content {
        margin-left: 0;
        padding-top: 56px;
        width: 100%;
        max-width: 100%;
    }
    .navbar {
        left: 0;
        width: 100%;
    }
    #sidebar.minimized {
        transform: translateX(-100%);
        min-width: 85%;
        max-width: 85%;
    }
    #sidebar.minimized ~ #content,
    #sidebar.minimized + #content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
}


/* Efeitos de transição para modo escuro */
body.theme-dark #sidebar {
    background: linear-gradient(180deg, #111827 0%, #1f2937 100%);
    border-right: 1px solid rgba(255,255,255,0.08);
}

body.theme-dark #sidebar::before {
    background: linear-gradient(180deg, #818cf8 0%, #a78bfa 100%);
}

body.theme-dark .sidebar-header {
    background: linear-gradient(135deg, #4338ca 0%, #7c3aed 100%);
}

body.theme-dark .menu-item {
    color: #e5e7eb !important;
}

body.theme-dark .menu-item:hover,
body.theme-dark .menu-item.active {
    background: linear-gradient(90deg, rgba(129, 140, 248, 0.18) 0%, rgba(167, 139, 250, 0.12) 100%);
    color: #ffffff !important;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

body.theme-dark .menu-icon {
    color: #cbd5e1;
}

body.theme-dark .menu-item:hover .menu-icon,
body.theme-dark .menu-item.active .menu-icon {
    color: #ffffff;
}

body.theme-dark .menu-arrow {
    color: #cbd5e1;
}

body.theme-dark .submenu {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
}

body.theme-dark .menu-item::before {
    background: linear-gradient(180deg, #c7d2fe 0%, #ddd6fe 100%);
}

/* Animações */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.menu-item {
    animation: slideIn 0.3s ease-out;
}

/* Responsividade */
@media only screen and (max-width: 800px) {
    #sidebar {
        position: fixed;
        z-index: 1000;
        height: 100vh;
    }
    
    #sidebar.minimized {
        transform: translateX(-100%);
    }
}

/* Melhorias visuais adicionais */
.menu-item:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Efeito de ripple ao clicar */
.menu-item {
    position: relative;
    overflow: hidden;
}

.menu-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 123, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.menu-item:active::after {
    width: 300px;
    height: 300px;
}
