/*
 * Calma e aparência (Trilha C5 do Ciclo 2). Carregado em base.html e mobile/_base.html
 * por components/_calma_head.html, que põe no <html>:
 *   data-tema-ativo="escuro|claro"  (tema do Perfil; "do aparelho" segue prefers-color-scheme)
 *   data-calmo="1"                  (modo calmo ligado)
 *
 * Tema escuro por SOBREPOSIÇÃO: o Tailwind vem por CDN, sem build e sem classes dark:.
 * Cada regra aqui tem especificidade (0,2,1)+ e ganha das classes utilitárias (0,1,0).
 * Cobre as classes mais usadas nas telas do dia a dia; tela rara pode ficar imperfeita.
 */

/* ── Movimento reduzido: sempre que o sistema pedir, e sempre no modo calmo ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
html[data-calmo="1"] *, html[data-calmo="1"] *::before, html[data-calmo="1"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* ── Modo calmo ── */
/* Números de pendência escondidos (o dado continua no histórico) */
html[data-calmo="1"] .calmo-oculto { display: none !important; }
/* Nenhum fundo vermelho sólido (o texto de segurança continua em vermelho) */
html[data-calmo="1"] .bg-red-500, html[data-calmo="1"] .bg-red-600, html[data-calmo="1"] .bg-red-700,
html[data-calmo="1"] .bg-rose-500, html[data-calmo="1"] .bg-rose-600, html[data-calmo="1"] .bg-rose-700,
html[data-calmo="1"] .hover\:bg-red-700:hover, html[data-calmo="1"] .hover\:bg-red-600:hover {
  background-color: #475569 !important;
}

/* ── Tema escuro ── */
html[data-tema-ativo="escuro"] { color-scheme: dark; }
html[data-tema-ativo="escuro"] body { background-color: #0f172a; color: #e2e8f0; }

/* Superfícies */
html[data-tema-ativo="escuro"] .bg-white { background-color: #1e293b; }
html[data-tema-ativo="escuro"] .bg-white\/80, html[data-tema-ativo="escuro"] .bg-white\/90,
html[data-tema-ativo="escuro"] .bg-white\/95 { background-color: rgba(30, 41, 59, 0.9); }
html[data-tema-ativo="escuro"] .bg-slate-50\/50, html[data-tema-ativo="escuro"] .bg-gray-50\/60 { background-color: rgba(15, 23, 42, 0.5); }
html[data-tema-ativo="escuro"] .bg-amber-50\/50 { background-color: rgba(245, 158, 11, 0.1); }
html[data-tema-ativo="escuro"] .bg-emerald-50\/50 { background-color: rgba(16, 185, 129, 0.1); }
html[data-tema-ativo="escuro"] .bg-slate-50, html[data-tema-ativo="escuro"] .bg-gray-50 { background-color: #0f172a; }
html[data-tema-ativo="escuro"] .bg-slate-100, html[data-tema-ativo="escuro"] .bg-gray-100 { background-color: #273449; }
html[data-tema-ativo="escuro"] .bg-slate-200, html[data-tema-ativo="escuro"] .bg-gray-200 { background-color: #334155; }
html[data-tema-ativo="escuro"] .bg-slate-800 { background-color: #475569; }
html[data-tema-ativo="escuro"] .hover\:bg-white:hover,
html[data-tema-ativo="escuro"] .hover\:bg-slate-50:hover, html[data-tema-ativo="escuro"] .hover\:bg-gray-50:hover,
html[data-tema-ativo="escuro"] .hover\:bg-slate-100:hover, html[data-tema-ativo="escuro"] .hover\:bg-gray-100:hover { background-color: #2b3a51; }
html[data-tema-ativo="escuro"] .hover\:bg-slate-200:hover, html[data-tema-ativo="escuro"] .hover\:bg-gray-200:hover,
html[data-tema-ativo="escuro"] .hover\:bg-gray-300:hover { background-color: #3b4a61; }
html[data-tema-ativo="escuro"] .hover\:bg-slate-700:hover, html[data-tema-ativo="escuro"] .hover\:bg-slate-800:hover { background-color: #64748b; }

/* Texto */
html[data-tema-ativo="escuro"] .text-slate-900, html[data-tema-ativo="escuro"] .text-gray-900 { color: #f1f5f9; }
html[data-tema-ativo="escuro"] .text-slate-800, html[data-tema-ativo="escuro"] .text-gray-800 { color: #e2e8f0; }
html[data-tema-ativo="escuro"] .text-slate-700, html[data-tema-ativo="escuro"] .text-gray-700 { color: #cbd5e1; }
html[data-tema-ativo="escuro"] .text-slate-600, html[data-tema-ativo="escuro"] .text-gray-600 { color: #b4c0d0; }
html[data-tema-ativo="escuro"] .text-slate-500, html[data-tema-ativo="escuro"] .text-gray-500 { color: #9aa8bb; }
html[data-tema-ativo="escuro"] .text-slate-400, html[data-tema-ativo="escuro"] .text-gray-400 { color: #8291a6; }
html[data-tema-ativo="escuro"] .text-slate-300, html[data-tema-ativo="escuro"] .text-gray-300 { color: #64748b; }
html[data-tema-ativo="escuro"] .hover\:text-slate-900:hover, html[data-tema-ativo="escuro"] .hover\:text-gray-900:hover,
html[data-tema-ativo="escuro"] .hover\:text-slate-800:hover, html[data-tema-ativo="escuro"] .hover\:text-gray-800:hover,
html[data-tema-ativo="escuro"] .hover\:text-slate-700:hover, html[data-tema-ativo="escuro"] .hover\:text-gray-700:hover,
html[data-tema-ativo="escuro"] .hover\:text-slate-600:hover, html[data-tema-ativo="escuro"] .hover\:text-gray-600:hover { color: #f8fafc; }

/* Bordas e divisórias */
html[data-tema-ativo="escuro"] .border-slate-100, html[data-tema-ativo="escuro"] .border-gray-100 { border-color: #263244; }
html[data-tema-ativo="escuro"] .border-slate-200, html[data-tema-ativo="escuro"] .border-gray-200 { border-color: #334155; }
html[data-tema-ativo="escuro"] .border-slate-300, html[data-tema-ativo="escuro"] .border-gray-300 { border-color: #475569; }
html[data-tema-ativo="escuro"] .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
html[data-tema-ativo="escuro"] .divide-gray-100 > :not([hidden]) ~ :not([hidden]),
html[data-tema-ativo="escuro"] .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: #263244; }

/* Superfícies coloridas claras → tons translúcidos */
html[data-tema-ativo="escuro"] .bg-amber-50 { background-color: rgba(245, 158, 11, 0.12); }
html[data-tema-ativo="escuro"] .bg-amber-100 { background-color: rgba(245, 158, 11, 0.2); }
html[data-tema-ativo="escuro"] .border-amber-100, html[data-tema-ativo="escuro"] .border-amber-200,
html[data-tema-ativo="escuro"] .border-amber-300 { border-color: rgba(245, 158, 11, 0.4); }
html[data-tema-ativo="escuro"] .text-amber-700, html[data-tema-ativo="escuro"] .text-amber-800,
html[data-tema-ativo="escuro"] .text-amber-900 { color: #fcd34d; }
html[data-tema-ativo="escuro"] .bg-emerald-50, html[data-tema-ativo="escuro"] .bg-green-50,
html[data-tema-ativo="escuro"] .bg-green-100, html[data-tema-ativo="escuro"] .bg-emerald-50\/60 { background-color: rgba(16, 185, 129, 0.12); }
html[data-tema-ativo="escuro"] .border-emerald-100, html[data-tema-ativo="escuro"] .border-green-200 { border-color: rgba(16, 185, 129, 0.35); }
html[data-tema-ativo="escuro"] .text-green-700, html[data-tema-ativo="escuro"] .text-green-800,
html[data-tema-ativo="escuro"] .text-emerald-600, html[data-tema-ativo="escuro"] .text-emerald-700 { color: #6ee7b7; }
html[data-tema-ativo="escuro"] .bg-sky-50, html[data-tema-ativo="escuro"] .bg-blue-50,
html[data-tema-ativo="escuro"] .bg-indigo-50, html[data-tema-ativo="escuro"] .bg-blue-100 { background-color: rgba(56, 189, 248, 0.1); }
html[data-tema-ativo="escuro"] .border-sky-200, html[data-tema-ativo="escuro"] .border-indigo-200,
html[data-tema-ativo="escuro"] .border-blue-200 { border-color: rgba(56, 189, 248, 0.35); }
html[data-tema-ativo="escuro"] .text-blue-700, html[data-tema-ativo="escuro"] .text-blue-800,
html[data-tema-ativo="escuro"] .text-indigo-700 { color: #93c5fd; }
html[data-tema-ativo="escuro"] .bg-rose-50, html[data-tema-ativo="escuro"] .bg-red-50 { background-color: rgba(244, 63, 94, 0.12); }
html[data-tema-ativo="escuro"] .border-rose-200, html[data-tema-ativo="escuro"] .border-red-200 { border-color: rgba(244, 63, 94, 0.4); }
html[data-tema-ativo="escuro"] .text-red-600, html[data-tema-ativo="escuro"] .text-red-700,
html[data-tema-ativo="escuro"] .text-rose-600 { color: #fda4af; }

/* Campos de formulário sem fundo explícito */
html[data-tema-ativo="escuro"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-tema-ativo="escuro"] select, html[data-tema-ativo="escuro"] textarea {
  background-color: #0f172a; color: #e2e8f0;
}
html[data-tema-ativo="escuro"] ::placeholder { color: #64748b; }

/* Markdown (plugin typography) */
html[data-tema-ativo="escuro"] .prose {
  --tw-prose-body: #cbd5e1; --tw-prose-headings: #f1f5f9; --tw-prose-links: #93c5fd;
  --tw-prose-bold: #f1f5f9; --tw-prose-bullets: #64748b; --tw-prose-code: #f1f5f9;
  --tw-prose-quotes: #cbd5e1; --tw-prose-hr: #334155;
}

/* Blocos da Agenda (ScheduleEvent.COR_CSS; com projeto, a cor do projeto) */
html[data-tema-ativo="escuro"] .bg-purple-100 { background-color: rgba(168, 85, 247, 0.18); }
html[data-tema-ativo="escuro"] .text-purple-800 { color: #d8b4fe; }
html[data-tema-ativo="escuro"] .bg-yellow-100 { background-color: rgba(234, 179, 8, 0.18); }
html[data-tema-ativo="escuro"] .text-yellow-800 { color: #fde047; }
html[data-tema-ativo="escuro"] .bg-orange-100 { background-color: rgba(249, 115, 22, 0.18); }
html[data-tema-ativo="escuro"] .text-orange-800 { color: #fdba74; }
html[data-tema-ativo="escuro"] .bg-pink-100 { background-color: rgba(236, 72, 153, 0.18); }
html[data-tema-ativo="escuro"] .text-pink-800 { color: #f9a8d4; }
html[data-tema-ativo="escuro"] .bg-red-100 { background-color: rgba(244, 63, 94, 0.18); }
html[data-tema-ativo="escuro"] .text-red-800 { color: #fda4af; }
