﻿/* Fixes consolidadas para AppAviva - Layout Full Height (Header/Footer Fixos) & Sidebar */

/* GLOBAL: Fixar Viewport para evitar scroll da janela */
html,
body {
    height: 100%;
    height: 100dvh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Forçar âncora total */
}

/* 1. ESTRUTURA MAIN CONTAINER (Flexbox Vertical) */
.main-container {
    height: 100% !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    box-sizing: border-box;
}

/* 2. HEADER FIXO */
.top-navbar {
    flex: 0 0 auto !important;
    width: 100% !important;
    z-index: 1020;
    background: #fff !important;
    border-bottom: 1px solid #e9ecef !important;
    padding: 0.5rem 1rem !important;
    box-shadow: none !important;
}

/* 3. CONTEÚDO ROLÁVEL CENTRAL */
.content-wrapper {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative;
    padding: 0 !important;
    height: auto !important;
}

#main-content-container {
    padding: 1.5rem !important;
    min-height: auto !important;
    padding-bottom: 3rem !important;
}

@media (max-width: 991px) {
    #main-content-container {
        padding: 0.5rem !important;
        padding-bottom: 150px !important;
        /* Espaço extra para barras do Safari/Chrome mobile */
    }
}

/* 4. FOOTER FIXO NA BASE */
.content-footer,
.main-footer {
    flex: 0 0 auto !important;
    width: 100% !important;
    margin: 0 !important;
    z-index: 1020;

    background: #fff !important;
    border-top: 1px solid #e9ecef;
    padding: 0.75rem 1.5rem !important;

    text-align: center;
    color: #6c757d;
    font-size: 0.85rem;
    display: block !important;
}

.content-footer *,
.main-footer * {
    margin-bottom: 0 !important;
}

/* --- LOGICA SIDEBAR (Layout Desktop/Mobile) --- */

@media (min-width: 992px) {
    .main-container {
        margin-left: 260px !important;
        width: auto !important;
        transition: margin-left 0.3s ease;
    }

    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px !important;
        z-index: 1030;
        overflow-y: auto;
        overflow-x: hidden;
        transition: width 0.3s ease;
    }

    #sidebarCollapse {
        display: inline-block !important;
    }

    /* Mini Sidebar */
    body.sidebar-collapsed .sidebar {
        width: 80px !important;
    }

    body.sidebar-collapsed .main-container {
        margin-left: 80px !important;
    }

    /* Hide Elements */
    body.sidebar-collapsed .sidebar a span,
    body.sidebar-collapsed .sidebar .nav-link span,
    body.sidebar-collapsed .sidebar .sidebar-header h3,
    body.sidebar-collapsed .sidebar .badge,
    body.sidebar-collapsed .sidebar .sidebar-header strong,
    body.sidebar-collapsed .sidebar a::after,
    body.sidebar-collapsed .sidebar .collapse.show {
        display: none !important;
    }

    /* Center Icons */
    body.sidebar-collapsed .sidebar a,
    body.sidebar-collapsed .sidebar .nav-link {
        justify-content: center !important;
        padding: 12px 0 !important;
        text-align: center;
    }

    body.sidebar-collapsed .sidebar i,
    body.sidebar-collapsed .sidebar svg {
        margin: 0 !important;
        font-size: 1.25rem !important;
    }

    body.sidebar-collapsed .sidebar .sidebar-header {
        padding: 5px !important;
        height: 60px;
        justify-content: center;
    }

    body.sidebar-collapsed .sidebar .sidebar-header img {
        margin: 0 !important;
    }
}

@media (max-width: 991px) {
    .main-container {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* VISUAL SIDEBAR */
.sidebar,
.offcanvas {
    background: linear-gradient(180deg, #1F2937 0%, #111827 100%);
    color: white;
}

.sidebar a,
.offcanvas a,
.sidebar .nav-link,
.offcanvas .nav-link {
    color: rgba(255, 255, 255, 0.75) !important;
    text-decoration: none !important;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-left: 4px solid transparent;
    white-space: nowrap;
    transition: all 0.2s ease-in-out !important;
}

.sidebar i,
.offcanvas i,
.sidebar svg,
.offcanvas svg {
    margin-right: 12px !important;
    width: 25px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar a:hover,
.offcanvas a:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.05);
}

/* ATIVO */
.sidebar a.active,
.offcanvas a.active,
.sidebar li.active>a,
.offcanvas li.active>a {
    background: linear-gradient(90deg, rgba(220, 20, 60, 0.2) 0%, rgba(220, 20, 60, 0.05) 100%) !important;
    color: #fff !important;
    border-left: 4px solid #DC143C !important;
    font-weight: 600 !important;
}

.sidebar a.active i,
.offcanvas a.active i,
.sidebar li.active>a i,
.offcanvas li.active>a i {
    color: #DC143C !important;
    transform: scale(1.1);
}

/* UTILS */
.page-link {
    margin: 0 !important;
    border-radius: 0 !important;
    border: 1px solid #e9ecef !important;
    color: #4b5563 !important;
}

.page-item.active .page-link {
    background-color: #DC143C !important;
    border-color: #DC143C !important;
    color: white !important;
}

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

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

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

/* INDENTAÇÃO DE SUBMENUS */
.sidebar .collapse a,
.offcanvas .collapse a,
.sidebar .collapse .nav-link,
.offcanvas .collapse .nav-link {
    padding-left: 32px !important;
    /* Indentação visual clara */
    background-color: rgba(0, 0, 0, 0.15) !important;
    /* Fundo mais escuro para contraste */
    font-size: 0.95rem;
    /* Leve redução de tamanho */
    border-left: 4px solid transparent !important;
    /* Mantém alinhamento da borda ativa */
}

/* Ajuste específico para quando o item do submenu for ATIVO */
.sidebar .collapse a.active,
.offcanvas .collapse a.active,
.sidebar .collapse .nav-link,
.offcanvas .collapse .nav-link.active {
    padding-left: 32px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-left-color: #DC143C !important;
}

/* Ícone do submenu levemente menor */
.sidebar .collapse a i,
.offcanvas .collapse a i,
.sidebar .collapse .nav-link,
.offcanvas .collapse .nav-link i {
    font-size: 0.9em !important;
    opacity: 0.8;
}


/* Delay escalonado mantido para efeito cascata fluido */
.sidebar .collapse.show li:nth-child(1),
.offcanvas .collapse.show li:nth-child(1) {
    animation-delay: 0.02s;
}

.sidebar .collapse.show li:nth-child(2),
.offcanvas .collapse.show li:nth-child(2) {
    animation-delay: 0.04s;
}

.sidebar .collapse.show li:nth-child(3),
.offcanvas .collapse.show li:nth-child(3) {
    animation-delay: 0.06s;
}

.sidebar .collapse.show li:nth-child(4),
.offcanvas .collapse.show li:nth-child(4) {
    animation-delay: 0.08s;
}

.sidebar .collapse.show li:nth-child(n+5),
.offcanvas .collapse.show li:nth-child(n+5) {
    animation-delay: 0.1s;
}

/* Animação extra no Hover: Recuo interativo */
.sidebar .collapse a {
    transition: padding-left 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), background-color 0.2s;
}

.sidebar .collapse a:hover {
    padding-left: 38px !important;
    /* +7px de deslocamento ao passar o mouse */
}

/* Ajuste Mobile Offcanvas Specific */
.offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.offcanvas .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    /* Botão fechar branco */
    opacity: 0.8;
}

/* --- Global SPA Loader Styles (InfoGestor) --- */
#global-loader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    transition: opacity 0.2s ease;
    opacity: 0;
    backdrop-filter: blur(2px);
}

#global-loader .loader-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


/* BADGES - Estilo Global (Rounded & Semibold) */
.badge {
    border-radius: 50rem !important;
    /* rounded-pill */
    font-weight: 600 !important;
    /* fw-semibold */
    padding: 0.35em 0.65em;
    /* Ajuste fino de padding */
}

/* FIX: Transição suave para todos os itens da sidebar (High Priority) */
.sidebar a,
.sidebar .sidebar-menu-link,
.sidebar .nav-link,
.sidebar .list-group-item {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}