/* ═══════════════════════════════════════════════
   Crypta AI — Animações, Scrollbar, Prose
   (variáveis de tema ficam inline em cada arquivo)
   ═══════════════════════════════════════════════ */

* { box-sizing: border-box; }

/* ── Base ───────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  transition: background 0.25s ease, color 0.25s ease;
}
html:not(.dark) body { color: #0a0a18 !important; }

/* ── Fontes ─────────────────────────────────────── */
* { font-family: 'Inter', sans-serif; }
h1, h2, h3, .brand { font-family: 'Space Grotesk', sans-serif; }

/* ── Corporate Dark Premium ─────────────────────── */

/* Gradient text — violet/indigo split */
.brand-gradient {
  background: linear-gradient(115deg, #c4b5fd 0%, #818cf8 55%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* Stronger glow variant */
.brand-gradient-vivid {
  background: linear-gradient(115deg, #ddd6fe 0%, #a78bfa 40%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Dot grid overlay (applied to a pseudo or wrapper) */
.bg-dot-grid::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(139,92,246,.1) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}
html:not(.dark) .bg-dot-grid::before {
  background-image: radial-gradient(circle, rgba(139,92,246,.07) 1px, transparent 1px);
}

/* Editorial heading: ultra-bold, tight tracking */
.heading-editorial {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.95;
}

/* Subtle tag/badge — mono uppercase */
.tag-mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(139,92,246,.1);
  border: 1px solid rgba(139,92,246,.2);
  color: #a78bfa;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

/* Horizontal rule with violet glow */
.divider-glow {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,.4), transparent);
}

/* ── Scrollbar fina ─────────────────────────────── */
.scrollbar-thin::-webkit-scrollbar { width: 4px; height: 4px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: rgba(139,92,246,.2); border-radius: 9999px; }
.scrollbar-thin::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,.4); }

/* ── Animações ──────────────────────────────────── */
@keyframes msgAppear {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-appear { animation: msgAppear .22s cubic-bezier(.22,1,.36,1) forwards; }

@keyframes typingBounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-5px); }
}
.typing-dot { animation: typingBounce 1.2s ease-in-out infinite; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeSlideIn .35s cubic-bezier(.22,1,.36,1) forwards; }

@keyframes spinPulse {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.animate-spin { animation: spinPulse 1s linear infinite; }

@keyframes pulse-glow {
  0%,100% { box-shadow: 0 0 0 0 rgba(139,92,246,0), 0 24px 64px rgba(0,0,0,.4); }
  50%      { box-shadow: 0 0 28px 4px rgba(139,92,246,.12), 0 24px 64px rgba(0,0,0,.4); }
}
.card-glow { animation: pulse-glow 4s ease-in-out infinite; }

/* ── Prose (markdown da Crypta) ─────────────────── */
.prose-crypta { line-height: 1.75; }

.prose-crypta h1,
.prose-crypta h2,
.prose-crypta h3 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  color: var(--text);
  font-weight: 600;
  margin-top: 1.25em;
  margin-bottom: .5em;
  line-height: 1.35;
}
.prose-crypta h1 { font-size: 1.15rem; }
.prose-crypta h2 { font-size: 1.05rem; }
.prose-crypta h3 { font-size: .95rem; color: var(--text-3); }

.prose-crypta p  { margin-bottom: .75em; color: var(--text-2); }
.prose-crypta p:last-child { margin-bottom: 0; }

.prose-crypta ul,
.prose-crypta ol { padding-left: 1.4em; margin-bottom: .75em; }
.prose-crypta li { margin-bottom: .3em; color: var(--text-2); }
.prose-crypta ul li::marker { color: #8b5cf6; }
.prose-crypta ol li::marker { color: #8b5cf6; font-weight: 600; }

.prose-crypta strong { color: var(--text); font-weight: 600; }
.prose-crypta em     { color: #8b5cf6; }

.prose-crypta a {
  color: #818cf8;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose-crypta a:hover { color: #a5b4fc; }

.prose-crypta blockquote {
  border-left: 3px solid #8b5cf6;
  padding: .5rem 1rem;
  margin: .75rem 0;
  background: rgba(139,92,246,.07);
  border-radius: 0 10px 10px 0;
  color: var(--text-3);
  font-style: italic;
}

/* ── Modo claro: força texto escuro no prose ── */
html:not(.dark) .prose-crypta,
html:not(.dark) .prose-crypta p,
html:not(.dark) .prose-crypta li,
html:not(.dark) .prose-crypta td { color: #1a1a3a !important; }

html:not(.dark) .prose-crypta h1,
html:not(.dark) .prose-crypta h2 { color: #0a0a18 !important; }

html:not(.dark) .prose-crypta h3 { color: #2a2a52 !important; }

html:not(.dark) .prose-crypta strong { color: #0a0a18 !important; }

html:not(.dark) .prose-crypta em { color: #6d28d9 !important; }

html:not(.dark) .prose-crypta a { color: #4f46e5 !important; }
html:not(.dark) .prose-crypta a:hover { color: #6d28d9 !important; }

html:not(.dark) .prose-crypta blockquote {
  color: #2e2e58 !important;
  background: rgba(109,40,217,.06) !important;
}

.prose-crypta code {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .15em .42em;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .83em;
  color: #a78bfa;
}

html:not(.dark) .prose-crypta code {
  color: #7c3aed;
  background: rgba(139,92,246,.08);
  border-color: rgba(139,92,246,.15);
}

.prose-crypta pre {
  background: var(--surface) !important;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  overflow-x: auto;
  margin: .75rem 0;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}

html.dark .prose-crypta pre { background: #080815 !important; }
html.dark .prose-crypta pre code { color: #c9d1d9 !important; }

.prose-crypta pre code {
  background: transparent !important;
  border: none;
  padding: 0;
  color: inherit;
  font-size: .82rem;
  line-height: 1.65;
}

.prose-crypta table {
  width: 100%;
  border-collapse: collapse;
  margin: .75rem 0;
  font-size: .9em;
}
.prose-crypta th {
  background: rgba(139,92,246,.1);
  color: #a78bfa;
  font-weight: 600;
  padding: .5rem .75rem;
  text-align: left;
  border-bottom: 1px solid rgba(139,92,246,.2);
}
.prose-crypta td {
  padding: .4rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.prose-crypta tr:last-child td { border-bottom: none; }

.prose-crypta hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ── Btn primário ────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: white;
  font-weight: 600;
  border-radius: 12px;
  transition: filter .18s, transform .15s;
}
.btn-primary:hover  { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); filter: brightness(.95); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }

/* ── Theme toggle ──────────────────────────────── */
.theme-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s;
  flex-shrink: 0;
}
.theme-btn:hover {
  background: rgba(139,92,246,.1);
  border-color: rgba(139,92,246,.3);
  color: #8b5cf6;
}

/* ── Input base ─────────────────────────────────── */
.inp {
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.inp::placeholder { color: var(--text-4); }
.inp:focus {
  outline: none;
  border-color: rgba(139,92,246,.5);
  box-shadow: 0 0 0 3px rgba(139,92,246,.12);
}

input:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(139,92,246,.12);
  border-color: rgba(139,92,246,.5) !important;
}
textarea:focus { outline: none; box-shadow: none; border-color: inherit; }

/* ── Select estilizado ───────────────────────────── */
select {
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  background-color: var(--input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem 1rem;
  padding-right: 2.5rem !important;
  cursor: pointer;
  color: var(--text);
}
html:not(.dark) select { color-scheme: light; }
select option {
  background-color: var(--surface);
  color: var(--text);
}

/* ── Sidebar conversation item ──────────────────── */
.conv-item.active-conv {
  background: rgba(139,92,246,.1) !important;
  color: var(--text) !important;
  border-left: 2px solid #8b5cf6;
}

/* ── Tab ativa ──────────────────────────────────── */
.tab-btn.active {
  color: var(--text) !important;
  border-bottom: 2px solid #8b5cf6;
}

/* ── Tabela alternada ───────────────────────────── */
tbody tr:nth-child(even) { background: rgba(139,92,246,.02); }

/* ── Custom dropdown ────────────────────────────── */
#categorySelectList::-webkit-scrollbar,
#causaCatList::-webkit-scrollbar       { width: 4px; }
#categorySelectList::-webkit-scrollbar-track,
#causaCatList::-webkit-scrollbar-track { background: transparent; }
#categorySelectList::-webkit-scrollbar-thumb,
#causaCatList::-webkit-scrollbar-thumb { background: rgba(139,92,246,.3); border-radius: 4px; }

.cat-opt:first-child { border-radius: 12px 12px 0 0; }
.cat-opt:last-child  { border-radius: 0 0 12px 12px; }

/* ── Seleção de texto ─────────────────────────── */
::selection {
  background: rgba(139,92,246,.3);
  color: #f1f5f9;
}

/* ── Light mode overrides para elementos gerados pelo JS ── */
html:not(.dark) #typingIndicator .typing-bubble {
  background: rgba(0,0,0,0.06) !important;
}
html:not(.dark) [style*="background:#1a1a2a"],
html:not(.dark) [style*="background:#14142a"],
html:not(.dark) [style*="background:#0d1117"],
html:not(.dark) [style*="background:#161b22"] {
  background: #f0f0f8 !important;
}

/* hljs: tema claro no modo claro */
html:not(.dark) .hljs {
  background: #f0f0f8 !important;
  color: #1e1e3a !important;
}
html:not(.dark) .prose-crypta pre {
  background: #f0f0f8 !important;
  border-color: rgba(0,0,0,.1) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.06) !important;
}
html:not(.dark) .prose-crypta code {
  color: #6d28d9 !important;
  background: rgba(109,40,217,.08) !important;
  border-color: rgba(109,40,217,.15) !important;
}

/* Blockquote no modo claro */
html:not(.dark) .prose-crypta blockquote {
  background: rgba(109,40,217,.05);
  color: var(--text-3);
}

/* ── Suggestion buttons hover ─── */
.suggestion-btn:hover {
  border-color: rgba(139,92,246,.35) !important;
  background: rgba(139,92,246,.07) !important;
}
