/* =========================================================
   VARIÁVEIS DE TEMA E ESTILOS GLOBAIS
   ========================================================= */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --topbar-bg: #1e293b;
    --topbar-text: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-active-bg: #1e293b;
    --sidebar-hover-bg: rgba(30, 41, 59, 0.5);
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #334155;
    --footer-bg: #ffffff;
    --footer-text: #64748b;
    --main-font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
    font-family: var(--main-font);
    background-color: var(--body-bg);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important;
}

/* =========================================================
   COMPONENTES E DROPDOWNS DO TOPO
   ========================================================= */
.topbar-custom .position-relative {
    position: relative !important;
}

.topbar-custom .submenu-container {
    top: 100% !important;
    left: 0 !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
}

.topbar-custom, .navbar, .main-container {
    overflow: visible !important;
}

a, .btn-link {
    color: var(--primary-color);
}

.btn-primary {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-hover);
}

    .btn-primary:hover {
        background-color: var(--primary-hover);
        border-color: var(--primary-hover);
    }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--primary-color);
}

/* =========================================================
   ESTRUTURA E LAYOUT (DESKTOP)
   ========================================================= */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

.app-viewport {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar-custom {
    background-color: var(--topbar-bg);
    color: var(--topbar-text);
    min-height: 60px;
    height: auto !important;
    width: 100%;
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow: visible !important;
}

.user-badge {
    background-color: var(--primary-color);
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.main-container {
    display: flex;
    flex: 1;
    width: 100%;
    position: relative;
    overflow: visible !important;
}

.sidebar-custom {
    width: 280px;
    min-width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column !important;
    z-index: 1050;
}

    .sidebar-custom .nav,
    .sidebar-custom .nav-scrollable-custom,
    .sidebar-custom div[class*="nav"] {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }

.nav-scrollable-custom {
    background-color: var(--sidebar-bg, #0f172a);
    flex: 1;
    overflow-y: auto;
    width: 100%;
}

/* =========================================================
   ÁREA DE CONTEÚDO E ADAPTAÇÃO INTELIGENTE DE FUNDO
   ========================================================= */
.content-body {
    flex: 1;
    padding: 0 !important;
    background-color: var(--body-bg);
    min-height: calc(100vh - 3.5rem);
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

    .content-body .card,
    .content-body .row,
    .content-body container,
    .secao-vertical-custom {
        max-width: 100%;
        box-sizing: border-box;
    }

.footer-custom {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 0.75rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    z-index: 1000;
}

/* =========================================================
   OVERLAY E COMPORTAMENTO MOBILE / OFF-CANVAS (< 992px)
   ========================================================= */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

    .sidebar-overlay.show {
        display: block !important;
    }

@media (max-width: 991.98px) {
    .app-viewport {
        position: relative !important;
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    .main-container {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .sidebar-custom {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        min-width: 280px !important;
        height: 100vh !important;
        box-shadow: 15px 0 35px rgba(0,0,0,0.6) !important;
        z-index: 1055 !important;
        overflow-y: auto !important;
        margin: 0 !important;
        flex-direction: column !important;
    }

        .sidebar-custom.show {
            display: flex !important;
            flex-direction: column !important;
        }

        .sidebar-custom .nav-link {
            display: flex !important;
            flex-direction: row !important;
            align-items: center !important;
            width: 100% !important;
            white-space: nowrap !important;
            color: var(--sidebar-text, #ffffff) !important;
        }

            .sidebar-custom .nav-link:hover {
                color: #ffffff !important;
                background-color: rgba(255, 255, 255, 0.1);
            }

    .content-body {
        width: 100% !important;
        max-width: 100vw !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }

    .topbar-custom {
        padding: 0.5rem 0.75rem !important;
        position: relative !important;
        z-index: 3000 !important;
        overflow: visible !important;
    }

    .card, .card-body {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    table {
        width: 100% !important;
        min-width: 500px !important;
    }

    div[class*="table"] {
        width: 100% !important;
        overflow-x: auto !important;
    }

    .navbar-nav {
        overflow: visible !important;
    }

    .dropdown-container {
        position: relative !important;
        overflow: visible !important;
    }

    .dropdown-menu.show {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        z-index: 999999 !important;
        display: block !important;
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4) !important;
    }
}
