@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

/* ============================================= */
/* ZOOM DE 90% APLICADO À PÁGINA INTEIRA         */
/* ============================================= */
html {
    zoom: 100%;
    -moz-transform: scale(0.9);
    -moz-transform-origin: 0 0;
}

/* ============================================= */
/* CSS PARA CORREÇÃO DO LAYOUT COM SIDEBAR TOGGLE */
/* ============================================= */

#wrapper {
    display: flex;
    transition: all 0.3s ease;
}

#sidebar-wrapper {
    width: 250px;
    flex-shrink: 0;
    transition: margin-left 0.3s ease;
}

#page-content-wrapper {
    flex-grow: 1;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

#wrapper.toggled #sidebar-wrapper {
    margin-left: -250px;
}

/* Variáveis de cores e layout (PALETA CONDOFLOW) */
:root {
    --sidebar-width: 15rem;
    --mini-sidebar-width: 5rem;

    /* Modo Claro (Clean / Moderno) */
    --body-bg-light: #f8fafc;
    --card-bg-light: #ffffff;
    --text-color-light: #0f172a;
    --text-muted-light: #64748b;
    --border-color-light: #e2e8f0;
    --sidebar-bg-light: #ffffff;
    --sidebar-text-light: #475569;
    --sidebar-hover-bg-light: #f1f5f9;
    --navbar-bg-light: #ffffff;
    --modal-bg-light: #ffffff;
    --modal-border-light: #e2e8f0;

    /* Modo Escuro (CondoFlow Slate) */
    --body-bg-dark: #0f172a;
    --card-bg-dark: #1e293b;
    --text-color-dark: #f8fafc; /* Branco/Gelo para texto principal */
    --text-muted-dark: #94a3b8;  /* Cinza claro para texto secundário */
    --border-color-dark: #334155;
    --sidebar-bg-dark: #1e293b;
    --sidebar-text-dark: #cbd5e1;
    --sidebar-hover-bg-dark: #0f172a;
    --navbar-bg-dark: #1e293b;
    --modal-bg-dark: #1e293b;
    --modal-border-dark: #334155;

    /* Cores de destaque (Suaves) */
    --primary-highlight: #3b82f6;
    --info-highlight: #0ea5e9;
    --success-highlight: #10b981;
    --danger-highlight: #ef4444;
    --warning-highlight: #f59e0b;
    
    /* Fundo suave para os badges no modo escuro */
    --bg-badge-success: rgba(16, 185, 129, 0.15);
    --bg-badge-danger: rgba(239, 68, 68, 0.15);
    --bg-badge-warning: rgba(245, 158, 11, 0.15);
    --bg-badge-info: rgba(59, 130, 246, 0.15);
    --bg-badge-primary: rgba(59, 130, 246, 0.15);
}

/* Estilos Base do Body */
body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--body-bg-light);
    color: var(--text-color-light); /* Cor base do texto */
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

body.dark-mode {
    background-color: var(--body-bg-dark);
    color: var(--text-color-dark); /* Cor base no modo escuro */
}

/* --- FORÇAR CORES DE TEXTO NO MODO ESCURO --- */
body.dark-mode .text-dark,
body.dark-mode .text-body,
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4, body.dark-mode h5, body.dark-mode h6 {
    color: var(--text-color-dark) !important;
}

.text-muted { color: var(--text-muted-light) !important; }
body.dark-mode .text-muted, body.dark-mode .text-secondary { 
    color: var(--text-muted-dark) !important; 
}

/* ============================================= */
/* CORREÇÃO DEFINITIVA DAS TABELAS AGRUPADAS     */
/* ============================================= */
/* Modo Claro */
.bg-light-subtle { background-color: #f1f5f9 !important; color: var(--text-color-light) !important; }
.bg-primary-subtle { background-color: #dbeafe !important; }
.text-primary-emphasis { color: #1e40af !important; }

/* Modo Escuro */
body.dark-mode .bg-light-subtle { background-color: rgba(255, 255, 255, 0.05) !important; color: var(--text-color-dark) !important; }
body.dark-mode .bg-primary-subtle { background-color: rgba(59, 130, 246, 0.2) !important; }
body.dark-mode .text-primary-emphasis { color: #93c5fd !important; }

/* --- LÓGICA DE LAYOUT ORIGINAL MANTIDA --- */
#sidebar-wrapper {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000 !important; /* Z-INDEX original restaurado */
    transition: margin-left 0.3s ease-in-out;
    background-color: var(--sidebar-bg-light);
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;
    scrollbar-width: thin;
}

body.dark-mode #sidebar-wrapper {
    background-color: var(--sidebar-bg-dark);
}

#mini-sidebar {
    width: var(--mini-sidebar-width);
    min-width: var(--mini-sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 1rem;
    background-color: var(--sidebar-bg-light);
    border-right: 1px solid var(--border-color-light);
    transition: opacity 0.2s ease;
}

body.dark-mode #mini-sidebar {
    background-color: var(--sidebar-bg-dark);
    border-right-color: var(--border-color-dark);
}

#page-content-wrapper {
    width: 100%;
    flex-grow: 1;
    transition: margin-left 0.3s ease-in-out;
}

.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998; /* CORREÇÃO AQUI: Agora está abaixo do sidebar (1000) para não bloquear cliques no menu mobile! */
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* LÓGICA DE VISIBILIDADE E POSICIONAMENTO */
#sidebar-wrapper { margin-left: calc(-1 * var(--sidebar-width)); }
#mini-sidebar { display: none; }
#page-content-wrapper { margin-left: 0; }
#wrapper.toggled #sidebar-wrapper { margin-left: 0; }

@media (min-width: 768px) {
    #wrapper:not(.toggled) #sidebar-wrapper { margin-left: calc(-1 * var(--sidebar-width)); }
    #wrapper:not(.toggled) #mini-sidebar { display: flex; opacity: 1; }
    #wrapper:not(.toggled) #page-content-wrapper { margin-left: var(--mini-sidebar-width); }
    #wrapper.toggled #sidebar-wrapper { margin-left: 0; }
    #wrapper.toggled #mini-sidebar { opacity: 0; visibility: hidden; }
    #wrapper.toggled #page-content-wrapper { margin-left: var(--sidebar-width); }
}

/* --- ESTILOS DOS COMPONENTES --- */

.toggle-button {
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border: 1px solid var(--border-color-light) !important;
    background-color: transparent !important;
    color: var(--text-color-light) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.toggle-button:hover { background-color: var(--border-color-light) !important; }

body.dark-mode .toggle-button {
    border-color: var(--border-color-dark) !important;
    color: var(--text-color-dark) !important;
}
body.dark-mode .toggle-button:hover {
    background-color: var(--border-color-dark) !important;
}

.mini-btn {
    font-size: 1.5rem;
    color: var(--sidebar-text-light);
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}
.mini-btn:hover { background-color: var(--sidebar-hover-bg-light); }
body.dark-mode .mini-btn { color: var(--sidebar-text-dark); }
body.dark-mode .mini-btn:hover { background-color: var(--sidebar-hover-bg-dark); }

/* --- BOTÕES DO MENU --- */
#sidebar-wrapper .list-group-item-action {
    border: none;
    transition: all 0.2s ease;
    border-radius: 0.5rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 2px;
    font-size: 0.85rem;
    color: var(--sidebar-text-light);
    display: flex;
    align-items: center;
    background-color: transparent;
}

body.dark-mode #sidebar-wrapper .list-group-item-action {
    color: var(--sidebar-text-dark) !important;
}

#sidebar-wrapper .list-group-item-action:not(.active):hover {
    background-color: var(--sidebar-hover-bg-light);
    color: var(--primary-highlight) !important;
}

body.dark-mode #sidebar-wrapper .list-group-item-action:not(.active):hover {
    background-color: var(--sidebar-hover-bg-dark);
    color: var(--primary-highlight) !important;
}

#sidebar-wrapper .list-group-item-action.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-highlight) !important;
    font-weight: 600;
    border-left: 3px solid var(--primary-highlight);
    border-radius: 4px 8px 8px 4px;
}

#sidebar-wrapper .list-group-item-action.active .menu-text,
#sidebar-wrapper .list-group-item-action.active .bi {
    color: var(--primary-highlight) !important;
}

.submenu-container {
    border-left: 1px solid var(--border-color-light);
    margin-left: 1rem;
    padding-left: 0;
    background-color: transparent;
}
body.dark-mode .submenu-container { border-left-color: var(--border-color-dark); }

.submenu-container .list-group-item-action {
    padding-left: 1.5rem;
}

/* --- CARDS DE KPI IDÊNTICOS À IMAGEM 2 (CONDOFLOW) --- */
.card {
    border-radius: 1rem;
    border: 1px solid var(--border-color-light) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
    background-color: var(--card-bg-light) !important;
    color: var(--text-color-light) !important;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body.dark-mode .card {
    background-color: var(--card-bg-dark) !important;
    color: var(--text-color-dark) !important;
    border-color: var(--border-color-dark) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2) !important;
}

.kpi-card.border-start.border-4 { border-left: 1px solid var(--border-color-light) !important; }
body.dark-mode .kpi-card.border-start.border-4 { border-left: 1px solid var(--border-color-dark) !important; }

.kpi-card .card-body {
    display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: center; padding: 1.25rem;
}

.kpi-card .kpi-icon {
    width: 45px; height: 45px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; margin-right: 0 !important; opacity: 1;
}

.kpi-card .text-danger.kpi-icon { background-color: rgba(239, 68, 68, 0.15); color: var(--danger-highlight) !important; }
.kpi-card .text-success.kpi-icon { background-color: rgba(16, 185, 129, 0.15); color: var(--success-highlight) !important; }
.kpi-card .text-warning.kpi-icon { background-color: rgba(245, 158, 11, 0.15); color: var(--warning-highlight) !important; }
.kpi-card .text-primary.kpi-icon { background-color: rgba(59, 130, 246, 0.15); color: var(--primary-highlight) !important; }

.kpi-card .text-xs, .kpi-card .text-uppercase { color: var(--text-muted-light) !important; font-size: 0.75rem; letter-spacing: 0.5px; font-weight: 600; }
body.dark-mode .kpi-card .text-xs, body.dark-mode .kpi-card .text-uppercase { color: var(--text-muted-dark) !important; }

.kpi-card .h5, .kpi-card h3 { color: var(--text-color-light) !important; font-size: 1.6rem; margin-top: 5px; }
body.dark-mode .kpi-card .h5, body.dark-mode .kpi-card h3 { color: var(--text-color-dark) !important; }

.card-title { color: var(--text-color-light) !important; }
body.dark-mode .card-title { color: var(--text-color-dark) !important; }

/* ============================================= */
/* 7. TABELAS (CORES SUAVES E FUNDO TRANSPARENTE)*/
/* ============================================= */
.table { 
    color: var(--text-color-light) !important; 
    margin-bottom: 0; 
    background-color: transparent !important; 
}
body.dark-mode .table { 
    color: var(--text-color-dark) !important; 
}

/* Removemos qualquer fundo nativo do Bootstrap nas células */
.table > :not(caption) > * > * {
    background-color: transparent !important;
    border-bottom: 1px solid var(--border-color-light) !important;
    color: var(--text-color-light) !important;
    vertical-align: middle;
}

body.dark-mode .table > :not(caption) > * > * {
    background-color: transparent !important;
    border-bottom: 1px solid var(--border-color-dark) !important;
    color: var(--text-color-dark) !important;
}

.table thead th {
    background-color: transparent !important;
    color: var(--text-muted-light) !important;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    padding: 12px 15px; border-bottom: 1px solid var(--border-color-light) !important; border-top: none;
}
body.dark-mode .table thead th {
    color: var(--text-muted-dark) !important; border-bottom-color: var(--border-color-dark) !important;
}

.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(0, 0, 0, 0.02) !important; }
body.dark-mode .table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(255, 255, 255, 0.02) !important; }

.table-striped > tbody > tr:nth-of-type(even) > * { background-color: transparent !important; }
.table-hover > tbody > tr:hover > * { background-color: rgba(0, 0, 0, 0.04) !important; }
body.dark-mode .table-hover > tbody > tr:hover > * { background-color: rgba(255, 255, 255, 0.05) !important; }

/* ============================================= */
/* 8. BADGES E BOTÕES (STATUS E CONSULTAR)       */
/* ============================================= */

.badge { padding: 5px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.3px; border: 1px solid transparent; }

.bg-success { background-color: rgba(16, 185, 129, 0.15) !important; color: #10b981 !important; }
.bg-danger { background-color: rgba(239, 68, 68, 0.15) !important; color: #ef4444 !important; }
.bg-warning { background-color: rgba(245, 158, 11, 0.15) !important; color: #f59e0b !important; }
.bg-info { background-color: rgba(59, 130, 246, 0.15) !important; color: #3b82f6 !important; }
.bg-primary { background-color: rgba(59, 130, 246, 0.15) !important; color: #3b82f6 !important; }
.bg-secondary { background-color: rgba(100, 116, 139, 0.15) !important; color: #94a3b8 !important; }

/* CORREÇÃO DAS BADGES "SUBTLE" NO MODO ESCURO */
body.dark-mode .bg-success-subtle { background-color: rgba(16, 185, 129, 0.2) !important; color: #6ee7b7 !important; }
body.dark-mode .text-success-emphasis { color: #6ee7b7 !important; }

body.dark-mode .bg-info-subtle { background-color: rgba(14, 165, 233, 0.2) !important; color: #7dd3fc !important; }
body.dark-mode .text-info-emphasis { color: #7dd3fc !important; }

body.dark-mode .bg-secondary-subtle { background-color: rgba(148, 163, 184, 0.2) !important; color: #cbd5e1 !important; }
body.dark-mode .text-secondary-emphasis { color: #cbd5e1 !important; }

body.dark-mode .badge.bg-light.text-dark {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-color-dark) !important;
}

/* Botões da tabela */
.btn-sm { padding: 4px 8px; font-size: 0.75rem; border-radius: 6px; font-weight: 500; border: none !important; box-shadow: none !important; display: inline-flex; align-items: center; gap: 4px; }
.btn-primary { background-color: rgba(59, 130, 246, 0.15) !important; color: #3b82f6 !important; }
.btn-primary:hover { background-color: rgba(59, 130, 246, 0.25) !important; color: #fff !important; }
.btn-secondary { background-color: rgba(100, 116, 139, 0.15) !important; color: #94a3b8 !important; }

/* --- BARRA AZUL (NAVBAR) --- */
.bg-navbar { background-color: var(--navbar-bg-light) !important; border-bottom: 1px solid var(--border-color-light) !important; }
.bg-navbar .text-main, .bg-navbar .h3 { color: var(--text-color-light) !important; }
body.dark-mode .bg-navbar { background-color: var(--navbar-bg-dark) !important; border-bottom-color: var(--border-color-dark) !important; }
body.dark-mode .bg-navbar .text-main, body.dark-mode .bg-navbar .h3 { color: var(--text-color-dark) !important; }

/* ============================================= */
/* 9. INPUTS, PESQUISA E SELECTS NO MODO ESCURO  */
/* ============================================= */
.form-control, .form-select {
    background-color: var(--body-bg-light) !important;
    color: var(--text-color-light) !important;
    border-color: var(--border-color-light) !important;
}

body.dark-mode .form-control, body.dark-mode .form-select {
    background-color: rgba(0, 0, 0, 0.2) !important;
    color: var(--text-color-dark) !important;
    border-color: var(--border-color-dark) !important;
}

body.dark-mode .form-control::placeholder {
    color: var(--text-muted-dark) !important;
}

body.dark-mode .form-control:focus {
    border-color: var(--primary-highlight) !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ============================================= */
/* 10. MODAIS E LISTAS INTERNAS                  */
/* ============================================= */

/* CORREÇÃO DO BACKDROP (SOMBRA ATRÁS DA MODAL) */
/* Escondemos completamente a película que bloqueava os cliques */
.modal-backdrop {
    display: none !important; 
    visibility: hidden !important; 
    pointer-events: none !important;
}

/* Garante que a Modal fique bem acima no topo da página e possua uma sombra sólida nela mesma */
.modal { 
    z-index: 1060 !important; 
}

.modal-content {
    background-color: var(--card-bg-light) !important; /* Fundo Sólido */
    border: 1px solid var(--border-color-light) !important;
    border-radius: var(--radius-md);
    color: var(--text-main) !important;
    /* A sombra é gerada pela própria janela, dando o efeito 3D sem bloquear o resto da tela */
    box-shadow: 0 0 50px rgba(0,0,0,0.5) !important;
}

body.dark-mode .modal-content {
    background-color: var(--card-bg-dark) !important; /* Fundo Sólido Escuro */
    border-color: var(--border-color-dark) !important;
    box-shadow: 0 0 50px rgba(0,0,0,0.8) !important; /* Sombra mais forte no escuro */
}

.modal-header { border-bottom: 1px solid var(--border-color-light) !important; }
.modal-footer { border-top: 1px solid var(--border-color-light) !important; }
body.dark-mode .modal-header { border-bottom-color: var(--border-color-dark) !important; }
body.dark-mode .modal-footer { border-top-color: var(--border-color-dark) !important; }
body.dark-mode .btn-close { filter: invert(1) opacity(0.8); }

/* Força as Listas (Serviços Executados) a não terem fundo branco no modo escuro */
.list-group-item {
    background-color: transparent !important;
    border-color: var(--border-color-light) !important;
    color: var(--text-color-light) !important;
}

body.dark-mode .list-group-item {
    background-color: transparent !important;
    border-color: var(--border-color-dark) !important;
    color: var(--text-color-dark) !important;
}

/* BLINDAGEM DE TEXTO: Garante a leitura de qualquer texto solto dentro da modal */
body.dark-mode .modal-body,
body.dark-mode .modal-body p, 
body.dark-mode .modal-body span, 
body.dark-mode .modal-body div,
body.dark-mode .modal-body dl,
body.dark-mode .modal-body dt,
body.dark-mode .modal-body dd,
body.dark-mode .modal-body li,
body.dark-mode .modal-title {
    color: var(--text-color-dark) !important;
}

body.dark-mode .modal-body .text-muted { color: var(--text-muted-dark) !important; }

/* Customização Scrollbar */
#sidebar-wrapper::-webkit-scrollbar { width: 6px; }
#sidebar-wrapper::-webkit-scrollbar-thumb { background-color: var(--border-color-light); border-radius: 10px; }
body.dark-mode #sidebar-wrapper::-webkit-scrollbar-thumb { background-color: var(--border-color-dark); }
/* ============================================= */
/* CORREÇÃO DAS CAIXAS DE ALERTA NO MODO ESCURO  */
/* ============================================= */
body.dark-mode .alert-light {
    background-color: rgba(255, 255, 255, 0.05) !important; /* Fundo levemente translúcido/escuro */
    border-color: var(--border-color-dark) !important;      /* Borda escura */
    color: var(--text-color-dark) !important;               /* Texto claro */
}

/* Garante que links ou destaques dentro do alerta fiquem legíveis */
body.dark-mode .alert-light .text-primary {
    color: var(--primary-highlight) !important;
}