/* ================= KOAVY HEALTH TECH DESIGN SYSTEM ================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,600&family=JetBrains+Mono:wght@400;600;700&display=swap');

/* RESET & BASE VARIABLES */
:root {
  /* DARK THEME (DEFAULT) */
  --bg-main: #0A0A0A;
  --bg-secondary: #141414;
  --surface-1: #1C1C1C;
  --surface-2: #242424;
  --border-color: #2A2A2A;
  --border-subtle: rgba(255, 255, 255, 0.08);

  --turquoise: #008A8A;
  --turquoise-glow: rgba(0, 138, 138, 0.25);
  --turquoise-dark: #006666;
  --teal-light: #4DB8B8;
  --mascot-gray: #6F737C;
  --cream: #E5CDB7;

  --text-main: #FFFFFF;
  --text-muted: #A3A3A3;
  --text-dim: #6B6B6B;

  --accent-red: #FF5A65;
  --accent-amber: #FFB340;
  --accent-emerald: #22C55E;

  --glass-bg: rgba(28, 28, 28, 0.65);
  --glass-border: rgba(42, 42, 42, 0.7);
  --shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  --ecg-color: #008A8A;
  --ecg-grid: rgba(0, 138, 138, 0.10);
}

/* LIGHT THEME OVERRIDES */
html.light, body.light {
  --bg-main: #FFFFFF;
  --bg-secondary: #F5F5F5;
  --surface-1: #FFFFFF;
  --surface-2: #F0F0F0;
  --border-color: #DDDDDD;
  --border-subtle: rgba(0, 0, 0, 0.08);

  --turquoise: #008A8A;
  --turquoise-glow: rgba(0, 138, 138, 0.20);
  --turquoise-dark: #006666;
  --teal-light: #2E9E9E;
  --mascot-gray: #555A63;
  --cream: #D4B498;

  --text-main: #000000;
  --text-muted: #4A4A4A;
  --text-dim: #7A7A7A;

  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(221, 221, 221, 0.8);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
  --ecg-color: #008A8A;
  --ecg-grid: rgba(0, 138, 138, 0.10);
}

/* GLOBAL RESET & TYPOGRAPHY */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

code, pre, .font-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* UTILITY CLASSES & GLASSMORPHISM */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
}

.glass-card {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  box-shadow: var(--shadow-card);
}

.glass-card:hover {
  border-color: var(--turquoise);
  box-shadow: 0 20px 40px -15px var(--turquoise-glow);
}

.text-gradient {
  background: linear-gradient(135deg, var(--turquoise) 0%, var(--teal-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-gradient-gold {
  background: linear-gradient(135deg, #FFD700 0%, var(--cream) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.bg-gradient-koavy {
  background: linear-gradient(135deg, var(--turquoise) 0%, var(--turquoise-dark) 100%);
}

/* BUTTON STYLES */
.btn-primary {
  background: linear-gradient(135deg, var(--turquoise) 0%, var(--turquoise-dark) 100%);
  color: #FFFFFF;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 0.875rem 2rem;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 25px -5px var(--turquoise-glow);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 15px 35px -5px var(--turquoise-glow);
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--surface-1);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-weight: 700;
  padding: 0.875rem 2rem;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--turquoise);
  color: var(--turquoise);
  transform: translateY(-2px);
}

/* ECG MONITOR CANVAS & ANIMATION */
.ecg-container {
  position: relative;
  width: 100%;
  height: 120px;
  background-color: #050505;
  background-image: 
    linear-gradient(var(--ecg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--ecg-grid) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

html.light .ecg-container {
  background-color: #FAFAFA;
}

.ecg-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* PULSE BEAT ANIMATION */
@keyframes heartPulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 0px var(--turquoise)); }
  15% { transform: scale(1.25); filter: drop-shadow(0 0 15px var(--turquoise)); }
  30% { transform: scale(1); filter: drop-shadow(0 0 0px var(--turquoise)); }
  45% { transform: scale(1.15); filter: drop-shadow(0 0 10px var(--turquoise)); }
  60% { transform: scale(1); filter: drop-shadow(0 0 0px var(--turquoise)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0px var(--turquoise)); }
}

.animate-heartbeat {
  animation: heartPulse 1.2s ease-in-out infinite;
}

/* REVEAL ANIMATIONS */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

.reveal-up { transform: translateY(32px); }
.reveal-left { transform: translateX(-32px); }
.reveal-right { transform: translateX(32px); }
.reveal-zoom { transform: scale(0.92); }

.delay-100 { transition-delay: 0.1s; }
.delay-200 { transition-delay: 0.2s; }
.delay-300 { transition-delay: 0.3s; }
.delay-400 { transition-delay: 0.4s; }

/* MODALS */
#modalEditar, #modalTutor, #forgotModal, #googleMockModal, #history-modal {
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
}

html.light #modalEditar, html.light #modalTutor, html.light #forgotModal, html.light #googleMockModal, html.light #history-modal {
  background: rgba(255, 255, 255, 0.85);
}

/* CUSTOM INPUT FORM STYLES */
.form-input-custom {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input-custom:focus {
  border-color: var(--turquoise);
  box-shadow: 0 0 0 4px var(--turquoise-glow);
}

/* CUSTOM SCROLLBAR */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--turquoise);
}

/* SELECTION */
::selection {
  background: var(--turquoise-glow);
  color: var(--turquoise);
}

/* ===================== Acessibilidade (components/acessibilidade.js) ===================== */
/* Letra grande: zoom aumenta tudo, inclusive textos com tamanho fixo em px (text-[10px]). */
html.a11y-texto-grande body { zoom: 1.2; }

/* Alto contraste: textos secundários e bordas bem mais fortes. */
html.a11y-contraste {
  --text-muted: #EDEDED;
  --text-dim: #D4D4D4;
  --border-color: #9A9A9A;
  --border-subtle: rgba(255, 255, 255, 0.45);
  --glass-border: rgba(220, 220, 220, 0.7);
  --turquoise: #2FE6E6;
}
html.light.a11y-contraste {
  --text-muted: #111111;
  --text-dim: #222222;
  --border-color: #333333;
  --border-subtle: rgba(0, 0, 0, 0.5);
  --glass-border: rgba(40, 40, 40, 0.7);
  --turquoise: #005A5A;
}
/* Telas que usam os cinzas do Tailwind direto. */
html.a11y-contraste .text-gray-400,
html.a11y-contraste .text-gray-500,
html.a11y-contraste .text-gray-600 { color: var(--text-muted) !important; }

/* ===================== Monitor do topo (script.js: iniciarMonitorHero) ===================== */
/* Coração e luz do monitor batem junto com o pico do ECG (a classe .batendo é reposta a cada batida). */
@keyframes batida {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 var(--turquoise)); }
  25% { transform: scale(1.25); filter: drop-shadow(0 0 12px var(--turquoise)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 var(--turquoise)); }
}
#hero-coracao.batendo { animation: batida 0.45s ease-out; }

.monitor-luz {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--turquoise);
}
@keyframes luzBatida {
  0% { box-shadow: 0 0 0 0 var(--turquoise); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
.monitor-luz.batendo { animation: luzBatida 0.6s ease-out; }

/* ===================== Como funciona (script.js: iniciarComoFunciona) ===================== */
/* Um ciclo de 4 s: a luz sai da pulseira (0%), passa pela API (33%) e chega no celular (66%). */
.fluxo { --ciclo: 4s; }

.fluxo-icone {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--turquoise-glow);
  color: var(--turquoise);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  animation: etapaAtiva var(--ciclo) ease-out infinite;
}
.fluxo-etapa:nth-of-type(3) .fluxo-icone { animation-delay: calc(var(--ciclo) / 3); }
.fluxo-etapa:nth-of-type(5) .fluxo-icone { animation-delay: calc(var(--ciclo) * 2 / 3); }

@keyframes etapaAtiva {
  0% { box-shadow: 0 0 0 0 var(--turquoise); transform: scale(1.08); }
  20% { box-shadow: 0 0 0 14px transparent; transform: scale(1); }
  100% { box-shadow: 0 0 0 14px transparent; transform: scale(1); }
}

/* Linha entre as etapas: vertical no celular, horizontal no computador. */
.fluxo-linha {
  position: relative;
  width: 2px;
  height: 56px;
  margin: 0 auto;
  background: linear-gradient(var(--border-color), var(--turquoise), var(--border-color));
}
.fluxo-linha span {
  position: absolute;
  left: 50%;
  top: 0;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--turquoise);
  box-shadow: 0 0 12px 3px var(--turquoise);
  opacity: 0;
  animation: pacoteVertical var(--ciclo) linear infinite;
}
.fluxo-linha-2 span { animation-delay: calc(var(--ciclo) / 3); }

@keyframes pacoteVertical {
  0% { top: 0; opacity: 0; }
  4% { opacity: 1; }
  29% { opacity: 1; }
  33% { top: 100%; opacity: 0; }
  100% { top: 100%; opacity: 0; }
}
@keyframes pacoteHorizontal {
  0% { left: 0; opacity: 0; }
  4% { opacity: 1; }
  29% { opacity: 1; }
  33% { left: 100%; opacity: 0; }
  100% { left: 100%; opacity: 0; }
}

@media (min-width: 1024px) {
  .fluxo-linha {
    width: 72px;
    height: 2px;
    margin: 0;
    align-self: center;
    background: linear-gradient(90deg, var(--border-color), var(--turquoise), var(--border-color));
  }
  .fluxo-linha span { top: 50%; left: 0; animation-name: pacoteHorizontal; }
}

/* Celular de mentira da 3ª etapa, com o aviso que muda. */
.fluxo-celular {
  margin-top: 1.5rem;
  padding: 12px;
  border-radius: 22px;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
}
.fluxo-aviso {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--surface-2);
}
.fluxo-aviso-icone {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--turquoise-glow);
  color: var(--turquoise);
  font-size: 16px;
}
/* A cor troca na hora (sem a transição geral de cores), junto com a animação de chegada. */
.fluxo-aviso, .fluxo-aviso * { transition: none; }
.fluxo-aviso-titulo { font-size: 14px; font-weight: 800; color: var(--text-main); }
.fluxo-aviso-texto { font-size: 12px; color: var(--text-muted); }

.fluxo-aviso[data-tipo="queda"] { border-color: var(--accent-red); background: rgba(255, 90, 101, 0.12); }
.fluxo-aviso[data-tipo="queda"] .fluxo-aviso-icone { background: var(--accent-red); color: #FFFFFF; }
.fluxo-aviso[data-tipo="queda"] .fluxo-aviso-titulo { color: var(--accent-red); }
.fluxo-aviso[data-tipo="bem"] .fluxo-aviso-icone { background: rgba(34, 197, 94, 0.15); color: var(--accent-emerald); }

@keyframes avisoChega {
  0% { transform: translateY(-8px); opacity: 0.3; }
  100% { transform: translateY(0); opacity: 1; }
}
.fluxo-aviso.chegou { animation: avisoChega 0.45s ease-out; }

/* ===================== Efeitos de todas as páginas (components/efeitos.js) ===================== */
/* Brilho que segue o mouse em qualquer cartão. Os cartões com .efeito-luz também inclinam. */
.glass-card, .efeito-brilho { --luz-x: 50%; --luz-y: 50%; }
.glass-card:hover, .efeito-brilho:hover {
  background-image: radial-gradient(420px circle at var(--luz-x) var(--luz-y), var(--turquoise-glow), transparent 45%);
}
/* Enquanto inclina, o cartão segue o mouse rápido (sem o atraso da animação de entrada). */
.efeito-luz.inclinando {
  transition: transform 0.12s ease-out, border-color 0.3s ease, box-shadow 0.3s ease !important;
  transition-delay: 0s !important;
}

/* Entrada ao rolar: o cartão sobe e aparece quando chega na tela. */
.revelar {
  opacity: 0;
  transform: translateY(24px);
}
.revelar.visivel {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1) var(--atraso, 0ms),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1) var(--atraso, 0ms),
              border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Barra de leitura no topo das páginas compridas. */
.barra-leitura {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 300;
  pointer-events: none;
  transform-origin: left;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--turquoise), var(--teal-light));
  box-shadow: 0 0 10px var(--turquoise-glow);
  transition: opacity 0.3s ease;
}

/* Brilho que passa pelo botão principal quando o mouse fica em cima. */
.btn-primary { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  transform: translateX(-120%);
  pointer-events: none;
}
.btn-primary:hover::after { animation: brilhoBotao 0.9s ease; }
@keyframes brilhoBotao { to { transform: translateX(120%); } }

/* Fundo "aurora" das telas de entrada (login, cadastro, senha): luzes turquesa se mexendo devagar. */
.fundo-aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.fundo-aurora::before,
.fundo-aurora::after {
  content: "";
  position: absolute;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  background: var(--turquoise-glow);
  filter: blur(120px);
  animation: aurora 18s ease-in-out infinite alternate;
}
.fundo-aurora::before { top: -20vmax; left: -15vmax; }
.fundo-aurora::after { bottom: -25vmax; right: -15vmax; animation-delay: -9s; opacity: 0.8; }
@keyframes aurora {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(12vmax, 8vmax) scale(1.15); }
  100% { transform: translate(-6vmax, 14vmax) scale(0.95); }
}
/* ===================== Planos: botões Mensal / Anual (script.js: iniciarPlanos) ===================== */
.botao-periodo { color: var(--text-muted); font-weight: 700; transition: color 0.2s ease; }
.botao-periodo:hover { color: var(--text-main); }
.botao-periodo[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--turquoise) 0%, var(--turquoise-dark) 100%);
  color: #0A0A0A;
  font-weight: 900;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
/* ===================== Painel do tutor: leitura nova (dashboard_tutor.html) ===================== */
/* O cartão "bate" duas vezes, com um anel na cor da classificação da leitura. */
@keyframes leituraNova {
  0% { box-shadow: 0 0 0 0 var(--cor-leitura, var(--turquoise)); transform: scale(1); }
  20% { transform: scale(1.015); }
  100% { box-shadow: 0 0 0 18px transparent; transform: scale(1); }
}
.glass-card.leitura-nova { animation: leituraNova 0.7s ease-out 2; }

/* ===================== Painel do paciente: gráfico que se desenha (dashboard_paciente.html) ===================== */
/* A linha usa pathLength="1": o traço vai de "escondido" (1) a "inteiro" (0). Sem animação, já aparece inteira. */
.grafico-linha {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 6px rgba(46, 196, 196, 0.5));
  animation: desenharLinha 1.4s ease-out both;
}
@keyframes desenharLinha { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

.grafico-area { animation: aparecer 0.8s ease-out 0.9s both; }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

/* Cada ponto aparece quando a linha chega nele (o atraso vem do style de cada ponto). */
.grafico-ponto {
  transform-box: fill-box;
  transform-origin: center;
  animation: pontoChega 0.35s ease-out both;
}
@keyframes pontoChega { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
/* ===================== Faixa de custo da página inicial (index.html, seção #custo) ===================== */
/* As barras começam vazias e crescem até --largura quando a seção aparece (.reveal.active, components/efeitos.js). */
.custo-trilho {
  height: 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.custo-barra {
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 1.4s cubic-bezier(0.16, 1, 0.3, 1) 0.3s;
}
.reveal.active .custo-barra { width: var(--largura); }
.custo-barra-koavy {
  background: linear-gradient(90deg, var(--turquoise), var(--teal-light));
  box-shadow: 0 0 12px var(--turquoise-glow);
  min-width: 14px; /* a barra pequena continua visível mesmo em tela estreita */
}
.custo-barra-relogio { background: var(--text-dim); }
/* ===================== Reduzir movimento ===================== */
/* Vale para a opção do sistema e para a opção do botão de acessibilidade. */
html.a11y-sem-movimento { scroll-behavior: auto; }
html.a11y-sem-movimento *,
html.a11y-sem-movimento *::before,
html.a11y-sem-movimento *::after {
  animation: none !important;
  transition-duration: 0.01ms !important;
  transition-delay: 0s !important;
}
html.a11y-sem-movimento .reveal,
html.a11y-sem-movimento .revelar { opacity: 1; transform: none; }
html.a11y-sem-movimento .custo-barra { width: var(--largura); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
  .reveal, .revelar { opacity: 1; transform: none; }
  .custo-barra { width: var(--largura); }
}
