:root {
    /* Paleta de Cores - Light Mode */
    --theme-primary: #ffc107; /* Amarelo principal */
    --theme-primary-rgb: 255, 193, 7;
    --theme-primary-dark: #212529; /* Cor do texto no botão primário */

    --theme-bg: #f8f9fa; /* Fundo principal (branco suave) */
    --theme-bg-rgb: 248, 249, 250;
    --theme-surface: #ffffff; /* Fundo de componentes como cards e modais */
    --theme-surface-rgb: 255, 255, 255;
    
    --theme-text: #212529; /* Cor do texto principal */
    --theme-text-muted: #6c757d; /* Cor do texto secundário */
    --theme-border: #dee2e6; /* Cor das bordas */

    /* Tipografia e Bordas */
    --bs-font-sans-serif: 'Poppins', sans-serif;
    --border-radius: 0.5rem; /* 8px */
    --border-radius-lg: 0.75rem; /* 12px */
}

/* Paleta de Cores - Dark Mode */
[data-bs-theme="dark"] {
    --theme-primary: #ffc107;
    --theme-primary-rgb: 255, 193, 7;
    --theme-primary-dark: #212529;

    --theme-bg: #222222; /* Fundo principal (preto customizado) */
    --theme-bg-rgb: 34, 34, 34;
    --theme-surface: #2c2c2c; /* Fundo de componentes */
    --theme-surface-rgb: 44, 44, 44;

    --theme-text: #f8f9fa;
    --theme-text-muted: #adb5bd;
    --theme-border: #495057;
}

/* 2. ESTILOS GERAIS E BASE
 * ===========================
 * Configurações globais que afetam o corpo do documento e
 * garantem transições suaves na troca de tema.
*/
body {
    background-color: var(--theme-bg);
    color: var(--theme-text);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 3. PERSONALIZAÇÃO DE COMPONENTES
 * ===================================
 * Aqui, sobrescrevemos os estilos dos componentes do Bootstrap.
*/

/* --- NAVBAR --- */
.navbar {
    background-color: var(--theme-surface);
    border-bottom: 1px solid var(--theme-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease;
}
.navbar-brand { color: var(--theme-primary); }
.nav-link {
    color: var(--theme-text-muted);
    font-weight: 500;
    transition: color 0.2s ease;
}
.nav-link.active, .nav-link:hover { color: var(--theme-primary); }
.navbar-toggler { border: none; font-size: 1.5rem; color: var(--theme-primary); }
.navbar-toggler:focus { box-shadow: none; }

/* --- BOTÕES (BTN) --- */
.btn {
    border-radius: var(--border-radius);
    font-weight: 600;
    padding: 0.6rem 1.5rem;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
}

.btn-primary {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--theme-primary-dark);
}
.btn-primary:hover, .btn-primary:focus {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(var(--theme-primary-rgb), 0.3);
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--theme-primary-dark);
}
.btn-secondary {
    background-color: var(--theme-surface);
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}
.btn-secondary:hover {
    background-color: var(--theme-primary);
    color: var(--theme-primary-dark);
}

/* --- CARD --- */
.card {
    background-color: var(--theme-surface);
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.icon-box {
    width: 60px;
    height: 60px;
    background-color: rgba(var(--theme-primary-rgb), 0.1);
    color: var(--theme-primary);
    border-radius: var(--border-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

/* --- TABS --- */
.nav-tabs { border-bottom-color: var(--theme-border); }
.nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--theme-text-muted);
    font-weight: 600;
}
.nav-tabs .nav-link.active, .nav-tabs .nav-link:hover {
    border-color: var(--theme-primary);
    color: var(--theme-primary);
    background: none;
}
.tab-content { padding-top: 1.5rem; }

/* --- FORMS --- */
.form-control {
    background-color: var(--theme-bg);
    border: 1px solid var(--theme-border);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
}
.form-control:focus {
    background-color: var(--theme-surface);
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.2);
    color: var(--theme-text);
}
.form-check-input:checked {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
}

/* --- ALERTS --- */
.alert {
    border: none;
    border-left: 5px solid;
    border-radius: var(--border-radius);
    background-color: var(--theme-surface);
    color: var(--theme-text);
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.07);
}
.alert .bi { font-size: 1.25rem; }
.alert-success { border-color: #198754; color: #198754; }
.alert-warning { border-color: #ffc107; color: #ffc107; }
.alert-danger { border-color: #dc3545; color: #dc3545; }
[data-bs-theme="dark"] .alert-success { color: #20c997; border-color: #20c997; }
[data-bs-theme="dark"] .alert-warning { color: #ffca2c; border-color: #ffca2c; }
[data-bs-theme="dark"] .alert-danger { color: #fd7e14; border-color: #fd7e14; }

/* --- MODAL --- */
.modal-content {
    background-color: var(--theme-surface);
    border: none;
    border-radius: var(--border-radius-lg);
}
.modal-header, .modal-footer { border-color: var(--theme-border); }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* --- FOOTER --- */
.footer {
    background-color: var(--theme-surface);
    border-top: 1px solid var(--theme-border);
}
.footer .text-muted { color: var(--theme-text-muted) !important; }

.accordion-button {
    font-weight: 600;
}

.accordion-button:focus {
    box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.2);
    border-color: transparent; /* Evita bordas duplicadas no foco */
}

.accordion {
    --bs-accordion-color: var(--theme-text);
    --bs-accordion-bg: var(--theme-surface);
    --bs-accordion-border-color: var(--theme-border);
    --bs-accordion-border-radius: var(--border-radius-lg);
    --bs-accordion-inner-border-radius: var(--border-radius);
    
    --bs-accordion-btn-color: var(--theme-text);
    --bs-accordion-btn-bg: var(--theme-surface);
    --bs-accordion-btn-focus-box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.2);

    --bs-accordion-active-color: var(--theme-primary);
    --bs-accordion-active-bg: rgba(var(--theme-primary-rgb), 0.05); /* Fundo amarelo sutil quando aberto */

    /* Customiza o ícone de seta (chevron) */
    --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='#{str-replace(var(--theme-text-muted), "#", "%23")}'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
    --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='#{str-replace(var(--theme-primary), "#", "%23")}'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.accordion-body img {
    max-width: 100% !important;
}

.TinyMDE {
    border: 1px solid #f1f1f1 !important;
    min-height: 300px !important;
    overflow: auto !important;
    background-color: var(--theme-bg) !important;
    color: var(--theme-text) !important;
}

.TMCommandBar {
    background-color: var(--theme-bg) !important;
    border: 1px solid var(--theme-border) !important;
    padding: 5px !important;
}

.TMCommandButton {
    fill: var(--theme-text) !important;
}

.TMCommandButton_Inactive {
    background-color: transparent !important;
}