/* =====================================================================
   Inovasoft CRM - Tema escuro
   Sobrescreve as variaveis do :root quando <html data-theme="dark">.
   Carregado depois do style.css para ter prioridade.
   ===================================================================== */
html[data-theme="dark"] {
    --surface: #14151c;
    --surface-card: #1d1f29;
    --surface-muted: #262835;
    --surface-container: #262835;
    --muted-soft: #9aa0b5;
    --text: #e8e9f0;
    --muted: #9a9bac;
    --line: #323444;
}

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

/* Cartoes, paineis e tabelas */
html[data-theme="dark"] .panel,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .chat-panel,
html[data-theme="dark"] .chat-list,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] table {
    background: var(--surface-card);
    color: var(--text);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .chat-list,
html[data-theme="dark"] .chat-panel {
    border-color: var(--line);
}

html[data-theme="dark"] thead th {
    background: var(--surface-muted);
    color: var(--muted);
}

html[data-theme="dark"] td,
html[data-theme="dark"] th {
    border-color: var(--line);
}

html[data-theme="dark"] tbody tr:hover {
    background: var(--surface-muted);
}

/* Campos de formulario */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--line);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--muted);
}

/* Botoes claros no tema escuro */
html[data-theme="dark"] .btn-light {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--line);
}

/* Chat */
html[data-theme="dark"] .chat-messages {
    background: #0f1016;
}
html[data-theme="dark"] .chat-bubble.in {
    background: var(--surface-muted);
    border-color: var(--line);
    color: var(--text);
}
html[data-theme="dark"] .chat-bubble.out {
    background: #1f5c3a;
    color: #eafff0;
}
html[data-theme="dark"] .chat-list-item.is-active {
    background: #232a44;
}

/* Payload / pre */
html[data-theme="dark"] .payload-box {
    background: #0f1016;
    color: #cfd2e0;
}

/* Badges mantem cor propria; apenas suaviza os neutros */
html[data-theme="dark"] .badge-yellow {
    filter: brightness(.92);
}

/* Topbar do tema (botao) */
.theme-toggle {
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease;
}
.theme-toggle:hover { background: rgba(255,255,255,.22); }

/* Precision - ajustes do modo escuro */
html[data-theme="dark"] table tbody tr:hover { background: var(--surface-muted); }
html[data-theme="dark"] .badge-green { background: rgba(34,197,94,.18); color: #6ee7a0; }
html[data-theme="dark"] .badge-blue { background: rgba(33,112,228,.20); color: #93c5fd; }
html[data-theme="dark"] .badge-yellow { background: rgba(214,138,0,.20); color: #fcd34d; }
html[data-theme="dark"] .badge-red { background: rgba(186,26,26,.22); color: #fca5a5; }
html[data-theme="dark"] .badge-gray { background: rgba(148,163,184,.18); color: #cbd5e1; }
html[data-theme="dark"] input:focus, html[data-theme="dark"] select:focus, html[data-theme="dark"] textarea:focus {
    box-shadow: 0 0 0 3px rgba(33,112,228,.25);
}

/* Sidebar no modo escuro (sobrepoe o branco do Precision) */
html[data-theme="dark"] .sidebar {
    background: #1a1c25;
    border-right-color: #2a2d3a;
    color: #e8e9f0;
}
html[data-theme="dark"] .nav-link { color: #aab0c2; }
html[data-theme="dark"] .nav-link .material-symbols-outlined { color: #aab0c2; }
html[data-theme="dark"] .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
html[data-theme="dark"] .nav-link.active { background: var(--secondary); color: #fff; }
html[data-theme="dark"] .nav-link.active .material-symbols-outlined { color: #fff; }
html[data-theme="dark"] .brand strong { color: #cfe0ff; }

/* Precision - lista de clientes no modo escuro */
html[data-theme="dark"] .avatar-initials { background: rgba(33,112,228,.18); color: #93c5fd; }
html[data-theme="dark"] .row-more-menu { background: #1d1f29; border-color: #323444; }
html[data-theme="dark"] .row-more-menu a, html[data-theme="dark"] .row-more-danger { color: #e8e9f0; }
html[data-theme="dark"] .row-more-menu a:hover { background: #262835; }

/* Precision - OS no modo escuro */
html[data-theme="dark"] .metric-card-danger { background: rgba(186,26,26,.12); }
