/* ==========================================================================
   THEME-ENGINE.CSS - Sistema Unificado de Temas Globais do AppHub
   Suporte Completo a 4 Ambientes: Light, Dark, Cosmos e Matrix
   Cobertura Total (100%): Cabeçalhos, Cards, Métricas, Abas, Inputs, Modais,
   Painéis de Leitura, Controles de Áudio, Drawers e Rodapés.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. VARIÁVEIS CSS E FUNDAÇÃO POR TEMA
   -------------------------------------------------------------------------- */
:root {
  --th-transition-speed: 0.22s;
}

/* 1. LIGHT THEME (Modo Claro Alto Padrão & Contraste Limpo) */
html[data-theme="light"], body[data-theme="light"] {
  --th-bg: #f8fafc;
  --th-bg-alt: #f1f5f9;
  --th-surface: #ffffff;
  --th-surface-card: #ffffff;
  --th-surface-card-hover: #f8fafc;
  --th-border: #e2e8f0;
  --th-border-strong: #cbd5e1;
  --th-text: #0f172a;
  --th-text-muted: #64748b;
  --th-text-dim: #94a3b8;
  --th-primary: #0284c7;
  --th-primary-hover: #0369a1;
  --th-accent: #7c3aed;
  --th-header-bg: rgba(255, 255, 255, 0.96);
  --th-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  --th-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
  --th-input-bg: #ffffff;
  --th-input-border: #cbd5e1;
  --th-input-text: #0f172a;
  --th-btn-sec-bg: #f1f5f9;
  --th-btn-sec-border: #cbd5e1;
  --th-btn-sec-text: #1e293b;
  --th-highlight: rgba(124, 58, 237, 0.12);
  --th-highlight-border: #7c3aed;
  color-scheme: light;
}

/* 2. DARK THEME (Padrão Elegante Slate Profundo) */
html[data-theme="dark"], body[data-theme="dark"] {
  --th-bg: #0b1120;
  --th-bg-alt: #090d16;
  --th-surface: #0f172a;
  --th-surface-card: #1e293b;
  --th-surface-card-hover: #26334d;
  --th-border: #334155;
  --th-border-strong: #475569;
  --th-text: #f8fafc;
  --th-text-muted: #94a3b8;
  --th-text-dim: #64748b;
  --th-primary: #0284c7;
  --th-primary-hover: #38bdf8;
  --th-accent: #a855f7;
  --th-header-bg: rgba(15, 23, 42, 0.95);
  --th-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --th-shadow-lg: 0 12px 35px rgba(0, 0, 0, 0.6);
  --th-input-bg: #0f172a;
  --th-input-border: #334155;
  --th-input-text: #f8fafc;
  --th-btn-sec-bg: #1e293b;
  --th-btn-sec-border: #334155;
  --th-btn-sec-text: #e2e8f0;
  --th-highlight: rgba(168, 85, 247, 0.25);
  --th-highlight-border: #a855f7;
  color-scheme: dark;
}

/* 3. COSMOS THEME (Deep Space, Nebulosa & Vidro Cósmico) */
html[data-theme="cosmos"], body[data-theme="cosmos"] {
  --th-bg: #020308;
  --th-bg-alt: #07091a;
  --th-surface: rgba(10, 13, 32, 0.92);
  --th-surface-card: rgba(14, 18, 42, 0.88);
  --th-surface-card-hover: rgba(26, 32, 70, 0.92);
  --th-border: rgba(99, 102, 241, 0.28);
  --th-border-strong: rgba(129, 140, 248, 0.45);
  --th-text: #f8fafc;
  --th-text-muted: #a5b4fc;
  --th-text-dim: #6366f1;
  --th-primary: #6366f1;
  --th-primary-hover: #818cf8;
  --th-accent: #c084fc;
  --th-header-bg: rgba(5, 7, 20, 0.92);
  --th-shadow: 0 0 25px rgba(99, 102, 241, 0.18);
  --th-shadow-lg: 0 0 40px rgba(99, 102, 241, 0.3);
  --th-input-bg: rgba(9, 11, 28, 0.92);
  --th-input-border: rgba(99, 102, 241, 0.38);
  --th-input-text: #f8fafc;
  --th-btn-sec-bg: rgba(19, 24, 55, 0.85);
  --th-btn-sec-border: rgba(99, 102, 241, 0.35);
  --th-btn-sec-text: #e0e7ff;
  --th-highlight: rgba(129, 140, 248, 0.28);
  --th-highlight-border: #818cf8;
  color-scheme: dark;
}

/* ==========================================================================
   1. MODO LIGHT (CLARO) - REGRAS GLOBAIS PROFUNDAS
   ========================================================================== */
body[data-theme="light"] {
  background-color: var(--th-bg) !important;
  color: var(--th-text) !important;
}

/* Cabeçalho Principal e Barras Superiores */
body[data-theme="light"] header,
body[data-theme="light"] nav,
body[data-theme="light"] .app-header-bar {
  background-color: var(--th-header-bg) !important;
  border-color: var(--th-border) !important;
  color: var(--th-text) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04) !important;
}
body[data-theme="light"] header h1,
body[data-theme="light"] header h2,
body[data-theme="light"] header .text-white {
  color: var(--th-text) !important;
}
body[data-theme="light"] header p,
body[data-theme="light"] header .text-slate-400 {
  color: var(--th-text-muted) !important;
}

/* Switcher de Workspaces no Topo */
body[data-theme="light"] header .bg-slate-800\/90,
body[data-theme="light"] header .bg-slate-800 {
  background-color: #f1f5f9 !important;
  border-color: var(--th-border) !important;
}
body[data-theme="light"] .ws-tab-btn:not(.active) {
  color: #64748b !important;
}
body[data-theme="light"] .ws-tab-btn:not(.active):hover {
  color: #0f172a !important;
}
body[data-theme="light"] .ws-tab-btn.active {
  background-color: #0284c7 !important;
  color: #ffffff !important;
}

/* Alternador de Tema */
body[data-theme="light"] .app-theme-toggle-btn {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}
body[data-theme="light"] .app-theme-toggle-btn:hover {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
}

/* Botão Entrar / Autenticação no Tema Light */
body[data-theme="light"] #btn-open-login {
  background-color: #0284c7 !important;
  color: #ffffff !important;
  border: 1px solid #0284c7 !important;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25) !important;
}
body[data-theme="light"] #btn-open-login:hover {
  background-color: #0369a1 !important;
  border-color: #0369a1 !important;
}

/* Hero Banners do AppHub */
body[data-theme="light"] .hero-banner,
body[data-theme="light"] #area-apps > section:first-child,
body[data-theme="light"] #area-dev > section:first-child,
body[data-theme="light"] .catalogo-banner {
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%) !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05) !important;
}
body[data-theme="light"] #area-apps > section:first-child span,
body[data-theme="light"] #area-dev > section:first-child span {
  color: #0284c7 !important;
}
body[data-theme="light"] #area-apps > section:first-child h2,
body[data-theme="light"] #area-dev > section:first-child h2 {
  color: #0f172a !important;
}
body[data-theme="light"] #area-apps > section:first-child p,
body[data-theme="light"] #area-dev > section:first-child p {
  color: #475569 !important;
}

/* Métricas e Estatísticas dos Aplicativos e Dev */
body[data-theme="light"] section[aria-label="Resumo dos Aplicativos"] > div,
body[data-theme="light"] section[aria-label="Resumo do Dev Workspace"] > div {
  background-color: #ffffff !important;
  border-color: var(--th-border) !important;
  color: var(--th-text) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

/* Card de Status no Resumo de Aplicativos (Harmonia Light) */
body[data-theme="light"] section[aria-label="Resumo dos Aplicativos"] > div:last-child {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
  border: 1px solid #86efac !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08) !important;
}
body[data-theme="light"] section[aria-label="Resumo dos Aplicativos"] > div:last-child span,
body[data-theme="light"] section[aria-label="Resumo dos Aplicativos"] > div:last-child i {
  color: #15803d !important;
}
body[data-theme="light"] section[aria-label="Resumo dos Aplicativos"] > div:last-child .text-white {
  color: #14532d !important;
}

/* Títulos de Seção */
body[data-theme="light"] #apps-title,
body[data-theme="light"] #dev-title,
body[data-theme="light"] h3.text-slate-900 {
  color: var(--th-text) !important;
}

/* Cards de Aplicativos, Dev e Literatura */
body[data-theme="light"] .app-card,
body[data-theme="light"] .dev-shortcut-card,
body[data-theme="light"] .book-card,
body[data-theme="light"] .book-catalog-card,
body[data-theme="light"] .preview-card,
body[data-theme="light"] .glass-panel {
  background-color: #ffffff !important;
  border-color: var(--th-border) !important;
  color: var(--th-text) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04) !important;
}
body[data-theme="light"] .app-card:hover,
body[data-theme="light"] .dev-shortcut-card:hover,
body[data-theme="light"] .book-card:hover,
body[data-theme="light"] .book-catalog-card:hover {
  background-color: #f8fafc !important;
  border-color: #0284c7 !important;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.12) !important;
}
body[data-theme="light"] .app-card h4,
body[data-theme="light"] .dev-shortcut-card h4,
body[data-theme="light"] .book-card h3,
body[data-theme="light"] .book-card h4,
body[data-theme="light"] .book-catalog-card h3 {
  color: #0f172a !important;
}
body[data-theme="light"] .app-card p,
body[data-theme="light"] .dev-shortcut-card p,
body[data-theme="light"] .book-card p,
body[data-theme="light"] .book-catalog-card p {
  color: #64748b !important;
}
body[data-theme="light"] .app-card .border-t,
body[data-theme="light"] .dev-shortcut-card .border-t,
body[data-theme="light"] .book-card .border-t,
body[data-theme="light"] .book-catalog-card .border-t {
  background-color: #f8fafc !important;
  border-color: var(--th-border) !important;
}

/* Pílulas de Filtro de Categoria e Pesquisa */
body[data-theme="light"] .cat-pill:not(.active) {
  background-color: #ffffff !important;
  border-color: var(--th-border) !important;
  color: #475569 !important;
}
body[data-theme="light"] .cat-pill.active {
  background-color: #0284c7 !important;
  color: #ffffff !important;
}
body[data-theme="light"] input[type="text"],
body[data-theme="light"] input[type="email"],
body[data-theme="light"] input[type="password"],
body[data-theme="light"] select,
body[data-theme="light"] textarea {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

/* Modais e Caixas de Diálogo */
body[data-theme="light"] #dev-modal > div,
body[data-theme="light"] #modal-auth-overlay > div,
body[data-theme="light"] #modal-profile-overlay > div,
body[data-theme="light"] #modal-pendente-overlay > div,
body[data-theme="light"] #modal-admin-approvals > div {
  background-color: #ffffff !important;
  border-color: var(--th-border) !important;
  color: #0f172a !important;
}
body[data-theme="light"] #drawer-biblioteca {
  background-color: #ffffff !important;
  border-color: var(--th-border) !important;
  color: #0f172a !important;
}

/* Módulo Literatura: Área de Leitura e Player */
body[data-theme="light"] #view-text-mode {
  background-color: #ffffff !important;
  border-color: var(--th-border) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05) !important;
}
body[data-theme="light"] #text-content-container {
  color: #1e293b !important;
}
body[data-theme="light"] #current-book-title {
  color: #0f172a !important;
}
body[data-theme="light"] .spoken-paragraph {
  background-color: rgba(124, 58, 237, 0.12) !important;
  border-left-color: #7c3aed !important;
  color: #0f172a !important;
}
body[data-theme="light"] .bottom-audio-bar {
  background-color: rgba(255, 255, 255, 0.98) !important;
  border-color: #e2e8f0 !important;
  color: #0f172a !important;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08) !important;
}
body[data-theme="light"] .bottom-audio-bar button.bg-slate-800\/80,
body[data-theme="light"] .bottom-audio-bar div.bg-slate-800\/90 {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}
body[data-theme="light"] .bottom-audio-bar select {
  color: #0f172a !important;
}
body[data-theme="light"] .bottom-audio-bar select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}
body[data-theme="light"] #page-slider {
  background-color: #e2e8f0 !important;
}

/* Rodapés */
body[data-theme="light"] footer {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  color: #64748b !important;
}

/* Guia Prático - Enciclopédia Técnica (Modo Light Global) */
body[data-theme="light"] .guide-module > div:first-child {
  background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%) !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04) !important;
}
body[data-theme="light"] .guide-module > div:first-child h2 {
  color: #0f172a !important;
}
body[data-theme="light"] .guide-module > div:first-child p {
  color: #475569 !important;
}
body[data-theme="light"] article.bg-slate-900,
body[data-theme="light"] div.bg-slate-900 {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04) !important;
  color: #1e293b !important;
}
body[data-theme="light"] article h3.text-white,
body[data-theme="light"] article h3 {
  color: #0f172a !important;
}
body[data-theme="light"] article p.text-slate-300,
body[data-theme="light"] article p.text-slate-400 {
  color: #475569 !important;
}
body[data-theme="light"] .code-box {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
body[data-theme="light"] thead.bg-slate-950,
body[data-theme="light"] thead {
  background-color: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
  color: #0284c7 !important;
}
body[data-theme="light"] tbody tr {
  border-color: #f1f5f9 !important;
}
body[data-theme="light"] tbody tr:hover {
  background-color: #f8fafc !important;
}
body[data-theme="light"] #regex-pattern,
body[data-theme="light"] #regex-flags,
body[data-theme="light"] #regex-text {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
body[data-theme="light"] #regex-result {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}
body[data-theme="light"] pre {
  background-color: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
body[data-theme="light"] code {
  color: #0f172a !important;
}
body[data-theme="light"] pre code,
body[data-theme="light"] code[class*="language-"],
body[data-theme="light"] pre[class*="language-"] {
  color: #0f172a !important;
  text-shadow: none !important;
}

/* Blocos de Conteúdo Científico e Código no Modo Light */
body[data-theme="light"] .code-card {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}
body[data-theme="light"] .code-card-header {
  background: #e2e8f0 !important;
  border-bottom: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}
body[data-theme="light"] .code-card-header span {
  color: #0f172a !important;
}
body[data-theme="light"] .code-card-header .bg-zinc-800 {
  background: #dbeafe !important;
  color: #0284c7 !important;
  border-color: #bfdbfe !important;
}
body[data-theme="light"] .ascii-card {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}
body[data-theme="light"] .ascii-card code,
body[data-theme="light"] .ascii-card pre {
  color: #1e1b4b !important;
  font-weight: 600 !important;
}
body[data-theme="light"] .math-card {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
body[data-theme="light"] .math-display .katex {
  color: #0f172a !important;
}
body[data-theme="light"] .math-input,
body[data-theme="light"] .mermaid-input {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}
body[data-theme="light"] .mermaid-card {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

/* Tokens de Sintaxe Prism para Alto Contraste no Light Theme */
body[data-theme="light"] .token.comment,
body[data-theme="light"] .token.prolog,
body[data-theme="light"] .token.doctype,
body[data-theme="light"] .token.cdata {
  color: #64748b !important;
  font-style: italic;
}
body[data-theme="light"] .token.punctuation {
  color: #334155 !important;
}
body[data-theme="light"] .token.property,
body[data-theme="light"] .token.tag,
body[data-theme="light"] .token.boolean,
body[data-theme="light"] .token.number,
body[data-theme="light"] .token.constant,
body[data-theme="light"] .token.symbol,
body[data-theme="light"] .token.deleted {
  color: #b91c1c !important;
  font-weight: 600;
}
body[data-theme="light"] .token.selector,
body[data-theme="light"] .token.attr-name,
body[data-theme="light"] .token.string,
body[data-theme="light"] .token.char,
body[data-theme="light"] .token.builtin,
body[data-theme="light"] .token.inserted {
  color: #15803d !important;
  font-weight: 600;
}
body[data-theme="light"] .token.operator,
body[data-theme="light"] .token.entity,
body[data-theme="light"] .token.url {
  color: #0369a1 !important;
}
body[data-theme="light"] .token.atrule,
body[data-theme="light"] .token.attr-value,
body[data-theme="light"] .token.keyword {
  color: #7c3aed !important;
  font-weight: 700;
}
body[data-theme="light"] .token.function,
body[data-theme="light"] .token.class-name {
  color: #0284c7 !important;
  font-weight: 700;
}
body[data-theme="light"] .token.regex,
body[data-theme="light"] .token.important,
body[data-theme="light"] .token.variable {
  color: #c2410c !important;
}

body[data-theme="light"] div.bg-slate-950.font-mono {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #065f46 !important;
}


/* ==========================================================================
   2. MODO DARK (PADRÃO ELEGANTE SLATE PROFUNDO)
   ========================================================================== */
body[data-theme="dark"] {
  background-color: #0b1120 !important;
  color: #f8fafc !important;
}

body[data-theme="dark"] header,
body[data-theme="dark"] nav {
  background-color: #0f172a !important;
  border-color: #1e293b !important;
  color: #ffffff !important;
}

body[data-theme="dark"] .hero-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  border-color: #334155 !important;
}

body[data-theme="dark"] section[aria-label="Resumo dos Aplicativos"] > div,
body[data-theme="dark"] section[aria-label="Resumo do Dev Workspace"] > div {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
body[data-theme="dark"] section[aria-label="Resumo dos Aplicativos"] .text-slate-900,
body[data-theme="dark"] section[aria-label="Resumo do Dev Workspace"] .text-slate-900 {
  color: #f8fafc !important;
}

body[data-theme="dark"] #apps-title,
body[data-theme="dark"] #dev-title,
body[data-theme="dark"] h3.text-slate-900 {
  color: #f8fafc !important;
}

body[data-theme="dark"] .app-card,
body[data-theme="dark"] .dev-shortcut-card,
body[data-theme="dark"] .book-card,
body[data-theme="dark"] .book-catalog-card {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
body[data-theme="dark"] .app-card h4,
body[data-theme="dark"] .dev-shortcut-card h4,
body[data-theme="dark"] .book-card h3,
body[data-theme="dark"] .book-catalog-card h3 {
  color: #f8fafc !important;
}
body[data-theme="dark"] .app-card p,
body[data-theme="dark"] .dev-shortcut-card p,
body[data-theme="dark"] .book-card p,
body[data-theme="dark"] .book-catalog-card p {
  color: #94a3b8 !important;
}
body[data-theme="dark"] .app-card .border-t,
body[data-theme="dark"] .dev-shortcut-card .border-t,
body[data-theme="dark"] .book-card .border-t,
body[data-theme="dark"] .book-catalog-card .border-t {
  background-color: rgba(15, 23, 42, 0.6) !important;
  border-color: #334155 !important;
}

body[data-theme="dark"] .cat-pill:not(.active) {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}
body[data-theme="dark"] .cat-pill.active {
  background-color: #0284c7 !important;
  color: #ffffff !important;
}

body[data-theme="dark"] #dev-search-input {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

body[data-theme="dark"] #dev-modal > div,
body[data-theme="dark"] #modal-auth-overlay > div,
body[data-theme="dark"] #modal-profile-overlay > div,
body[data-theme="dark"] #modal-pendente-overlay > div,
body[data-theme="dark"] #modal-admin-approvals > div {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

body[data-theme="dark"] footer {
  background-color: #0f172a !important;
  border-color: #1e293b !important;
  color: #94a3b8 !important;
}


/* ==========================================================================
   3. MODO COSMOS (DEEP SPACE, NEBULOSA & VIDRO TRANSLÚCIDO)
   ========================================================================== */
body[data-theme="cosmos"] {
  background-color: #020308 !important;
  background: radial-gradient(ellipse at 50% 0%, #0d0f28 0%, #020308 75%) !important;
  background-attachment: fixed !important;
  color: #f8fafc !important;
}

body[data-theme="cosmos"] header,
body[data-theme="cosmos"] nav,
body[data-theme="cosmos"] .bottom-audio-bar {
  background: rgba(5, 7, 20, 0.92) !important;
  backdrop-filter: blur(16px) !important;
  border-color: rgba(99, 102, 241, 0.28) !important;
  color: #e0e7ff !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7) !important;
}

body[data-theme="cosmos"] header .bg-slate-800\/90,
body[data-theme="cosmos"] header .bg-slate-800 {
  background: rgba(14, 18, 45, 0.85) !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
}
body[data-theme="cosmos"] .ws-tab-btn.active {
  background: #6366f1 !important;
  color: #ffffff !important;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5) !important;
}

body[data-theme="cosmos"] #btn-open-login {
  background: #6366f1 !important;
  color: #ffffff !important;
  border: 1px solid rgba(165, 180, 252, 0.4) !important;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4) !important;
}
body[data-theme="cosmos"] #btn-open-login:hover {
  background: #4f46e5 !important;
  border-color: #c7d2fe !important;
}

body[data-theme="cosmos"] .hero-banner,
body[data-theme="cosmos"] #area-apps > section:first-child,
body[data-theme="cosmos"] #section-catalogo > div:first-child,
body[data-theme="cosmos"] .catalogo-banner,
body[data-theme="cosmos"] #area-dev > section:first-child {
  background: linear-gradient(135deg, rgba(15, 17, 36, 0.95) 0%, rgba(30, 27, 75, 0.8) 100%) !important;
  border: 1px solid rgba(99, 102, 241, 0.35) !important;
  box-shadow: 0 0 35px rgba(99, 102, 241, 0.2) !important;
}
body[data-theme="cosmos"] .hero-banner h2,
body[data-theme="cosmos"] #area-apps > section:first-child h2,
body[data-theme="cosmos"] #section-catalogo h2,
body[data-theme="cosmos"] #area-dev > section:first-child h2 {
  color: #ffffff !important;
  text-shadow: 0 0 16px rgba(99, 102, 241, 0.6);
}

body[data-theme="cosmos"] section[aria-label="Resumo dos Aplicativos"] > div,
body[data-theme="cosmos"] section[aria-label="Resumo do Dev Workspace"] > div {
  background: rgba(12, 16, 38, 0.85) !important;
  border: 1px solid rgba(99, 102, 241, 0.25) !important;
  color: #f8fafc !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6) !important;
}
body[data-theme="cosmos"] section[aria-label="Resumo dos Aplicativos"] .text-slate-900,
body[data-theme="cosmos"] section[aria-label="Resumo do Dev Workspace"] .text-slate-900 {
  color: #e0e7ff !important;
}

body[data-theme="cosmos"] #apps-title,
body[data-theme="cosmos"] #dev-title,
body[data-theme="cosmos"] h3.text-slate-900 {
  color: #e0e7ff !important;
}

body[data-theme="cosmos"] .app-card,
body[data-theme="cosmos"] .dev-shortcut-card,
body[data-theme="cosmos"] .book-card,
body[data-theme="cosmos"] .book-catalog-card,
body[data-theme="cosmos"] .preview-card,
body[data-theme="cosmos"] .glass-panel {
  background: rgba(12, 16, 38, 0.85) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(99, 102, 241, 0.25) !important;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7) !important;
  color: #f8fafc !important;
}
body[data-theme="cosmos"] .app-card:hover,
body[data-theme="cosmos"] .dev-shortcut-card:hover,
body[data-theme="cosmos"] .book-card:hover,
body[data-theme="cosmos"] .book-catalog-card:hover {
  border-color: #818cf8 !important;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.4) !important;
  transform: translateY(-2px);
}
body[data-theme="cosmos"] .app-card h4,
body[data-theme="cosmos"] .dev-shortcut-card h4,
body[data-theme="cosmos"] .book-card h3,
body[data-theme="cosmos"] .book-catalog-card h3 {
  color: #e0e7ff !important;
}
body[data-theme="cosmos"] .app-card p,
body[data-theme="cosmos"] .dev-shortcut-card p,
body[data-theme="cosmos"] .book-card p,
body[data-theme="cosmos"] .book-catalog-card p {
  color: #a5b4fc !important;
}
body[data-theme="cosmos"] .app-card .border-t,
body[data-theme="cosmos"] .dev-shortcut-card .border-t,
body[data-theme="cosmos"] .book-card .border-t,
body[data-theme="cosmos"] .book-catalog-card .border-t {
  background-color: rgba(6, 8, 20, 0.95) !important;
  border-color: rgba(99, 102, 241, 0.25) !important;
}

body[data-theme="cosmos"] .cat-pill:not(.active) {
  background: rgba(12, 16, 38, 0.85) !important;
  border: 1px solid rgba(99, 102, 241, 0.25) !important;
  color: #a5b4fc !important;
}
body[data-theme="cosmos"] .cat-pill.active {
  background: #6366f1 !important;
  color: #ffffff !important;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4) !important;
}

body[data-theme="cosmos"] input[type="text"],
body[data-theme="cosmos"] input[type="email"],
body[data-theme="cosmos"] input[type="password"],
body[data-theme="cosmos"] select,
body[data-theme="cosmos"] textarea {
  background: rgba(8, 10, 26, 0.92) !important;
  border-color: rgba(99, 102, 241, 0.38) !important;
  color: #f8fafc !important;
}

body[data-theme="cosmos"] #dev-modal > div,
body[data-theme="cosmos"] #modal-auth-overlay > div,
body[data-theme="cosmos"] #modal-profile-overlay > div,
body[data-theme="cosmos"] #modal-pendente-overlay > div,
body[data-theme="cosmos"] #modal-admin-approvals > div,
body[data-theme="cosmos"] #drawer-biblioteca {
  background: rgba(8, 10, 26, 0.96) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.3) !important;
}

body[data-theme="cosmos"] #view-text-mode {
  background: rgba(10, 13, 32, 0.88) !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
}
body[data-theme="cosmos"] #text-content-container {
  color: #e2e8f0 !important;
}
body[data-theme="cosmos"] .spoken-paragraph {
  background-color: rgba(129, 140, 248, 0.28) !important;
  border-left-color: #818cf8 !important;
  box-shadow: 0 0 20px rgba(129, 140, 248, 0.25) !important;
}

body[data-theme="cosmos"] footer {
  background-color: #020308 !important;
  border-color: rgba(99, 102, 241, 0.25) !important;
  color: #818cf8 !important;
}


/* ==========================================================================
   4. BARRAS DE ROLAGEM CUSTOMIZADAS
   ========================================================================== */
body[data-theme="light"] ::-webkit-scrollbar-thumb {
  background-color: #cbd5e1 !important;
}
body[data-theme="cosmos"] ::-webkit-scrollbar-thumb {
  background-color: rgba(99, 102, 241, 0.4) !important;
}

/* ==========================================================================
   5. COMMAND PALETTE, BOTÃO DE BUSCA & BADGE DE USUÁRIO
   ========================================================================== */

/* --- BOTÃO DE BUSCA NA TOOLBAR --- */
body[data-theme="light"] .app-search-trigger-btn {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}
body[data-theme="light"] .app-search-trigger-btn:hover {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
}
body[data-theme="light"] .palette-kbd-badge {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #64748b !important;
}

body[data-theme="dark"] .app-search-trigger-btn {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}
body[data-theme="dark"] .app-search-trigger-btn:hover {
  background-color: #334155 !important;
  color: #ffffff !important;
}
body[data-theme="dark"] .palette-kbd-badge {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}

body[data-theme="cosmos"] .app-search-trigger-btn {
  background-color: rgba(19, 24, 55, 0.85) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
  color: #e0e7ff !important;
}
body[data-theme="cosmos"] .app-search-trigger-btn:hover {
  background-color: rgba(26, 32, 70, 0.95) !important;
  color: #ffffff !important;
}
body[data-theme="cosmos"] .palette-kbd-badge {
  background-color: rgba(9, 11, 28, 0.9) !important;
  border-color: rgba(99, 102, 241, 0.4) !important;
  color: #a5b4fc !important;
}

/* --- BADGE DO USUÁRIO AUTENTICADO --- */
body[data-theme="light"] #auth-user-badge {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}
body[data-theme="light"] #auth-user-badge button {
  color: #64748b !important;
}
body[data-theme="light"] #auth-user-badge button:hover {
  color: #e11d48 !important;
  background-color: #e2e8f0 !important;
}

body[data-theme="dark"] #auth-user-badge {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}
body[data-theme="dark"] #auth-user-badge button {
  color: #94a3b8 !important;
}
body[data-theme="dark"] #auth-user-badge button:hover {
  color: #fb7185 !important;
  background-color: #334155 !important;
}

body[data-theme="cosmos"] #auth-user-badge {
  background-color: rgba(19, 24, 55, 0.85) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.15) !important;
}
body[data-theme="cosmos"] #auth-user-badge button {
  color: #a5b4fc !important;
}
body[data-theme="cosmos"] #auth-user-badge button:hover {
  color: #f43f5e !important;
  background-color: rgba(99, 102, 241, 0.2) !important;
}

/* --- JANELA GLOBAL DO COMMAND PALETTE --- */
/* MODO LIGHT */
body[data-theme="light"] #command-palette-modal {
  background-color: rgba(15, 23, 42, 0.4) !important;
}
body[data-theme="light"] .palette-dialog {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15) !important;
}
body[data-theme="light"] .palette-header {
  background-color: #f8fafc !important;
  border-bottom-color: #e2e8f0 !important;
}
body[data-theme="light"] #palette-search-input {
  color: #0f172a !important;
}
body[data-theme="light"] #palette-search-input::placeholder {
  color: #94a3b8 !important;
}
body[data-theme="light"] .palette-kbd {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #64748b !important;
}
body[data-theme="light"] .palette-close-btn {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #64748b !important;
}
body[data-theme="light"] .palette-close-btn:hover {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
}
body[data-theme="light"] .palette-item {
  color: #334155 !important;
}
body[data-theme="light"] .palette-item:hover,
body[data-theme="light"] .palette-item.selected {
  background-color: #f0f9ff !important;
  color: #0369a1 !important;
}
body[data-theme="light"] .palette-item-title {
  color: #0f172a !important;
}
body[data-theme="light"] .palette-item:hover .palette-item-title,
body[data-theme="light"] .palette-item.selected .palette-item-title {
  color: #0284c7 !important;
}
body[data-theme="light"] .palette-item-desc {
  color: #64748b !important;
}
body[data-theme="light"] .palette-icon-box {
  background-color: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  color: #0284c7 !important;
}
body[data-theme="light"] .palette-item:hover .palette-icon-box,
body[data-theme="light"] .palette-item.selected .palette-icon-box {
  background-color: #e0f2fe !important;
  border-color: #bae6fd !important;
}
body[data-theme="light"] .palette-item-enter {
  color: #94a3b8 !important;
}
body[data-theme="light"] .palette-item:hover .palette-item-enter,
body[data-theme="light"] .palette-item.selected .palette-item-enter {
  color: #0284c7 !important;
}
body[data-theme="light"] .palette-footer {
  background-color: #f8fafc !important;
  border-top-color: #e2e8f0 !important;
  color: #64748b !important;
}
body[data-theme="light"] .palette-footer-engine {
  color: #7c3aed !important;
}

/* MODO DARK */
body[data-theme="dark"] .palette-dialog {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6) !important;
}
body[data-theme="dark"] .palette-header {
  background-color: #090e1a !important;
  border-bottom-color: #1e293b !important;
}
body[data-theme="dark"] #palette-search-input {
  color: #f8fafc !important;
}
body[data-theme="dark"] #palette-search-input::placeholder {
  color: #64748b !important;
}
body[data-theme="dark"] .palette-kbd {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}
body[data-theme="dark"] .palette-item {
  color: #cbd5e1 !important;
}
body[data-theme="dark"] .palette-item:hover,
body[data-theme="dark"] .palette-item.selected {
  background-color: #1e293b !important;
  color: #ffffff !important;
}
body[data-theme="dark"] .palette-item-title {
  color: #f8fafc !important;
}
body[data-theme="dark"] .palette-item-desc {
  color: #94a3b8 !important;
}
body[data-theme="dark"] .palette-icon-box {
  background-color: #1e293b !important;
  border: 1px solid #334155 !important;
}
body[data-theme="dark"] .palette-footer {
  background-color: #090e1a !important;
  border-top-color: #1e293b !important;
  color: #94a3b8 !important;
}

/* MODO COSMOS */
body[data-theme="cosmos"] .palette-dialog {
  background-color: rgba(10, 13, 34, 0.96) !important;
  border-color: rgba(99, 102, 241, 0.45) !important;
  color: #f8fafc !important;
  box-shadow: 0 0 50px rgba(99, 102, 241, 0.35) !important;
}
body[data-theme="cosmos"] .palette-header {
  background-color: rgba(7, 9, 24, 0.95) !important;
  border-bottom-color: rgba(99, 102, 241, 0.3) !important;
}
body[data-theme="cosmos"] #palette-search-input {
  color: #f8fafc !important;
}
body[data-theme="cosmos"] #palette-search-input::placeholder {
  color: #818cf8 !important;
}
body[data-theme="cosmos"] .palette-kbd {
  background-color: rgba(19, 24, 55, 0.9) !important;
  border-color: rgba(99, 102, 241, 0.4) !important;
  color: #c7d2fe !important;
}
body[data-theme="cosmos"] .palette-item {
  color: #e0e7ff !important;
}
body[data-theme="cosmos"] .palette-item:hover,
body[data-theme="cosmos"] .palette-item.selected {
  background-color: rgba(99, 102, 241, 0.22) !important;
  color: #ffffff !important;
}
body[data-theme="cosmos"] .palette-item-title {
  color: #ffffff !important;
}
body[data-theme="cosmos"] .palette-item-desc {
  color: #a5b4fc !important;
}
body[data-theme="cosmos"] .palette-icon-box {
  background-color: rgba(19, 24, 55, 0.85) !important;
  border: 1px solid rgba(99, 102, 241, 0.35) !important;
}
body[data-theme="cosmos"] .palette-footer {
  background-color: rgba(7, 9, 24, 0.95) !important;
  border-top-color: rgba(99, 102, 241, 0.3) !important;
  color: #a5b4fc !important;
}
body[data-theme="cosmos"] .palette-footer-engine {
  color: #c084fc !important;
}

/* ==========================================================================
   ESTILOS GLOBAIS DE CÓDIGO INLINE (ALTO CONTRASTE EM TODOS OS TEMAS)
   ========================================================================== */
:not(pre) > code,
.inline-code,
code:not(pre code) {
  font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
  font-size: 0.88em !important;
  padding: 1.5px 5.5px !important;
  border-radius: 4px !important;
  display: inline !important;
  vertical-align: baseline !important;
  margin: 0 1.5px !important;
  word-break: break-word !important;
  text-shadow: none !important;
  font-weight: 600 !important;
}

body[data-theme="light"] :not(pre) > code,
body[data-theme="light"] .inline-code,
body[data-theme="light"] code:not(pre code) {
  background-color: #f1f5f9 !important;
  background: #f1f5f9 !important;
  color: #e11d48 !important; /* VERMELHO VIVO / ROSE CONFORME PEDIDO */
  border: 1px solid #cbd5e1 !important;
}

body[data-theme="dark"] :not(pre) > code,
body[data-theme="dark"] .inline-code,
body[data-theme="dark"] code:not(pre code) {
  background-color: #1e293b !important;
  background: #1e293b !important;
  color: #fb7185 !important; /* ROSE / VERMELHO CLARO VIBRANTE */
  border: 1px solid #334155 !important;
}

body[data-theme="cosmos"] :not(pre) > code,
body[data-theme="cosmos"] .inline-code,
body[data-theme="cosmos"] code:not(pre code) {
  background-color: rgba(99, 102, 241, 0.2) !important;
  background: rgba(99, 102, 241, 0.2) !important;
  color: #f43f5e !important;
  border: 1px solid rgba(99, 102, 241, 0.4) !important;
}

body[data-theme="matrix"] :not(pre) > code,
body[data-theme="matrix"] .inline-code,
body[data-theme="matrix"] code:not(pre code) {
  background-color: #002200 !important;
  background: #002200 !important;
  color: #00ff41 !important;
  border: 1px solid #005f15 !important;
}

/* ==========================================================================
   QUEBRA AUTOMÁTICA EM BLOCOS DE CÓDIGO - SEM BARRAS DE ROLAGEM HORIZONTAIS
   ========================================================================== */
.page-a4 pre,
.page-a4 pre code,
.page-a4 .code-card pre,
.page-a4 .code-card code,
.page-a4 .ascii-card,
.page-a4 pre[class*="language-"],
.page-a4 code[class*="language-"] {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  overflow-x: hidden !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* ==========================================================================
   MODAL DE AUTENTICAÇÃO — CONTRASTE CONSISTENTE EM DARK E COSMOS
   ========================================================================== */
body[data-theme="dark"] #modal-auth-overlay > div,
body[data-theme="cosmos"] #modal-auth-overlay > div {
  background: #0b1120 !important;
  color: #f8fafc !important;
}
body[data-theme="cosmos"] #modal-auth-overlay > div {
  background: rgba(8, 11, 30, 0.98) !important;
  border-color: rgba(129, 140, 248, 0.42) !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.68), 0 0 32px rgba(99, 102, 241, 0.18) !important;
}
body[data-theme="dark"] #modal-auth-overlay .bg-slate-100,
body[data-theme="cosmos"] #modal-auth-overlay .bg-slate-100 {
  background: #111827 !important;
  border-color: #334155 !important;
}
body[data-theme="cosmos"] #modal-auth-overlay .bg-slate-100 {
  background: rgba(17, 24, 55, 0.9) !important;
  border-color: rgba(129, 140, 248, 0.35) !important;
}
body[data-theme="dark"] #modal-auth-overlay #tab-auth-login.bg-white,
body[data-theme="dark"] #modal-auth-overlay #tab-auth-register.bg-white,
body[data-theme="cosmos"] #modal-auth-overlay #tab-auth-login.bg-white,
body[data-theme="cosmos"] #modal-auth-overlay #tab-auth-register.bg-white {
  background: #334155 !important;
  color: #ffffff !important;
}
body[data-theme="cosmos"] #modal-auth-overlay #tab-auth-login.bg-white,
body[data-theme="cosmos"] #modal-auth-overlay #tab-auth-register.bg-white {
  background: #4f46e5 !important;
}
body[data-theme="dark"] #modal-auth-overlay label,
body[data-theme="dark"] #modal-auth-overlay .text-slate-700,
body[data-theme="dark"] #modal-auth-overlay .text-slate-600,
body[data-theme="cosmos"] #modal-auth-overlay label,
body[data-theme="cosmos"] #modal-auth-overlay .text-slate-700,
body[data-theme="cosmos"] #modal-auth-overlay .text-slate-600 {
  color: #cbd5e1 !important;
}
body[data-theme="dark"] #modal-auth-overlay input,
body[data-theme="cosmos"] #modal-auth-overlay input {
  background: #172033 !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}
body[data-theme="cosmos"] #modal-auth-overlay input {
  background: rgba(17, 24, 55, 0.92) !important;
  border-color: rgba(129, 140, 248, 0.5) !important;
}
body[data-theme="dark"] #modal-auth-overlay #btn-auth-google,
body[data-theme="cosmos"] #modal-auth-overlay #btn-auth-google {
  background: #1e293b !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}
body[data-theme="cosmos"] #modal-auth-overlay #btn-auth-google {
  background: rgba(30, 36, 76, 0.92) !important;
  border-color: rgba(129, 140, 248, 0.45) !important;
}
body[data-theme="dark"] #modal-auth-overlay .relative > span.bg-white,
body[data-theme="cosmos"] #modal-auth-overlay .relative > span.bg-white {
  background: #0b1120 !important;
  color: #94a3b8 !important;
}
body[data-theme="cosmos"] #modal-auth-overlay .relative > span.bg-white {
  background: #080b1e !important;
  color: #a5b4fc !important;
}
body[data-theme="dark"] #modal-auth-overlay #btn-auth-submit,
body[data-theme="cosmos"] #modal-auth-overlay #btn-auth-submit {
  background: #0284c7 !important;
  color: #ffffff !important;
}
body[data-theme="cosmos"] #modal-auth-overlay #btn-auth-submit {
  background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
}

