/* Sementes MVP — estilos (mobile-first KYC) */

:root {
  --bg: #050508;
  --surface: #0C0C14;
  --card: #12121E;
  --border: #1E1E32;
  --teal: #00F5E0;
  --coral: #FF5757;
  --amber: #FFB020;
  --violet: #9B6DFF;
  --mint: #3DFFA0;
  --sky: #4DB8FF;
  --rose: #FF4D9B;
  --text: #F0EDFF;
  --muted: #555580;
  --dim: #1A1A2E;

  /* Detection state colors (KYC-style ring) */
  --st-red: #FF5757;
  --st-yellow: #FFB020;
  --st-green: #3DFFA0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', 'Georgia', monospace;
  position: relative;
  overflow-x: hidden;
}

/* During live/capturing/cooldown, lock viewport scroll on mobile to keep
   everything in one screen. Result phase reabilita scroll. */
body[data-phase="live"],
body[data-phase="capturing"],
body[data-phase="cooldown"],
body[data-phase="requesting"] {
  overflow: hidden;
  height: 100dvh;
}

.hidden { display: none !important; }

/* ─── BACKGROUND ─────────────────────────────────────────────────────── */
.bg-glow {
  position: fixed; top: -150px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 400px;
  background: radial-gradient(ellipse, rgba(0,245,224,0.07), transparent 70%);
  pointer-events: none; z-index: 0;
}
.bg-glow-2 {
  position: fixed; inset: 0;
  pointer-events: none;
  transition: background 1s; z-index: 0;
}

/* ─── HEADER ─────────────────────────────────────────────────────────── */
.header {
  position: relative; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-emoji { font-size: 20px; }
.logo-text { font-size: 13px; font-weight: 900; letter-spacing: -0.3px; }
.badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); padding: 5px 12px;
  border-radius: 20px; border: 1px solid var(--border);
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.badge-dot.active { background: var(--mint); animation: pulse 1.2s infinite; }
.badge-text { font-size: 10px; color: var(--muted); font-weight: 700; }
.badge-text.active { color: var(--mint); }

/* ─── CONSENT ────────────────────────────────────────────────────────── */
.consent-screen {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  min-height: calc(100dvh - 60px);
}
.consent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 22px;
  max-width: 540px; width: 100%;
}
.consent-icon { font-size: 36px; margin-bottom: 12px; }
.consent-card h1 {
  margin: 0 0 12px;
  font-size: 22px; font-weight: 900;
  color: var(--teal);
}
.consent-lead { margin: 0 0 16px; font-size: 13px; line-height: 1.6; color: var(--text); }
.consent-list {
  margin: 0 0 20px; padding-left: 20px;
  font-size: 12px; line-height: 1.7; color: var(--muted);
}
.consent-list li { margin-bottom: 6px; }
.consent-list strong { color: var(--text); }
.consent-list em { color: var(--amber); font-style: normal; font-weight: 700; }
.consent-check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px;
  background: var(--dim); border-radius: 10px;
  margin-bottom: 16px;
  cursor: pointer;
  font-size: 12px; color: var(--text);
  line-height: 1.5;
}
.consent-check input { margin-top: 2px; cursor: pointer; }
.consent-foot {
  margin: 14px 0 0; text-align: center;
  font-size: 10px; color: var(--muted);
}
.consent-foot code {
  background: var(--dim); padding: 1px 6px;
  border-radius: 4px; color: var(--teal);
}

body[data-phase="consent"] #appMain { display: none; }
body:not([data-phase="consent"]) .consent-screen { display: none; }

/* ─── CONTAINER ──────────────────────────────────────────────────────── */
.container {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1100px; margin: 0 auto;
  width: 100%;
}

/* ─── LEFT PANEL (CAMERA) ────────────────────────────────────────────── */
.left-panel {
  display: flex; flex-direction: column;
  gap: 10px; align-items: center;
  width: 100%;
}

/* Status text dinamico (KYC instruction line) */
.status-line {
  width: 100%;
  max-width: min(420px, 92vw);
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: clamp(12px, 3.4vw, 14px);
  font-weight: 700;
  text-align: center;
  color: var(--muted);
  transition: color 0.3s, border-color 0.3s, background 0.3s;
  min-height: 42px;
}
.status-line .status-emoji { font-size: 16px; }
.status-line[data-detection="no-face"]   { color: var(--st-red);    border-color: rgba(255, 87, 87, 0.4);  background: rgba(255, 87, 87, 0.06); }
.status-line[data-detection="detecting"] { color: var(--st-yellow); border-color: rgba(255, 176, 32, 0.4); background: rgba(255, 176, 32, 0.06); }
.status-line[data-detection="locked"]    { color: var(--st-green);  border-color: rgba(61, 255, 160, 0.5); background: rgba(61, 255, 160, 0.08); }

/* Camera wrap responsivo */
.camera-wrap {
  width: 100%;
  max-width: min(420px, 92vw);
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  background: #000;
  border: 3px solid var(--border);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 0 transparent;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
.camera-wrap[data-detection="no-face"] {
  border-color: var(--st-red);
  box-shadow: 0 0 0 4px rgba(255, 87, 87, 0.18), 0 0 28px rgba(255, 87, 87, 0.25);
}
.camera-wrap[data-detection="detecting"] {
  border-color: var(--st-yellow);
  box-shadow: 0 0 0 4px rgba(255, 176, 32, 0.20), 0 0 28px rgba(255, 176, 32, 0.30);
}
.camera-wrap[data-detection="locked"] {
  border-color: var(--st-green);
  box-shadow: 0 0 0 4px rgba(61, 255, 160, 0.25), 0 0 32px rgba(61, 255, 160, 0.40);
  animation: lockedPulse 1.6s ease-in-out infinite;
}

@keyframes lockedPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(61, 255, 160, 0.25), 0 0 32px rgba(61, 255, 160, 0.40); }
  50%      { box-shadow: 0 0 0 6px rgba(61, 255, 160, 0.35), 0 0 44px rgba(61, 255, 160, 0.55); }
}

#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
  z-index: 1;
  display: block;
}
body[data-phase="live"] #video,
body[data-phase="capturing"] #video,
body[data-phase="result"] #video,
body[data-phase="cooldown"] #video,
body[data-phase="requesting"] #video { opacity: 1; }

#meshCanvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* Overlay genérico — usado em intro/error/requesting */
.overlay {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  background: rgba(5, 5, 8, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.overlay-emoji { font-size: 44px; margin-bottom: 10px; }
.overlay p { margin: 0; font-size: 13px; color: var(--text); line-height: 1.6; }
.overlay.error-overlay p { color: var(--coral); font-weight: 700; }
.text-coral { color: var(--coral) !important; }

/* Cooldown timer (canto sup. dir. da camera-wrap) */
.cooldown-timer {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 5;
  background: rgba(5, 5, 8, 0.7);
  backdrop-filter: blur(4px);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 800;
  color: var(--amber);
  letter-spacing: 0.5px;
  border: 1px solid rgba(255, 176, 32, 0.35);
  pointer-events: none;
}

/* Mini live tech badge (substitui o badge grande) */
.tech-mini {
  position: absolute;
  bottom: 8px; left: 8px;
  z-index: 5;
  font-size: 9px;
  color: var(--mint);
  background: rgba(5,5,8,0.6);
  backdrop-filter: blur(4px);
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid rgba(61, 255, 160, 0.3);
  font-weight: 700;
  letter-spacing: 0.4px;
  pointer-events: none;
}

/* Intro hero (mostrado em fase=intro) */
.intro-hero {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 10px;
}
.intro-hero .intro-emoji { font-size: 56px; }
.intro-hero h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--teal);
}
.intro-hero p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 280px;
}

/* Models loading state */
.models-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0;
}

/* ─── RIGHT PANEL ────────────────────────────────────────────────────── */
.right-panel {
  width: 100%;
  display: flex; flex-direction: column;
}
.title-block { margin-bottom: 14px; }
.kicker {
  margin: 0 0 2px;
  font-size: 10px; color: var(--muted);
  letter-spacing: 1px; font-weight: 700;
}
.title-block h2 {
  margin: 0;
  font-size: 18px; font-weight: 900;
  line-height: 1.25;
}
.title-block .accent { color: var(--teal); }
.subtitle {
  margin: 6px 0 0;
  font-size: 12px; color: var(--muted);
  line-height: 1.55;
}

.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.card-title {
  margin: 0 0 10px;
  font-size: 10px; color: var(--muted);
  font-weight: 800; letter-spacing: 1px;
}
.mode-tag {
  font-size: 9px;
  color: var(--teal);
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

.emotion-row {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 6px;
}
.emotion-emoji {
  font-size: 16px; width: 22px;
  text-align: center; flex-shrink: 0;
}
.emotion-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--dim);
  border-radius: 99px;
  overflow: hidden;
}
.emotion-bar {
  height: 100%; width: 0%;
  border-radius: 99px;
  transition: width 0.25s cubic-bezier(.34, 1.1, .64, 1);
}
.emotion-pct {
  font-size: 11px; font-weight: 800;
  width: 36px; text-align: right;
  flex-shrink: 0;
}

.result-cards {
  display: flex; gap: 8px; margin-bottom: 14px;
  flex-wrap: wrap;
}
.result-card {
  flex: 1;
  min-width: 140px;
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
}
.result-card-head {
  display: flex; align-items: center;
  gap: 8px; margin-bottom: 4px;
}
.result-card-icon { font-size: 16px; }
.result-card-label {
  font-size: 10px; color: var(--muted);
  font-weight: 700; letter-spacing: 0.5px;
}
.result-card-value {
  font-size: 18px; font-weight: 900;
  line-height: 1;
}
.result-card-sub {
  font-size: 10px; color: var(--muted);
  margin-top: 3px;
}

.ai-loading {
  display: flex; align-items: center;
  gap: 10px; padding: 12px 0;
  font-size: 12px; color: var(--muted);
}
.spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--dim);
  border-top: 2px solid var(--teal);
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.ai-block { display: flex; flex-direction: column; gap: 10px; }
.ai-greeting {
  border-left: 3px solid var(--teal);
  padding-left: 10px;
  font-size: 13px;
  font-style: italic;
  line-height: 1.55;
  color: var(--text);
}
.ai-interp {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.ai-box {
  border: 1px solid;
  border-radius: 10px;
  padding: 10px 12px;
}
.ai-box-label {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.ai-box-text {
  margin: 0;
  font-size: 12px;
  color: var(--text);
}

.tech-badges {
  display: flex; gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tech-badge {
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--dim);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Botões grandes (mobile-friendly) */
.btn {
  width: 100%;
  min-height: 56px;
  padding: 14px 18px;
  border-radius: 14px;
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  font-family: monospace;
  margin-top: 6px;
  letter-spacing: 0.3px;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--teal), rgba(61, 255, 160, 0.6)); color: #001815; }
.btn-error   { background: linear-gradient(135deg, var(--coral), rgba(255, 176, 32, 0.7)); }
.btn-violet  { background: linear-gradient(135deg, var(--violet), rgba(255, 77, 155, 0.6)); }

/* CTA wrap — mantém o botão sempre acessivel sem scroll na fase intro/error/cooldown */
.cta-wrap {
  width: 100%;
  max-width: min(420px, 92vw);
  margin: 0 auto;
}

/* Cooldown screen helper text */
.cooldown-msg {
  text-align: center;
  font-size: 13px;
  color: var(--coral);
  font-weight: 700;
  line-height: 1.55;
  padding: 14px 8px;
}
.cooldown-msg .cooldown-emoji { font-size: 36px; display: block; margin-bottom: 8px; }
.cooldown-msg small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

@keyframes spin   { to { transform: rotate(360deg); } }
@keyframes pulse  { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────── */

/* Tablet — 2 colunas, câmera 60% / análise 40% */
@media (min-width: 768px) {
  .container {
    grid-template-columns: 60% 1fr;
    gap: 20px;
    padding: 20px;
  }
  .left-panel { align-items: flex-start; }
  .camera-wrap { max-width: 100%; }
  .status-line { max-width: 100%; }
  .cta-wrap { max-width: 100%; }
}

/* Desktop — 50/50 */
@media (min-width: 1024px) {
  .container {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    padding: 28px;
  }
  .header { padding: 16px 28px; }
  .title-block h2 { font-size: 20px; }
  .camera-wrap { max-width: 480px; }
  .left-panel { gap: 12px; }
}

/* Mobile fine-tune (<480px) */
@media (max-width: 480px) {
  .header { padding: 10px 14px; }
  .logo-text { font-size: 12px; }
  .badge-text { font-size: 9px; }
  .container { padding: 12px; gap: 12px; }
  .camera-wrap {
    max-width: 100%;
    /* Em telas muito pequenas, deixa o aspect-ratio adaptar pra
       garantir que tudo cabe em 100dvh com hero+status+cta. */
    aspect-ratio: auto;
    height: 58dvh;
    min-height: 320px;
  }
  .title-block { margin-bottom: 8px; }
  .title-block h2 { font-size: 17px; }
  .subtitle { font-size: 11px; }
  body[data-phase="live"] .right-panel,
  body[data-phase="capturing"] .right-panel,
  body[data-phase="cooldown"] .right-panel {
    /* Em mobile durante live, esconde o painel direito (análise vem só
       no result). Viewport fica 100% pra câmera + status + nada mais. */
    display: none;
  }
  body[data-phase="live"] .container,
  body[data-phase="capturing"] .container,
  body[data-phase="cooldown"] .container,
  body[data-phase="requesting"] .container {
    grid-template-rows: auto;
    align-content: start;
    min-height: calc(100dvh - 50px);
  }
}

/* Em mobile na fase intro/error: mostrar só a coluna esquerda + CTA */
@media (max-width: 767px) {
  body[data-phase="intro"] .right-panel { display: none; }
  body[data-phase="error"] .right-panel { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   DISCLAIMER — limitações da análise (Barrett 2019, LGPD, EU AI Act)
   ═══════════════════════════════════════════════════════════════════ */
.ai-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin: 12px 0;
  background: rgba(255, 176, 32, 0.08);
  border: 1px solid rgba(255, 176, 32, 0.3);
  border-left: 3px solid #FFB020;
  border-radius: 8px;
}
.ai-disclaimer .disclaimer-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 176, 32, 0.18);
  color: #FFB020;
  font-weight: bold;
  font-size: 14px;
}
.ai-disclaimer p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: rgba(240, 237, 255, 0.82);
}
.ai-disclaimer strong { color: #FFB020; }
.ai-disclaimer em { font-style: italic; color: rgba(240, 237, 255, 0.95); }
