/*
 * Tema escuro global.
 * Usa html[data-theme="dark"] para aplicar antes do body existir e reduzir flash visual.
 */
html[data-theme="dark"] {
    color-scheme: dark;
    --primary-color: #60a5fa;
    --primary-light: #93c5fd;
    --primary-dark: #2563eb;
    --primary: #60a5fa;
    --secondary: #a78bfa;
    --secondary-color: #cbd5e1;
    --success-color: #34d399;
    --success: #34d399;
    --warning-color: #fbbf24;
    --warning: #fbbf24;
    --danger-color: #fb7185;
    --danger: #fb7185;
    --dark-color: #e5e7eb;
    --dark: #e5e7eb;
    --darker-color: #f8fafc;
    --light-color: #0f172a;
    --light: #0f172a;
    --gray-color: #94a3b8;
    --gray: #94a3b8;
    --border-color: #263244;
    --border: #263244;
    --card-bg: #111827;
    --surface-bg: #0b1220;
    --surface-bg-soft: #111827;
    --surface-bg-muted: #1f2937;
    --text-color: #e5e7eb;
    --text-muted: #94a3b8;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 10px 26px rgba(0, 0, 0, 0.38);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.45);
    --shadow: 0 10px 26px rgba(0, 0, 0, 0.38);
}

html[data-theme="dark"] body {
    background: var(--surface-bg) !important;
    color: var(--text-color) !important;
}

html[data-theme="dark"] .dashboard-layout,
html[data-theme="dark"] .dashboard-container,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .usuarios-container {
    background: var(--surface-bg) !important;
    color: var(--text-color) !important;
}

html[data-theme="dark"] .main-header,
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .login-container,
html[data-theme="dark"] .login-form,
html[data-theme="dark"] .licenca-card,
html[data-theme="dark"] .licenca-status,
html[data-theme="dark"] .page-header,
html[data-theme="dark"] .tab-content,
html[data-theme="dark"] .modal-container,
html[data-theme="dark"] .user-menu,
html[data-theme="dark"] .checkbox-dropdown-menu,
html[data-theme="dark"] .alertas-indicadores-card,
html[data-theme="dark"] .alertas-indicadores-header,
html[data-theme="dark"] .executivo-kpi-card,
html[data-theme="dark"] .executivo-chart-card,
html[data-theme="dark"] .executivo-modal-content,
html[data-theme="dark"] .executivo-modal-chart-card,
html[data-theme="dark"] .dashboard-card-wrapper > * {
    background: var(--surface-bg-soft) !important;
    border-color: var(--border-color) !important;
    color: var(--text-color) !important;
    box-shadow: var(--shadow-md) !important;
}

html[data-theme="dark"] .sidebar-brand,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] header {
    background: linear-gradient(135deg, #0f2a44, #1d4ed8) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] .header-title-text,
html[data-theme="dark"] .user-name,
html[data-theme="dark"] .user-name-large,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .metric-value,
html[data-theme="dark"] .metric-value-large,
html[data-theme="dark"] .metric-value-medium,
html[data-theme="dark"] .executivo-kpi-mini strong,
html[data-theme="dark"] .alertas-indicadores-card h3 {
    color: var(--text-color) !important;
}

html[data-theme="dark"] p,
html[data-theme="dark"] span,
html[data-theme="dark"] label,
html[data-theme="dark"] small,
html[data-theme="dark"] td,
html[data-theme="dark"] .user-role,
html[data-theme="dark"] .user-email,
html[data-theme="dark"] .current-date,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .form-help,
html[data-theme="dark"] .alertas-indicadores-header span,
html[data-theme="dark"] .alertas-indicadores-card small,
html[data-theme="dark"] .executivo-kpi-mini span,
html[data-theme="dark"] .executivo-kpi-mini small {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .menu-link,
html[data-theme="dark"] .sidebar-footer .btn-logout,
html[data-theme="dark"] .sidebar-footer .btn-refresh,
html[data-theme="dark"] .theme-toggle {
    background: transparent !important;
    border-color: var(--border-color) !important;
    color: var(--text-color) !important;
}

html[data-theme="dark"] .menu-link:hover,
html[data-theme="dark"] .menu-item.active .menu-link,
html[data-theme="dark"] .user-menu-item:hover,
html[data-theme="dark"] tr:hover,
html[data-theme="dark"] .checkbox-dropdown-item:hover {
    background: rgba(96, 165, 250, 0.12) !important;
    color: #bfdbfe !important;
}

html[data-theme="dark"] .menu-link i,
html[data-theme="dark"] .theme-toggle i {
    color: #93c5fd !important;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .login-form input,
html[data-theme="dark"] .period-select,
html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-textarea,
html[data-theme="dark"] .checkbox-dropdown-toggle,
html[data-theme="dark"] .checkbox-dropdown-search {
    background: #0f172a !important;
    border-color: var(--border-color) !important;
    color: var(--text-color) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] .empresa-placeholder {
    color: #94a3b8 !important;
}

html[data-theme="dark"] table,
html[data-theme="dark"] .data-table,
html[data-theme="dark"] .alertas-table,
html[data-theme="dark"] .executivo-resumo-analitico-tabela {
    background: var(--surface-bg-soft) !important;
    color: var(--text-color) !important;
}

html[data-theme="dark"] th,
html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .alertas-table th,
html[data-theme="dark"] .executivo-resumo-analitico-tabela th {
    background: #0f172a !important;
    border-color: var(--border-color) !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] td,
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .alertas-table td,
html[data-theme="dark"] .executivo-resumo-analitico-tabela td {
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .tab-button {
    background: #111827 !important;
    color: #cbd5e1 !important;
    border: 1px solid var(--border-color) !important;
}

html[data-theme="dark"] .tab-button:hover {
    background: #1f2937 !important;
}

html[data-theme="dark"] .tab-button.active {
    background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
    border-color: #60a5fa !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .executivo-kpi-mini,
html[data-theme="dark"] .executivo-kpi-grupo,
html[data-theme="dark"] .executivo-resumo-item,
html[data-theme="dark"] .alertas-ultima-atualizacao,
html[data-theme="dark"] .selected-count-badge {
    background: #0f172a !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .alertas-indicadores-link {
    background: #0f172a !important;
    border-color: var(--border-color) !important;
    color: #bfdbfe !important;
}

html[data-theme="dark"] .login-btn,
html[data-theme="dark"] .licenca-btn {
    background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .theme-toggle {
    align-items: center;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    font-weight: 600;
    gap: 0.75rem;
    justify-content: center;
    padding: 0.75rem;
    transition: all 0.2s ease;
    width: 100%;
}

html[data-theme="dark"] .theme-toggle:hover {
    background: rgba(96, 165, 250, 0.14) !important;
}

.theme-toggle {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border-color, #d5d8dc);
    border-radius: 10px;
    color: var(--secondary-color, #2a2e33);
    cursor: pointer;
    display: flex;
    font-weight: 600;
    gap: 0.75rem;
    justify-content: center;
    padding: 0.75rem;
    transition: all 0.2s ease;
    width: 100%;
}

.theme-toggle:hover {
    background: rgba(31, 78, 121, 0.08);
}

.sidebar.collapsed .theme-toggle span {
    display: none !important;
}

.sidebar.collapsed .theme-toggle {
    height: 40px !important;
    margin: 0 auto !important;
    padding: 10px !important;
    width: 40px !important;
}
