/* ============================================================================
 * CRM INFOCO — Sistema Global de Tema Claro / Escuro (Executive Polish)
 * Aplica-se a financeiro_dashboard.php, clientes.php, contratos.php e config_automacao_faturamento.php
 * ============================================================================ */

/* Botão elegante de troca de tema */
.crm-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.96));
    color: #f8fafc;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
    white-space: nowrap;
}
.crm-theme-toggle:hover {
    transform: translateY(-1px);
    border-color: #38bdf8;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
}
.crm-theme-toggle .crm-theme-icon {
    font-size: 14px;
    line-height: 1;
}

/* Polimento sutil no Modo Escuro */
html:not([data-theme="light"]) body {
    background-image:
        radial-gradient(950px 420px at 10% -8%, rgba(99, 102, 241, 0.13), transparent 60%),
        radial-gradient(850px 380px at 92% -4%, rgba(14, 165, 233, 0.10), transparent 55%);
    background-attachment: fixed;
}

/* ============================================================================
 * MODO CLARO (Executive Clean Light Theme — Alto Contraste & Sofisticação)
 * ============================================================================ */
html[data-theme="light"] {
    color-scheme: light;
    /* Variáveis do contratos.php */
    --bg: #f1f5f9 !important;
    --panel: #ffffff !important;
    --card: #ffffff !important;
    --card-2: #f8fafc !important;
    --border: #e2e8f0 !important;
    --text: #0f172a !important;
    --muted: #475569 !important;
    --accent: #4f46e5 !important;
    --accent-h: #4338ca !important;
    --good: #059669 !important;
    --warn: #d97706 !important;
    --bad: #dc2626 !important;
}

html[data-theme="light"] body {
    background-color: #f1f5f9 !important;
    background-image:
        radial-gradient(900px 420px at 12% -5%, rgba(99, 102, 241, 0.08), transparent 60%),
        radial-gradient(800px 380px at 90% 0%, rgba(14, 165, 233, 0.07), transparent 55%) !important;
    background-attachment: fixed !important;
    color: #0f172a !important;
}

html[data-theme="light"] .crm-theme-toggle {
    background: linear-gradient(135deg, #ffffff, #f8fafc) !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08) !important;
}
html[data-theme="light"] .crm-theme-toggle:hover {
    border-color: #6366f1 !important;
    background: #eef2ff !important;
    color: #3730a3 !important;
}

/* --- SCROLLBARS CLAROS --- */
html[data-theme="light"] ::-webkit-scrollbar-track,
html[data-theme="light"] .custom-scroll::-webkit-scrollbar-track {
    background: #e2e8f0 !important;
}
html[data-theme="light"] ::-webkit-scrollbar-thumb,
html[data-theme="light"] .custom-scroll::-webkit-scrollbar-thumb {
    background: #94a3b8 !important;
}
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #64748b !important;
}

/* --- SIDEBAR (clientes.php e páginas internas) --- */
html[data-theme="light"] .sidebar,
html[data-theme="light"] aside.sidebar {
    background-color: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
    box-shadow: 2px 0 12px rgba(15, 23, 42, 0.04) !important;
}
html[data-theme="light"] .sidebar-menu li a {
    color: #334155 !important;
}
html[data-theme="light"] .sidebar-menu li a:hover,
html[data-theme="light"] .sidebar-menu li a.active {
    background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28) !important;
}

/* --- SUPERFÍCIES, CARDS E PAINÉIS --- */
html[data-theme="light"] .card-glass,
html[data-theme="light"] .card-elevated,
html[data-theme="light"] .glass,
html[data-theme="light"] .topbar,
html[data-theme="light"] .card,
html[data-theme="light"] .kpi {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05) !important;
}
html[data-theme="light"] .card-clickable:hover {
    border-color: #94a3b8 !important;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.09) !important;
}
html[data-theme="light"] .card-header-accent,
html[data-theme="light"] .card-h {
    background: #f8fafc !important;
    border-bottom-color: #e2e8f0 !important;
}
html[data-theme="light"] .card-h h2 {
    color: #0f172a !important;
}

/* Header sticky (clientes.php) */
html[data-theme="light"] header.sticky,
html[data-theme="light"] header[class*="bg-[#0d1424]"] {
    background: rgba(255, 255, 255, 0.94) !important;
    border-bottom-color: #e2e8f0 !important;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04) !important;
}

/* Fundos Tailwind escuros -> claros */
html[data-theme="light"] .bg-slate-950,
html[data-theme="light"] .bg-slate-950\/90,
html[data-theme="light"] .bg-slate-950\/70,
html[data-theme="light"] .bg-slate-950\/50 {
    background-color: #f8fafc !important;
}
html[data-theme="light"] .bg-slate-900,
html[data-theme="light"] .bg-slate-900\/90,
html[data-theme="light"] .bg-slate-900\/80,
html[data-theme="light"] .bg-slate-900\/60,
html[data-theme="light"] .bg-slate-900\/50,
html[data-theme="light"] .bg-slate-850 {
    background-color: #ffffff !important;
}
html[data-theme="light"] .bg-slate-800,
html[data-theme="light"] .bg-slate-800\/50,
html[data-theme="light"] .bg-slate-800\/40 {
    background-color: #f1f5f9 !important;
}
html[data-theme="light"] tr:hover,
html[data-theme="light"] .hover\:bg-slate-800\/50:hover,
html[data-theme="light"] .hover\:bg-slate-850\/60:hover,
html[data-theme="light"] .hover\:bg-slate-900\/50:hover {
    background-color: #f1f5f9 !important;
}

/* Bordas e divisores claros */
html[data-theme="light"] .border-slate-800,
html[data-theme="light"] .border-slate-700,
html[data-theme="light"] .border-slate-700\/60,
html[data-theme="light"] .border-slate-600,
html[data-theme="light"] .border-white\/5,
html[data-theme="light"] .border-white\/10 {
    border-color: #cbd5e1 !important;
}
html[data-theme="light"] .divide-slate-800\/60 > :not([hidden]) ~ :not([hidden]),
html[data-theme="light"] .divide-slate-800\/70 > :not([hidden]) ~ :not([hidden]),
html[data-theme="light"] .divide-slate-800\/40 > :not([hidden]) ~ :not([hidden]),
html[data-theme="light"] .divide-slate-800 > :not([hidden]) ~ :not([hidden]) {
    border-color: #e2e8f0 !important;
}

/* --- TIPOGRAFIA (Alto Contraste no Claro) --- */
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] .text-white,
html[data-theme="light"] .text-slate-100,
html[data-theme="light"] .text-slate-200 {
    color: #0f172a !important;
}
html[data-theme="light"] .text-slate-300 {
    color: #334155 !important;
}
html[data-theme="light"] .text-slate-400 {
    color: #475569 !important;
}
html[data-theme="light"] .text-slate-500 {
    color: #64748b !important;
}

/* Valores, KPIs e destaques em cores vibrantes mas legíveis no branco */
html[data-theme="light"] .text-emerald-400,
html[data-theme="light"] .text-emerald-300 {
    color: #047857 !important;
}
html[data-theme="light"] .text-amber-400,
html[data-theme="light"] .text-amber-300 {
    color: #b45309 !important;
}
html[data-theme="light"] .text-rose-400,
html[data-theme="light"] .text-rose-300,
html[data-theme="light"] .text-red-400,
html[data-theme="light"] .text-red-300 {
    color: #be123c !important;
}
html[data-theme="light"] .text-sky-400,
html[data-theme="light"] .text-sky-300,
html[data-theme="light"] .text-cyan-400 {
    color: #0369a1 !important;
}
html[data-theme="light"] .text-indigo-400,
html[data-theme="light"] .text-indigo-300,
html[data-theme="light"] .text-blue-400 {
    color: #4338ca !important;
}
html[data-theme="light"] .text-purple-400,
html[data-theme="light"] .text-purple-300 {
    color: #7e22ce !important;
}

/* --- PROTEÇÃO DE BOTÕES SÓLIDOS COLORIDOS (SEMPRE TEXTO BRANCO!) --- */
html[data-theme="light"] a.bg-indigo-600,
html[data-theme="light"] button.bg-indigo-600,
html[data-theme="light"] button[class*="bg-indigo-600/"],
html[data-theme="light"] a.bg-blue-600,
html[data-theme="light"] button.bg-blue-600,
html[data-theme="light"] a.bg-sky-600,
html[data-theme="light"] button.bg-sky-600,
html[data-theme="light"] a.bg-emerald-600,
html[data-theme="light"] button.bg-emerald-600,
html[data-theme="light"] a.bg-emerald-500,
html[data-theme="light"] button.bg-emerald-500,
html[data-theme="light"] a.bg-teal-600,
html[data-theme="light"] button.bg-teal-600,
html[data-theme="light"] a.bg-amber-600,
html[data-theme="light"] button.bg-amber-600,
html[data-theme="light"] a.bg-rose-600,
html[data-theme="light"] button.bg-rose-600,
html[data-theme="light"] a.bg-red-600,
html[data-theme="light"] button.bg-red-600,
html[data-theme="light"] a.bg-purple-600,
html[data-theme="light"] button.bg-purple-600,
html[data-theme="light"] a.bg-slate-700,
html[data-theme="light"] button.bg-slate-700,
html[data-theme="light"] button[class*="from-sky-600"],
html[data-theme="light"] a.btn-primary,
html[data-theme="light"] button.btn-primary,
html[data-theme="light"] a.btn-green,
html[data-theme="light"] button.btn-green,
html[data-theme="light"] .bg-emerald-500.text-white,
html[data-theme="light"] .bg-rose-600.text-white {
    color: #ffffff !important;
}
html[data-theme="light"] a.bg-indigo-600 *,
html[data-theme="light"] button.bg-indigo-600 *,
html[data-theme="light"] button[class*="bg-indigo-600/"] *,
html[data-theme="light"] a.bg-blue-600 *,
html[data-theme="light"] button.bg-blue-600 *,
html[data-theme="light"] a.bg-sky-600 *,
html[data-theme="light"] button.bg-sky-600 *,
html[data-theme="light"] a.bg-emerald-600 *,
html[data-theme="light"] button.bg-emerald-600 *,
html[data-theme="light"] a.bg-emerald-500 *,
html[data-theme="light"] button.bg-emerald-500 *,
html[data-theme="light"] a.bg-teal-600 *,
html[data-theme="light"] button.bg-teal-600 *,
html[data-theme="light"] a.bg-amber-600 *,
html[data-theme="light"] button.bg-amber-600 *,
html[data-theme="light"] a.bg-rose-600 *,
html[data-theme="light"] button.bg-rose-600 *,
html[data-theme="light"] a.bg-red-600 *,
html[data-theme="light"] button.bg-red-600 *,
html[data-theme="light"] a.bg-purple-600 *,
html[data-theme="light"] button.bg-purple-600 *,
html[data-theme="light"] a.bg-slate-700 *,
html[data-theme="light"] button.bg-slate-700 *,
html[data-theme="light"] button[class*="from-sky-600"] *,
html[data-theme="light"] a.btn-primary *,
html[data-theme="light"] button.btn-primary *,
html[data-theme="light"] a.btn-green *,
html[data-theme="light"] button.btn-green * {
    color: #ffffff !important;
}

/* Botões translúcidos no topo (Voltar Dashboard, Sair, Contratos, Financeiro, Lembretes) */
html[data-theme="light"] a[class*="bg-slate-800"],
html[data-theme="light"] button[class*="bg-slate-800"],
html[data-theme="light"] button[class*="bg-slate-900"] {
    background-color: #ffffff !important;
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}
html[data-theme="light"] a[class*="bg-slate-800"]:hover,
html[data-theme="light"] button[class*="bg-slate-800"]:hover,
html[data-theme="light"] button[class*="bg-slate-900"]:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}
html[data-theme="light"] a[class*="bg-red-950"] {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
    border-color: #fecaca !important;
}
html[data-theme="light"] a[class*="bg-red-950"]:hover {
    background-color: #fee2e2 !important;
}
html[data-theme="light"] a[class*="bg-indigo-600/30"] {
    background-color: #eef2ff !important;
    color: #3730a3 !important;
    border-color: #c7d2fe !important;
}
html[data-theme="light"] a[class*="bg-emerald-600/30"] {
    background-color: #ecfdf5 !important;
    color: #065f46 !important;
    border-color: #a7f3d0 !important;
}
html[data-theme="light"] button[class*="bg-purple-600/30"] {
    background-color: #faf5ff !important;
    color: #6b21a8 !important;
    border-color: #e9d5ff !important;
}

/* --- INPUTS, SELECTS E TEXTAREAS NO MODO CLARO --- */
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="date"],
html[data-theme="light"] input[type="time"],
html[data-theme="light"] input[type="number"],
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="light"] .input-contrast,
html[data-theme="light"] .inp {
    background-color: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    color: #0f172a !important;
}
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder,
html[data-theme="light"] .input-contrast::placeholder {
    color: #64748b !important;
}
html[data-theme="light"] select option,
html[data-theme="light"] select.input-contrast option {
    background-color: #ffffff !important;
    color: #0f172a !important;
}
/* Select transparente no seletor de mês do financeiro */
html[data-theme="light"] select.bg-transparent {
    background-color: transparent !important;
    border: none !important;
    color: #0f172a !important;
}

/* --- TABELAS & CABEÇALHOS --- */
html[data-theme="light"] thead,
html[data-theme="light"] thead.bg-slate-950,
html[data-theme="light"] th {
    background-color: #f8fafc !important;
    color: #334155 !important;
    border-bottom-color: #e2e8f0 !important;
}
html[data-theme="light"] td {
    border-bottom-color: #e2e8f0 !important;
}

/* --- CONTRATOS.PHP ESPECÍFICOS --- */
html[data-theme="light"] .tab {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}
html[data-theme="light"] .tab:hover {
    background: #f8fafc !important;
    color: #0f172a !important;
}
html[data-theme="light"] .tab.active {
    background: #eef2ff !important;
    border-color: #6366f1 !important;
    color: #3730a3 !important;
}
html[data-theme="light"] .btn:not(.btn-primary):not(.btn-green) {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #1e293b !important;
}
html[data-theme="light"] .btn:not(.btn-primary):not(.btn-green):hover {
    background: #f1f5f9 !important;
}
html[data-theme="light"] .btn-warn {
    background: #fffbeb !important;
    border-color: #fcd34d !important;
    color: #b45309 !important;
}
html[data-theme="light"] .btn-red {
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    color: #b91c1c !important;
}
html[data-theme="light"] .q-pill {
    background: #eef2ff !important;
    border-color: #c7d2fe !important;
    color: #3730a3 !important;
}
html[data-theme="light"] .check-line {
    color: #334155 !important;
}
html[data-theme="light"] .flash.success {
    background: #ecfdf5 !important;
    border-color: #6ee7b7 !important;
    color: #065f46 !important;
}
html[data-theme="light"] .flash.error {
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    color: #991b1b !important;
}

/* --- BADGES DE ALERTA & MODAIS NO CLARO --- */
html[data-theme="light"] .bg-amber-950\/30,
html[data-theme="light"] .bg-amber-950 {
    background-color: #fffbeb !important;
    border-color: #fcd34d !important;
}
html[data-theme="light"] .bg-emerald-950\/60,
html[data-theme="light"] .bg-emerald-950 {
    background-color: #ecfdf5 !important;
    border-color: #6ee7b7 !important;
}
html[data-theme="light"] .bg-red-950\/60,
html[data-theme="light"] .bg-red-950\/40,
html[data-theme="light"] .bg-red-950 {
    background-color: #fef2f2 !important;
    border-color: #fca5a5 !important;
}
html[data-theme="light"] .bg-purple-950\/80 {
    background-color: #faf5ff !important;
    border-color: #d8b4fe !important;
}
html[data-theme="light"] .bg-sky-900\/80 {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
}
html[data-theme="light"] code {
    background-color: #f1f5f9 !important;
    color: #0369a1 !important;
    padding: 1px 5px;
    border-radius: 4px;
}
