/* ── Kanban ── */
.kanban-board{display:flex;gap:1rem;overflow-x:auto;padding-bottom:1rem;min-height:500px}
.kanban-column{flex:0 0 280px;background:#2c162b;border:1px solid #51284F;border-radius:.75rem;padding:1rem;display:flex;flex-direction:column;gap:.75rem}
.kanban-card{background:#51284F;border:1px solid #71386e;border-radius:.5rem;padding:.75rem;cursor:grab;transition:all .15s}
.kanban-card:hover{border-color:#2c162b;transform:translateY(-1px);box-shadow:0 4px 12px rgba(44,22,43,.25)}
.kanban-card.dragging{opacity:.5;cursor:grabbing}
.kanban-column.drag-over{background:#3a1d39;border-color:#2c162b}

/* ── Chat layout ── */
.chat-container{display:flex;height:calc(100dvh - 4rem);min-height:400px;overflow:hidden}
.chat-sidebar{width:320px;flex-shrink:0;border-right:1px solid #51284F;overflow-y:auto;display:flex;flex-direction:column}
.chat-main{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0}
.chat-messages{flex:1;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;align-items:stretch;gap:.375rem}

/* ── Bolhas ── */
.message-bubble{max-width:72%;padding:.5rem .875rem;border-radius:1rem;font-size:.875rem;line-height:1.45;word-break:break-word;position:relative}
.message-bubble.outbound{background:#2c162b;color:white;align-self:flex-end;border-bottom-right-radius:.25rem;margin-left:auto}
.message-bubble.inbound{background:#51284F;color:#e5e7eb;align-self:flex-start;border-bottom-left-radius:.25rem;margin-right:auto}
.message-bubble .msg-time{font-size:10px;opacity:.55;margin-top:3px;text-align:right;display:flex;align-items:center;justify-content:flex-end;gap:3px}
.message-bubble.inbound .msg-time{justify-content:flex-start}
.date-separator{display:flex;align-items:center;gap:.75rem;margin:.75rem 0;color:#6b7280;font-size:.7rem;text-transform:uppercase;letter-spacing:.06em;user-select:none}
.date-separator::before,.date-separator::after{content:'';flex:1;height:1px;background:#51284F}
.date-separator span{white-space:nowrap;padding:0 .25rem}

/* Status ticks */
.tick{display:inline-block;font-size:11px;line-height:1}
.tick.sent{opacity:.6}
.tick.delivered{opacity:.8}
.tick.read{color:#60a5fa}

/* ── Respostas rapidas ── */
.quick-replies-popup{position:absolute;bottom:100%;left:0;right:0;background:#2c162b;border:1px solid #71386e;border-radius:.5rem .5rem 0 0;max-height:220px;overflow-y:auto;z-index:10}
.quick-reply-item{padding:.5rem .875rem;cursor:pointer;font-size:.8125rem;border-bottom:1px solid #51284F;display:flex;gap:.75rem;align-items:flex-start}
.quick-reply-item:hover{background:#51284F}
.quick-reply-item .shortcut{color:#2c162b;font-weight:600;flex-shrink:0;min-width:60px}
.quick-reply-item .preview{color:#9ca3af;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ── Notificacao toast ── */
#toast{position:fixed;top:1rem;right:1rem;z-index:9999;display:flex;flex-direction:column;gap:.5rem;pointer-events:none}
.toast-item{background:#51284F;border:1px solid #71386e;border-radius:.5rem;padding:.625rem 1rem;font-size:.8125rem;color:#f9fafb;pointer-events:auto;animation:slideIn .2s ease;max-width:280px}
.toast-item.error{border-color:#f87171;color:#f87171}
.toast-item.success{border-color:#34d399;color:#34d399}
@keyframes slideIn{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}

/* ── Mobile ── */
@media(max-width:768px){
  .chat-container{height:calc(100dvh - 3.5rem);position:relative}
  .chat-sidebar{position:absolute;inset:0;z-index:20;width:100%;transition:transform .2s}
  .chat-sidebar.slide-out{transform:translateX(-100%)}
  .chat-main{width:100%}
  .btn-back-sidebar{display:flex!important}
}
.btn-back-sidebar{display:none;align-items:center;gap:.5rem;background:transparent;border:none;color:#9ca3af;cursor:pointer;font-size:.875rem;padding:.25rem 0;margin-bottom:.5rem}

/* ── Componentes gerais ── */
.badge{display:inline-flex;align-items:center;padding:.125rem .625rem;border-radius:9999px;font-size:.75rem;font-weight:500}
.crm-table{width:100%;border-collapse:collapse}
.crm-table th{padding:.75rem 1rem;text-align:left;font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:#6b7280;border-bottom:1px solid #51284F}
.crm-table td{padding:.875rem 1rem;font-size:.875rem;color:#d1d5db;border-bottom:1px solid #2c162b}
.crm-table tr:hover td{background:#2c162b}
.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.7);z-index:50;display:flex;align-items:center;justify-content:center;padding:1rem}
.modal-box{background:#51284F;border:1px solid #71386e;border-radius:.75rem;padding:1.5rem;width:100%;max-width:520px;max-height:90vh;overflow-y:auto}
.form-input{width:100%;background:#2c162b;border:1px solid #71386e;color:#f9fafb;border-radius:.5rem;padding:.5rem .75rem;font-size:.875rem;transition:border-color .15s}
.form-input:focus{outline:none;border-color:#2c162b;box-shadow:0 0 0 3px rgba(44,22,43,.25)}
.form-label{display:block;font-size:.8125rem;font-weight:500;color:#9ca3af;margin-bottom:.375rem}
.btn-primary{display:inline-flex;align-items:center;gap:.5rem;background:#4f46e5 !important;color:#fff !important;border:none;padding:.5rem 1rem;border-radius:.5rem;font-size:.875rem;font-weight:600;cursor:pointer;transition:background .15s;text-decoration:none}
.btn-primary:hover{background:#4338ca !important;color:#fff !important}
.btn-secondary{display:inline-flex;align-items:center;gap:.5rem;background:#71386e;color:#d1d5db;border:1px solid #4b5563;padding:.5rem 1rem;border-radius:.5rem;font-size:.875rem;font-weight:500;cursor:pointer;transition:all .15s;text-decoration:none}
.btn-secondary:hover{background:#4b5563;color:white}
.btn-danger{display:inline-flex;align-items:center;gap:.5rem;background:transparent;color:#f87171;border:1px solid #f87171;padding:.4rem .875rem;border-radius:.5rem;font-size:.8125rem;cursor:pointer;transition:all .15s}
.btn-danger:hover{background:#f87171;color:white}
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:#2c162b}
::-webkit-scrollbar-thumb{background:#71386e;border-radius:3px}


.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.hidden {
    display: none !important;
}

.modal-box {
    width: 100%;
    max-width: 560px;
    background: #2c162b;
    border: 1px solid #71386e;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-close {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.modal-title {
    color: #fff;
    font-size: 20px;
    font-weight: 600;
}


.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    color: #d1d5db;
    font-size: 14px;
    margin-bottom: 8px;
}

.form-input,
textarea.form-input {
    width: 100%;
    background: #51284F;
    border: 1px solid #71386e;
    border-radius: 10px;
    padding: 12px;
    color: #fff;
    font-size: 14px;
    box-sizing: border-box;
}

textarea.form-input {
    min-height: 140px;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}


/* ── Tema Claro/Escuro ── */
:root {
  --bg-primary: #2c162b;
  --bg-secondary: #51284F;
  --bg-tertiary: #71386e;
  --bg-hover: #3a1d39;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --border-color: #71386e;
  --border-light: #51284F;
}

html.light-mode {
  --bg-primary: #ffffff;
  --bg-secondary: #f3f4f6;
  --bg-tertiary: #e5e7eb;
  --bg-hover: #f0f0f0;
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --border-color: #d1d5db;
  --border-light: #e5e7eb;
}

html.light-mode body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

html.light-mode aside {
  background-color: #f8fafc;
  border-right-color: var(--border-light);
}

/* ── Sidebar nav links – light mode ── */
html.light-mode aside nav a {
  color: #4b5563;
}

/* Item ATIVO: fundo roxo + texto branco (2026-08-29: era indigo, trocado
   pro roxo da marca — pedido do usuário: "ele ta ficando azul, deixa roxo") */
html.light-mode aside nav a.bg-gray-800 {
  background-color: #9d4f97 !important;
  color: #ffffff !important;
}
html.light-mode aside nav a.bg-gray-800 svg {
  color: #ffffff !important;
}
html.light-mode aside nav a.bg-gray-800 .sidebar-label {
  color: #ffffff !important;
}

/* Hover em items inativos */
html.light-mode aside nav a:not(.bg-gray-800):hover {
  background-color: #e8eaf0 !important;
  color: #111827 !important;
}

/* Labels de seção */
html.light-mode aside nav p {
  color: #9ca3af !important;
}

/* Rodapé do sidebar */
html.light-mode aside > div:last-child {
  background-color: #f1f5f9;
  border-top-color: var(--border-light);
}

html.light-mode header {
  background-color: var(--bg-secondary);
  border-bottom-color: var(--border-light);
}

html.light-mode .bg-gray-900 {
  background-color: var(--bg-secondary);
}

html.light-mode .bg-gray-950 {
  background-color: var(--bg-primary);
}

html.light-mode .border-gray-800 {
  border-color: var(--border-light);
}

html.light-mode .text-white {
  color: var(--text-primary);
}

html.light-mode .text-gray-300 {
  color: var(--text-secondary);
}

html.light-mode .text-gray-400 {
  color: var(--text-muted);
}

html.light-mode .text-gray-500 {
  color: #9ca3af;
}

html.light-mode .hover\:bg-gray-800:hover {
  background-color: var(--bg-hover);
}

html.light-mode .form-input {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

html.light-mode .form-input:focus {
  border-color: var(--border-color);
}

/* 2026-08-29: era indigo, trocado pro roxo da marca ("botões roxos"). O
   !important é obrigatório aqui — a regra base (.btn-primary, linha ~66)
   também usa !important, sem isso a de baixo nunca vencia (bug antigo,
   a versão indigo também nunca tinha funcionado de verdade). */
html.light-mode .btn-primary {
  background-color: #9d4f97 !important;
  color: white !important;
}

html.light-mode .btn-primary:hover {
  background-color: #7a2f74 !important;
}

html.light-mode .crm-table th {
  color: var(--text-muted);
  border-bottom-color: var(--border-light);
}

html.light-mode .crm-table td {
  color: var(--text-secondary);
  border-bottom-color: var(--border-light);
}

html.light-mode .crm-table tr:hover td {
  background-color: var(--bg-hover);
}

html.light-mode .modal-box {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
}

html.light-mode .divide-y.divide-gray-800 > * {
  border-bottom-color: var(--border-light);
}

html.light-mode .bg-gray-800\/30 {
  background-color: rgba(243, 244, 246, 0.3);
}

html.light-mode .bg-gray-800\/40 {
  background-color: rgba(243, 244, 246, 0.4);
}

html.light-mode .bg-gray-800\/5 {
  background-color: rgba(243, 244, 246, 0.05);
}

html.light-mode .bg-gray-800\/50 {
  background-color: rgba(243, 244, 246, 0.5);
}

/* bg-gray-800 genérico em cards/modais fora do nav (não sidebar ativa) */
html.light-mode .bg-gray-800:not(aside nav a) {
  background-color: #e5e7eb;
}
html.light-mode .bg-gray-800\/60,
html.light-mode .hover\:bg-gray-800\/60:hover {
  background-color: rgba(229, 231, 235, 0.6);
}

/* Texto escuro em fundo claro */
html.light-mode .text-gray-600 {
  color: #6b7280;
}
html.light-mode .bg-gray-950 {
  background-color: #f1f5f9;
}

/* Tabelas */
html.light-mode .crm-table th {
  background-color: #f1f5f9;
  color: #374151;
}
html.light-mode .crm-table tr:hover td {
  background-color: #f0f4f8;
}

/* Inputs e selects */
html.light-mode select.form-input {
  background-color: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}

/* Modal */
html.light-mode .modal-backdrop {
  background: rgba(0,0,0,0.4);
}
html.light-mode .modal-box {
  background-color: #ffffff;
  border-color: #e5e7eb;
}

/* Badges de status – garantir legibilidade */
html.light-mode .badge {
  font-weight: 600;
}

/* Código inline */
html.light-mode code {
  background-color: #e5e7eb;
  color: #1d4ed8;
}

/* Botão secundário */
html.light-mode .btn-secondary {
  background-color: #e5e7eb;
  color: #374151;
  border-color: #d1d5db;
}
html.light-mode .btn-secondary:hover {
  background-color: #d1d5db;
  color: #111827;
}

/* Header da página */
html.light-mode header h1 {
  color: #111827;
}

/* Logo roxa no claro / branca no escuro (a original é branca, some no claro) */
.logo-light { display: none; }
html.light-mode .logo-dark  { display: none; }
html.light-mode .logo-light { display: block; }

/* Scrollbar clara */
html.light-mode ::-webkit-scrollbar-track {
  background: #f1f5f9;
}
html.light-mode ::-webkit-scrollbar-thumb {
  background: #d1d5db;
}

/* ── ★ Badges de status (2026-08-29) — padrão usado em leads/pipeline/etc é
   bg-{cor}-500/10 (fundo translúcido, OK nos dois temas) + text-{cor}-300/400
   (texto claro, pensado só pro fundo escuro — no claro ficava ilegível, ex:
   "Frio/Morno/Quente" em leads). Escurece o texto de cada família de cor
   usada nos badges do sistema; os fundos translúcidos não precisam mudar. */
html.light-mode .text-slate-300   { color: #334155 !important; }
html.light-mode .text-blue-300,
html.light-mode .text-blue-400    { color: #1d4ed8 !important; }
html.light-mode .text-green-300,
html.light-mode .text-green-400   { color: #15803d !important; }
html.light-mode .text-emerald-100,
html.light-mode .text-emerald-200,
html.light-mode .text-emerald-300,
html.light-mode .text-emerald-400 { color: #047857 !important; }
html.light-mode .text-yellow-300,
html.light-mode .text-yellow-400  { color: #a16207 !important; }
html.light-mode .text-amber-300,
html.light-mode .text-amber-400   { color: #b45309 !important; }
html.light-mode .text-orange-300,
html.light-mode .text-orange-400  { color: #c2410c !important; }
html.light-mode .text-red-300,
html.light-mode .text-red-400     { color: #b91c1c !important; }
html.light-mode .text-rose-300,
html.light-mode .text-rose-400    { color: #be123c !important; }
html.light-mode .text-indigo-100,
html.light-mode .text-indigo-200,
html.light-mode .text-indigo-300,
html.light-mode .text-indigo-400  { color: #4338ca !important; }
html.light-mode .text-purple-300,
html.light-mode .text-purple-400  { color: #7e22ce !important; }
html.light-mode .text-violet-300,
html.light-mode .text-violet-400  { color: #6d28d9 !important; }
html.light-mode .text-teal-300,
html.light-mode .text-teal-400    { color: #0f766e !important; }
html.light-mode .text-pink-300,
html.light-mode .text-pink-400    { color: #be185d !important; }
html.light-mode .text-cyan-300,
html.light-mode .text-cyan-400    { color: #0e7490 !important; }
html.light-mode .text-sky-300,
html.light-mode .text-sky-400     { color: #0369a1 !important; }
html.light-mode .text-amber-200   { color: #b45309 !important; }

/* ── ★ Componentes base ainda sem tema claro (kanban, popup de respostas
   rápidas, toast, separador de data, bolha de chat legada) ── */
html.light-mode .kanban-column      { background: #faf7fa; border-color: #e6dde5; }
html.light-mode .kanban-card        { background: #ffffff; border-color: #e6dde5; color: #241a23; }
html.light-mode .kanban-card:hover  { border-color: #9d4f97; box-shadow: 0 4px 12px rgba(157,79,151,.15); }
html.light-mode .kanban-column.drag-over { background: #f2eaf1; border-color: #9d4f97; }

html.light-mode .chat-sidebar { border-right-color: #e6dde5; }
html.light-mode .message-bubble.outbound { background: #f6ecf5; color: #241a23; }
html.light-mode .message-bubble.inbound  { background: #f2eaf1; color: #241a23; }
html.light-mode .date-separator { color: #6b6470; }
html.light-mode .date-separator::before,
html.light-mode .date-separator::after { background: #e6dde5; }

html.light-mode .quick-replies-popup    { background: #ffffff; border-color: #e6dde5; }
html.light-mode .quick-reply-item       { border-bottom-color: #e6dde5; }
html.light-mode .quick-reply-item:hover { background: #f2eaf1; }
html.light-mode .quick-reply-item .shortcut { color: #9d4f97; }
html.light-mode .quick-reply-item .preview  { color: #6b6470; }

html.light-mode .toast-item { background: #ffffff; border-color: #e6dde5; color: #241a23; box-shadow: 0 4px 14px rgba(0,0,0,.10); }
html.light-mode .btn-back-sidebar { color: #6b6470; }

/* ── ★ Variantes de opacidade de bg-gray-700/800/950 sem tema claro (ex:
   cabeçalho de seção "bg-gray-950/50" virava uma faixa quase preta em cima
   de card já claro — "informações com fundo escuro" na ficha do lead). ── */
html.light-mode .bg-gray-950\/50            { background-color: rgba(243,244,246,.6) !important; }
html.light-mode .bg-gray-700\/30            { background-color: rgba(229,231,235,.5) !important; }
html.light-mode .bg-gray-700\/40            { background-color: rgba(229,231,235,.6) !important; }
html.light-mode .hover\:bg-gray-800\/30:hover { background-color: rgba(243,244,246,.7) !important; }
html.light-mode .hover\:bg-gray-800\/40:hover { background-color: rgba(243,244,246,.8) !important; }
html.light-mode .hover\:bg-gray-700\/60:hover,
html.light-mode .bg-gray-700\/60 { background-color: rgba(229,231,235,.7) !important; }

/* Tons -700/-200 usados soltos (divisor, badge de fallback, texto quase
   branco em text-gray-200) — mesma lacuna, nunca tinham par no tema claro. */
html.light-mode .bg-gray-700     { background-color: #e5e7eb !important; }
html.light-mode .border-gray-700 { border-color: #d9cdd7 !important; }
html.light-mode .text-gray-200   { color: #374151 !important; }

/* ── Theme Toggle Button ── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-toggle:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

/* ── Versão Light (Simplificada) ── */
html.light-version {
  --sidebar-width: 56px;
}

html.light-version aside {
  width: 56px;
  overflow: hidden;
}

html.light-version .md\:pl-64 {
  padding-left: 56px;
}

/* Esconde labels de seção e textos no nav */
html.light-version aside nav p {
  display: none;
}

/* Centraliza e ajusta links */
html.light-version aside nav a {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}

html.light-version aside nav a svg {
  flex-shrink: 0;
  margin: 0;
}

/* Esconde qualquer .sidebar-label em qualquer lugar do aside */
html.light-version aside .sidebar-label {
  display: none !important;
}

html.light-version .sidebar-expanded-only {
  display: none;
}

/* Logo área compacta */
html.light-version aside > div:first-child {
  padding: 12px 0;
}

html.light-version aside > div:first-child img {
  max-height: 28px;
  max-width: 36px;
}

/* Rodapé do sidebar compacto */
html.light-version aside > div:last-child .flex {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}

/* ── Legibilidade geral (pedido da clínica, 2026-07-29): fonte maior e
   cinzas mais claros. !important porque o tailwind.css estático carrega
   DEPOIS deste arquivo e venceria a especificidade normal.
   2026-08-29 FIX: essas 4 regras não eram escopadas ao tema escuro — no
   modo claro, título/legenda/label ficavam quase brancos (#c2c2cc/#a8a8b3)
   em cima de fundo branco, ilegíveis. Escopado só pro escuro + adicionado
   o par claro (mais escuro, !important pelo mesmo motivo). ── */
html { font-size: 17px; }
html:not(.light-mode) .text-gray-500 { color: #a8a8b3 !important; }
html:not(.light-mode) .text-gray-400 { color: #c2c2cc !important; }
html:not(.light-mode) .form-label { color: #b3b3bd; }
html:not(.light-mode) .crm-table th { color: #a8a8b3; }

html.light-mode .text-gray-500 { color: #6b7280 !important; }
html.light-mode .text-gray-400 { color: #4b5563 !important; }
html.light-mode .form-label { color: #374151 !important; }
html.light-mode .crm-table th { color: #374151 !important; }

/* ── ★ Gradientes escuros (2026-08-29c) — bg-gradient-to-* + from-X/to-X é
   um mecanismo do Tailwind diferente de background-color; os overrides de
   .bg-gray-900/950 não pegavam esse caso (card "Principal" da ficha do
   lead continuava escuro mesmo depois do resto corrigido). ── */
html.light-mode .bg-gradient-to-br.from-gray-900.to-gray-950 {
  background-image: linear-gradient(to bottom right, #faf7fa, #f2eaf1) !important;
}

html.light-version aside > div:last-child a {
  margin: 0 auto;
}