/**
 * Modo claro (data-theme="light") — contraste e legibilidade em todas as telas.
 * Modo escuro: tokens padrão em style.css (:root).
 */

/* Clique sempre no botão, não em camadas de SVG */
.theme-toggle-btn svg,
#theme-toggle-btn svg {
    pointer-events: none;
}

/*
 * Um ícone por vez (sol = próximo claro no escuro; lua = próximo escuro no claro).
 */
#theme-toggle-btn .theme-icon-sun,
#theme-toggle-btn .theme-icon-moon,
#theme-toggle-btn [data-theme-toggle-icon="light"],
#theme-toggle-btn [data-theme-toggle-icon="dark"],
#theme-toggle-btn > svg:nth-of-type(1),
#theme-toggle-btn > svg:nth-of-type(2) {
    display: none !important;
}

html[data-theme="dark"] #theme-toggle-btn .theme-icon-sun,
html[data-theme="dark"] #theme-toggle-btn [data-theme-toggle-icon="light"],
html[data-theme="dark"] #theme-toggle-btn > svg:nth-of-type(1) {
    display: inline-block !important;
    vertical-align: middle;
}

html[data-theme="light"] #theme-toggle-btn .theme-icon-moon,
html[data-theme="light"] #theme-toggle-btn [data-theme-toggle-icon="dark"],
html[data-theme="light"] #theme-toggle-btn > svg:nth-of-type(2) {
    display: inline-block !important;
    vertical-align: middle;
}

html:not([data-theme]) #theme-toggle-btn .theme-icon-sun,
html:not([data-theme]) #theme-toggle-btn [data-theme-toggle-icon="light"],
html:not([data-theme]) #theme-toggle-btn > svg:nth-of-type(1) {
    display: inline-block !important;
    vertical-align: middle;
}

/* ========== Tokens modo claro (alto contraste) ========== */
html[data-theme="light"] {
    color-scheme: light;
    --dark-base: #e8eef5;
    --dark-elevated: #ffffff;
    --dark-card: #ffffff;
    --dark-border: rgba(15, 23, 42, 0.18);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #475569;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

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

/* Header */
html[data-theme="light"] header.fixed.bg-dark-base\/80,
html[data-theme="light"] header.fixed[class*="bg-dark-base"],
html[data-theme="light"] header.fixed {
    background: rgba(232, 238, 245, 0.96) !important;
    border-bottom: 1px solid var(--dark-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Sidebar — cinza-ardósia suave para destacar do conteúdo (cards brancos) */
html[data-theme="light"] .sidebar-glass,
html[data-theme="light"] #sidebar,
html[data-theme="light"] #admin-sidebar {
    background: #e2e8f0 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-right: 1px solid rgba(15, 23, 42, 0.16) !important;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08), inset 0 0 0 1px rgba(15, 23, 42, 0.02) !important;
}

html[data-theme="light"] .sidebar-item-inactive {
    color: #334155 !important;
}

html[data-theme="light"] .sidebar-item-inactive:hover {
    background: rgba(15, 23, 42, 0.08) !important;
    color: #0f172a !important;
}

html[data-theme="light"] .sidebar-item-inactive i {
    color: #475569 !important;
}

html[data-theme="light"] .sidebar-item-inactive:hover i {
    color: #0f172a !important;
}

/* Item ativo — fundo menta suave + verde da marca (herdado de load_settings) */
html[data-theme="light"] .sidebar-item-active {
    background: #dcfce7 !important;
    box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.25) !important;
}

html[data-theme="light"] .sidebar-user-info:hover,
html[data-theme="light"] .sidebar-control-btn:hover {
    background: rgba(15, 23, 42, 0.08) !important;
    color: var(--text-primary) !important;
}

/* Cards / superfícies — borda e sombra mais definidas */
html[data-theme="light"] .bg-dark-card,
html[data-theme="light"] .bg-dark-elevated {
    border-color: var(--dark-border) !important;
}

html[data-theme="light"] .bg-dark-card {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .border-dark-border,
html[data-theme="light"] [class*="border-dark-border"] {
    border-color: var(--dark-border) !important;
}

/* Tabs */
html[data-theme="light"] .config-tabs {
    border-bottom-color: var(--dark-border) !important;
}

html[data-theme="light"] .config-tab {
    color: var(--text-secondary) !important;
}

html[data-theme="light"] .config-tab:hover {
    color: var(--text-primary) !important;
    background: rgba(15, 23, 42, 0.05) !important;
}

/* ========== Tipografia Tailwind (legibilidade) ========== */
html[data-theme="light"] .text-white:not(.theme-on-accent):not(.theme-preserve-white) {
    color: #0f172a !important;
}

html[data-theme="light"] .text-gray-100,
html[data-theme="light"] .text-gray-200 {
    color: #1e293b !important;
}

html[data-theme="light"] .text-gray-300 {
    color: #334155 !important;
}

html[data-theme="light"] .text-gray-400 {
    color: #475569 !important;
}

html[data-theme="light"] .text-gray-500 {
    color: #64748b !important;
}

html[data-theme="light"] .text-slate-300,
html[data-theme="light"] .text-slate-400 {
    color: #475569 !important;
}

html[data-theme="light"] .text-slate-500 {
    color: #64748b !important;
}

/* Âmbar / amarelo — no escuro são claros; no claro precisam ser escuros */
html[data-theme="light"] .text-amber-100,
html[data-theme="light"] .text-amber-200,
html[data-theme="light"] .text-amber-200\/80,
html[data-theme="light"] .text-amber-300,
html[data-theme="light"] .text-amber-400,
html[data-theme="light"] .text-amber-400\/90,
html[data-theme="light"] .text-yellow-200,
html[data-theme="light"] .text-yellow-300,
html[data-theme="light"] .text-yellow-400 {
    color: #b45309 !important; /* amber-700 */
}

html[data-theme="light"] .text-orange-300,
html[data-theme="light"] .text-orange-400 {
    color: #c2410c !important;
}

/* Verde status — mais escuro no claro */
html[data-theme="light"] .text-green-300,
html[data-theme="light"] .text-green-400,
html[data-theme="light"] .text-emerald-300,
html[data-theme="light"] .text-emerald-400 {
    color: #15803d !important; /* green-700 */
}

html[data-theme="light"] .text-green-500 {
    color: #166534 !important;
}

/* Azul / ciano */
html[data-theme="light"] .text-blue-300,
html[data-theme="light"] .text-blue-400,
html[data-theme="light"] .text-sky-300,
html[data-theme="light"] .text-sky-400,
html[data-theme="light"] .text-cyan-300,
html[data-theme="light"] .text-cyan-400 {
    color: #1d4ed8 !important;
}

/* Roxo */
html[data-theme="light"] .text-purple-300,
html[data-theme="light"] .text-purple-400,
html[data-theme="light"] .text-violet-300,
html[data-theme="light"] .text-violet-400 {
    color: #6d28d9 !important;
}

/* Erro já parcialmente tratado — reforço */
html[data-theme="light"] .text-red-300,
html[data-theme="light"] .text-red-400 {
    color: #b91c1c !important;
}

html[data-theme="light"] .text-red-500 {
    color: #dc2626 !important;
}

html[data-theme="light"] .border-red-500 {
    border-color: #ef4444 !important;
}

/* Botões/links com fundo de destaque — manter texto claro */
html[data-theme="light"] button[style*="--accent-primary"].text-white,
html[data-theme="light"] a[style*="--accent-primary"].text-white,
html[data-theme="light"] .theme-on-accent,
html[data-theme="light"] .bg-primary.text-white,
html[data-theme="light"] button.bg-primary,
html[data-theme="light"] a.bg-primary {
    color: #ffffff !important;
}

/* Badges âmbar escuros no dark → fundo claro + texto escuro */
html[data-theme="light"] .bg-amber-900\/30,
html[data-theme="light"] .bg-amber-900\/40,
html[data-theme="light"] .bg-amber-800\/50,
html[data-theme="light"] .bg-amber-500\/15,
html[data-theme="light"] .bg-amber-500\/20 {
    background-color: #fef3c7 !important;
}

html[data-theme="light"] .border-amber-500\/25,
html[data-theme="light"] .border-amber-500\/30,
html[data-theme="light"] .border-amber-600\/40,
html[data-theme="light"] .border-amber-600\/50 {
    border-color: #f59e0b !important;
}

html[data-theme="light"] .bg-green-900\/20,
html[data-theme="light"] .bg-green-900\/30,
html[data-theme="light"] .bg-green-900\/40 {
    background-color: #dcfce7 !important;
}

html[data-theme="light"] .bg-red-900\/20,
html[data-theme="light"] .bg-red-900\/30,
html[data-theme="light"] .bg-red-900\/40 {
    background-color: #fee2e2 !important;
}

html[data-theme="light"] .bg-slate-700\/50,
html[data-theme="light"] .bg-gray-500\/20 {
    background-color: #e2e8f0 !important;
}

/* Inputs e formulários */
html[data-theme="light"] .form-input,
html[data-theme="light"] .form-input-style,
html[data-theme="light"] input[type="text"],
html[data-theme="light"] input[type="email"],
html[data-theme="light"] input[type="password"],
html[data-theme="light"] input[type="number"],
html[data-theme="light"] input[type="url"],
html[data-theme="light"] input[type="search"],
html[data-theme="light"] input[type="tel"],
html[data-theme="light"] input[type="date"],
html[data-theme="light"] input[type="time"],
html[data-theme="light"] select:not([class*="border-0"]),
html[data-theme="light"] textarea {
    background-color: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.22) !important;
    color: #0f172a !important;
}

html[data-theme="light"] .form-input::placeholder,
html[data-theme="light"] .form-input-style::placeholder,
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
    color: #64748b !important;
    opacity: 1 !important;
}

html[data-theme="light"] option {
    background-color: #ffffff;
    color: #0f172a;
}

/* Tabelas */
html[data-theme="light"] .divide-dark-border > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--dark-border) !important;
}

html[data-theme="light"] thead.bg-dark-elevated,
html[data-theme="light"] thead {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
}

html[data-theme="light"] tbody.bg-dark-card {
    background-color: var(--dark-card) !important;
}

html[data-theme="light"] th {
    color: #334155 !important;
}

html[data-theme="light"] td {
    color: #1e293b !important;
}

/* Hover */
html[data-theme="light"] .hover\:bg-dark-elevated:hover,
html[data-theme="light"] .hover\:bg-dark-card:hover {
    background-color: #e2e8f0 !important;
}

html[data-theme="light"] .notification-bell-container:hover {
    background-color: #e2e8f0 !important;
}

/* Scrollbar */
html[data-theme="light"] .theme-scrollbar,
html[data-theme="light"] #sidebar,
html[data-theme="light"] #admin-sidebar {
    scrollbar-color: rgba(34, 197, 94, 0.5) rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .theme-scrollbar::-webkit-scrollbar-track,
html[data-theme="light"] #sidebar::-webkit-scrollbar-track,
html[data-theme="light"] #admin-sidebar::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.06);
}

html[data-theme="light"] #sidebar-overlay,
html[data-theme="light"] #admin-sidebar-overlay {
    background-color: rgba(15, 23, 42, 0.4) !important;
}

/* Modais / dropdowns */
html[data-theme="light"] .bg-dark-card.shadow-xl,
html[data-theme="light"] .modal-content {
    box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08) !important;
    background-color: #ffffff !important;
    color: #0f172a !important;
}

html[data-theme="light"] .modal-overlay {
    background-color: rgba(15, 23, 42, 0.45) !important;
}

/* Ícones Lucide em textos muted */
html[data-theme="light"] .text-gray-400 svg,
html[data-theme="light"] .text-gray-500 svg,
html[data-theme="light"] i[data-lucide].text-gray-400,
html[data-theme="light"] i[data-lucide].text-gray-500 {
    color: #475569 !important;
    stroke: #475569 !important;
}

/* Placeholders vazios / empty states */
html[data-theme="light"] .text-center.text-gray-500,
html[data-theme="light"] p.text-gray-500 {
    color: #64748b !important;
}

/* Progress bars / barras claras no ranking */
html[data-theme="light"] .bg-blue-500\/20,
html[data-theme="light"] .bg-sky-500\/20 {
    background-color: #dbeafe !important;
}

/* Código inline */
html[data-theme="light"] code {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
}
