/* =====================================================================
   NATUMEDI — Design system, animações e componentes
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --primary: #073D13;
  --primary-hover: #0B5220;
  --primary-dark: #052F0E;
  --primary-tint: #ECF7F0;
  --primary-glow: rgba(7, 61, 19, 0.28);

  --bg: #ECF0EE;
  --surface: #FFFFFF;
  --border: #D5DED8;
  --border-strong: #C0CDC4;
  --text: #0E1B14;
  --text-muted: #46584E;

  --c-linguagens: #EC4899;
  --c-matematica: #3B82F6;
  --c-natureza: #10B981;
  --c-humanas: #F97316;
  --c-redacao: #8B5CF6;

  --shadow-xs: 0 1px 2px rgba(16, 32, 26, 0.04);
  --shadow-sm: 0 1px 2px rgba(16, 32, 26, 0.04), 0 2px 8px -1px rgba(16, 32, 26, 0.06);
  --shadow-md: 0 6px 20px -4px rgba(16, 32, 26, 0.10), 0 2px 6px -2px rgba(16, 32, 26, 0.04);
  --shadow-lg: 0 18px 44px -12px rgba(16, 32, 26, 0.18), 0 4px 12px -4px rgba(16, 32, 26, 0.06);
  --ring: 0 0 0 3px rgba(7, 61, 19, 0.14);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Seleção ---- */
::selection { background: rgba(7, 61, 19, 0.16); color: #052F0E; }

/* ---- Títulos ---- */
h1, h2, h3 { letter-spacing: -0.022em; }

/* ---- Scrollbar customizada ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3d1c9; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #9db2a6; border: 2px solid transparent; background-clip: padding-box; }

/* ---- Foco acessível global ---- */
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 0.5rem; }

/* ---- Botões: transições e feedback de clique ---- */
button { transition: transform .12s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease; }
button:active:not(:disabled) { transform: translateY(1px) scale(0.995); }
button:disabled { cursor: not-allowed; }

/* Botões primários (qualquer <button class="bg-primary ...">) */
button.bg-primary { box-shadow: var(--shadow-sm); }
button.bg-primary:hover:not(:disabled) { box-shadow: var(--shadow-md); transform: translateY(-1px); }
button.bg-primary:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-sm); }

/* =====================================================================
   Animações
   ===================================================================== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-up { animation: fadeUp .5s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.animate-fade-in { animation: fadeIn .4s ease both; }

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.animate-scale-in { animation: scaleIn .25s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -40px) scale(1.1); }
  66%      { transform: translate(-20px, 20px) scale(0.9); }
}
.animate-blob { animation: blob 14s ease-in-out infinite; }
.animation-delay-2000 { animation-delay: 2s; }
.animation-delay-4000 { animation-delay: 4s; }

@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 var(--primary-glow); }
  70%  { box-shadow: 0 0 0 12px rgba(7, 61, 19, 0); }
  100% { box-shadow: 0 0 0 0 rgba(7, 61, 19, 0); }
}
.animate-pulse-ring { animation: pulseRing 2s infinite; }

@keyframes countUp { from { opacity: 0; } to { opacity: 1; } }
.animate-count { animation: countUp .6s ease-out both; }

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.shimmer {
  background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes confetti-fall {
  0%   { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
.confetti-piece {
  position: fixed;
  top: 0;
  width: 10px;
  height: 14px;
  z-index: 9999;
  animation: confetti-fall 3s linear forwards;
}

/* =====================================================================
   Componentes
   ===================================================================== */

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

/* ---- Flashcard flip ---- */
.flip-card { perspective: 1200px; }
.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip-back { transform: rotateY(180deg); }

/* ---- Estados de alternativas ---- */
.alt-correct {
  background: #ECFDF5 !important;
  border-color: #10B981 !important;
  color: #065F46 !important;
}
.alt-incorrect {
  background: #FEF2F2 !important;
  border-color: #EF4444 !important;
  color: #991B1B !important;
}

/* ---- Blobs decorativos de fundo ---- */
.bg-blob {
  position: absolute;
  border-radius: 9999px;
  filter: blur(60px);
  opacity: .22;
  pointer-events: none;
}

/* ---- Mapa mental ---- */
.mm-node {
  transition: all .2s ease;
  cursor: pointer;
}
.mm-node:hover { transform: scale(1.04); }
.mm-node.central { background: var(--primary); color: #fff; }
.mm-node.topico { background: #DBEAFE; color: #1E40AF; }
.mm-node.detalhe { background: #F1F5F9; color: #334155; }
.mm-connector { stroke: #cbd5e1; stroke-width: 2; }

/* ---- Tipografia de questões (markdown básico) ---- */
.question-text { line-height: 1.72; color: #1A2620; }
.question-text strong { font-weight: 650; }
.question-text img { max-width: 100%; border-radius: 8px; margin: 8px 0; }

/* ---- Inputs ---- */
.input-base {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border-strong);
  background: #fff;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.input-base::placeholder { color: #7c8a82; }
.input-base:hover { border-color: #b6c6bc; }
.input-base:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.input-base:disabled { background: #f1f5f2; color: #9aa8a0; cursor: not-allowed; }

select.input-base { cursor: pointer; }

/* ---- Tooltip ---- */
.tooltip { position: relative; }
.tooltip:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 50;
}

/* ---- Toasts ---- */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 10000; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: #10201a;
  color: #fff;
  padding: .8rem 1.25rem;
  border-radius: .85rem;
  border-left: 3px solid #10B981;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(0.16, 1, 0.3, 1) both;
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .875rem;
  font-weight: 500;
  max-width: 20rem;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Linhas de progresso ---- */
.progress-bar {
  transition: width .55s cubic-bezier(0.16, 1, 0.3, 1);
  background-image: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.18) 100%);
}

/* ---- Spinner ---- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Cursor de "digitando" da IA */
.typing-dot { width: 6px; height: 6px; background: #94a3b8; border-radius: 50%; display: inline-block; animation: blink 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---- Estados vazios ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #6b7a72;
  padding: 2.5rem 1.5rem;
}

/* ---- Sidebar (profundidade sutil) ---- */
.sidebar-surface {
  background:
    radial-gradient(120% 80% at 20% -10%, rgba(255, 255, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--primary) 0%, #062F10 100%);
}
