/* frontend/styles/rp.css
   Indicação RP — Premium Dark + ícone-first.
   Spec: 2026-05-15-redesign-app-gestor-design.md §4.
   Sem framework. Mobile-first. Anima só transform/opacity. */

/* =========================================================
   1) TOKENS
   ========================================================= */
:root {
  --rp-void:     #060606;
  --rp-surface:  #0E0E0F;
  --rp-surface2: #161618;
  --rp-line:     rgba(255,255,255,0.08);
  --rp-line-2:   rgba(255,255,255,0.16);
  --rp-ink:      #FFFFFF;
  --rp-ink-2:    rgba(255,255,255,0.65);
  --rp-ink-3:    rgba(255,255,255,0.40);

  --rp-st-novo:    #8A8A8A;
  --rp-st-analise: #C9A227;
  --rp-st-qualif:  #3FB950;
  --rp-st-desq:    #E5484D;
  --rp-st-conv:    #4C8DFF;

  --rp-glow: radial-gradient(120% 60% at 50% 0%, rgba(255,255,255,0.045), transparent 70%);
  --rp-elev: 0 8px 24px rgba(0,0,0,0.4);

  /* Espaçamento (base 4) */
  --rp-xs: 4px;  --rp-sm: 8px;  --rp-md: 12px; --rp-base: 16px;
  --rp-lg: 20px; --rp-xl: 24px; --rp-2xl: 32px; --rp-3xl: 48px; --rp-4xl: 64px;

  /* Cantos */
  --rp-r-card:  14px;
  --rp-r-input: 12px;
  --rp-r-pill:  999px;

  /* Tipografia */
  --rp-font-display: 'Playfair Display', Georgia, serif;
  --rp-font-ui:      'Inter', system-ui, -apple-system, sans-serif;
  --rp-font-mono:    'IBM Plex Mono', Menlo, monospace;
}

/* =========================================================
   2) RESET
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--rp-font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--rp-ink);
  background: var(--rp-void);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: var(--rp-ink); text-decoration: none; }
::selection { background: var(--rp-line-2); }

/* =========================================================
   3) TIPOGRAFIA
   ========================================================= */
h1, h2, h3, h4 {
  font-family: var(--rp-font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
.font-mono { font-family: var(--rp-font-mono); letter-spacing: 0.02em; }
.t-text-2 { color: var(--rp-ink-2); }
.t-text-3 { color: var(--rp-ink-3); }
.t-small  { font-size: 14px; }
.t-tiny   { font-size: 12px; }
.upper { text-transform: uppercase; letter-spacing: 0.08em; }

/* =========================================================
   4) GLOW / MOTIVO GRÁFICO
   ========================================================= */
.rp-glow {
  position: absolute; inset: 0 0 auto 0; height: 280px;
  background: var(--rp-glow);
  pointer-events: none; z-index: 0;
}
.rp-lines { display: block; margin: 0 auto; }
.rp-lines path {
  stroke: var(--rp-ink); stroke-width: 1.5; fill: none;
  stroke-dasharray: 120; stroke-dashoffset: 120;
}
.rp-lines.drawn path { stroke-dashoffset: 0; transition: stroke-dashoffset 600ms ease; }

/* =========================================================
   5) BOTÕES
   ========================================================= */
.btn-primary {
  width: 100%;
  min-height: 56px;
  padding: 16px 22px;
  background: linear-gradient(180deg, #FFFFFF 0%, #E8E8E8 100%);
  color: #060606;
  border-radius: var(--rp-r-pill);
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  min-height: 56px;
  padding: 16px 22px;
  background: var(--rp-surface2);
  color: var(--rp-ink);
  border: 1px solid var(--rp-line-2);
  border-radius: var(--rp-r-pill);
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 0.12s ease;
}
.btn-secondary:active { transform: scale(0.97); }

.btn-link {
  background: none;
  color: var(--rp-ink-2);
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 8px 0;
  font-size: 15px;
}

.btn-wa {
  width: 100%;
  min-height: 56px;
  background: #25D366;
  color: #06140B;
  border-radius: var(--rp-r-pill);
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 0.12s ease;
}
.btn-wa:active { transform: scale(0.97); }

/* CTA com respiração sutil */
.btn-breathe { animation: rp-breathe 4s ease-in-out infinite; }
@keyframes rp-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.015); }
}

/* Botão grande de escolha (Sim/Não/Não sei) */
.choice-grid { display: grid; gap: var(--rp-md); }
.choice-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.choice-btn {
  min-height: 96px;
  background: var(--rp-surface2);
  border: 1px solid var(--rp-line);
  border-radius: var(--rp-r-card);
  color: var(--rp-ink);
  font-size: 18px;
  font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}
.choice-btn:active { transform: scale(0.97); }
.choice-btn.selected {
  border-color: var(--rp-ink);
  background: #1F1F22;
}
.choice-btn svg { color: var(--rp-ink-2); }
.choice-btn.selected svg { color: var(--rp-ink); }

/* =========================================================
   6) CARD / SURFACE
   ========================================================= */
.card {
  background: var(--rp-surface);
  border: 1px solid var(--rp-line);
  border-radius: var(--rp-r-card);
  padding: var(--rp-base);
}
.card-elev { box-shadow: var(--rp-elev); }
.card-item {
  background: var(--rp-surface2);
  border: 1px solid var(--rp-line);
  border-radius: var(--rp-r-card);
  padding: var(--rp-base);
}

/* =========================================================
   7) INPUTS
   ========================================================= */
.input, textarea.input, select.input {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border: 1px solid var(--rp-line);
  border-radius: var(--rp-r-input);
  background: var(--rp-surface2);
  color: var(--rp-ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
textarea.input { min-height: 96px; }
.input:focus {
  border-color: var(--rp-line-2);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}
.input::placeholder { color: var(--rp-ink-3); }
select.input { appearance: none; -webkit-appearance: none; }

.field { display: block; margin-bottom: var(--rp-base); }
.field-with-icon { position: relative; }
.field-with-icon .field-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--rp-ink-3); pointer-events: none; transition: color 0.18s ease;
}
.field-with-icon .input { padding-left: 48px; }
.field-with-icon .input:focus ~ .field-icon { color: var(--rp-ink-2); }

.label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--rp-ink-2);
}
.field-error { color: var(--rp-st-desq); font-size: 14px; margin-top: 6px; }

/* Shake amigável de validação */
.shake { animation: rp-shake 0.4s ease; }
@keyframes rp-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* =========================================================
   8) STATUS (pílulas)
   ========================================================= */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--rp-r-pill);
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--rp-line);
}
.pill svg { width: 14px; height: 14px; }
.pill.st-novo            { color: var(--rp-st-novo);    border-color: rgba(138,138,138,0.4); }
.pill.st-em_analise      { color: var(--rp-st-analise); border-color: rgba(201,162,39,0.4); }
.pill.st-qualificado     { color: var(--rp-st-qualif);  border-color: rgba(63,185,80,0.4); }
.pill.st-desqualificado  { color: var(--rp-st-desq);    border-color: rgba(229,72,77,0.4); }
.pill.st-convertido      { color: var(--rp-st-conv);    border-color: rgba(76,141,255,0.4); }
.pill.selectable { cursor: pointer; transition: transform 0.12s ease; }
.pill.selectable:active { transform: scale(0.95); }
.pill.selected { background: var(--rp-surface2); border-color: var(--rp-line-2); }

/* =========================================================
   9) AVATAR (iniciais)
   ========================================================= */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--rp-surface2);
  border: 1px solid var(--rp-line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; color: var(--rp-ink-2);
  flex-shrink: 0;
}
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }

/* =========================================================
   10) KPI / NÚMERO GIGANTE
   ========================================================= */
.kpi-hero {
  font-family: var(--rp-font-display);
  font-size: 88px; line-height: 1; font-weight: 600;
  text-align: center;
}
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--rp-md); }
.kpi-card {
  background: var(--rp-surface);
  border: 1px solid var(--rp-line);
  border-radius: var(--rp-r-card);
  padding: var(--rp-base);
  display: flex; align-items: center; gap: var(--rp-md);
}
.kpi-card .kpi-icon { color: var(--rp-ink-2); }

/* Painel admin (Plan C) — classes próprias do dashboard, não redesenhado */
.kpi-number {
  font-family: var(--rp-font-display);
  font-size: 56px; line-height: 1;
  color: var(--rp-ink); text-align: center;
}
.kpi-cell {
  background: var(--rp-surface);
  border: 1px solid var(--rp-line);
  border-radius: var(--rp-r-card);
  padding: var(--rp-base);
}
.kpi-cell .label { color: var(--rp-ink-3); font-size: 13px; }
.kpi-cell .value {
  font-family: var(--rp-font-display);
  font-size: 32px; line-height: 1.1; color: var(--rp-ink);
}
.status-dot {
  display: inline-block; width: 9px; height: 9px;
  border-radius: 50%; vertical-align: middle;
  background: var(--rp-st-novo);
}
.status-dot.status-novo           { background: var(--rp-st-novo); }
.status-dot.status-em_analise     { background: var(--rp-st-analise); }
.status-dot.status-qualificado    { background: var(--rp-st-qualif); }
.status-dot.status-desqualificado { background: var(--rp-st-desq); }
.status-dot.status-convertido     { background: var(--rp-st-conv); }
.kpi-card .kpi-val  { font-family: var(--rp-font-display); font-size: 30px; font-weight: 600; line-height: 1; }
.kpi-card .kpi-lbl  { font-size: 13px; color: var(--rp-ink-3); }

/* =========================================================
   11) CHIPS DE FILTRO
   ========================================================= */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-filter {
  flex-shrink: 0;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--rp-line);
  border-radius: var(--rp-r-pill);
  background: var(--rp-surface2);
  font-size: 15px; font-weight: 500;
  color: var(--rp-ink-2);
  transition: transform 0.12s ease;
}
.chip-filter:active { transform: scale(0.95); }
.chip-filter.active {
  background: var(--rp-ink);
  color: var(--rp-void);
  border-color: var(--rp-ink);
}

/* =========================================================
   12) TOAST
   ========================================================= */
.toast {
  position: fixed;
  bottom: 88px; left: 50%;
  transform: translateX(-50%);
  background: var(--rp-surface2);
  border: 1px solid var(--rp-line-2);
  color: var(--rp-ink);
  padding: 14px 20px;
  border-radius: var(--rp-r-pill);
  font-size: 15px;
  z-index: 1000;
  box-shadow: var(--rp-elev);
}
.toast.error { border-color: rgba(229,72,77,0.5); color: var(--rp-st-desq); }
.toast.success { border-color: rgba(63,185,80,0.5); }

/* =========================================================
   13) SKELETON
   ========================================================= */
.skel {
  background: linear-gradient(90deg, var(--rp-surface) 25%, var(--rp-surface2) 37%, var(--rp-surface) 63%);
  background-size: 400% 100%;
  animation: rp-shimmer 1.4s ease infinite;
  border-radius: var(--rp-r-input);
}
@keyframes rp-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
.skel-line { height: 16px; margin: 10px 0; }
.skel-card { height: 84px; margin-bottom: var(--rp-md); }

/* =========================================================
   14) LAYOUT HELPERS
   ========================================================= */
.stack > * + * { margin-top: var(--rp-base); }
.stack-sm > * + * { margin-top: var(--rp-sm); }
.stack-md > * + * { margin-top: var(--rp-md); }
.row { display: flex; gap: var(--rp-md); align-items: center; }
.row-between { display: flex; gap: var(--rp-md); align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.mt-sm { margin-top: var(--rp-sm); }
.mt-base { margin-top: var(--rp-base); }
.mt-xl   { margin-top: var(--rp-xl); }
.mt-2xl  { margin-top: var(--rp-2xl); }
.mt-3xl  { margin-top: var(--rp-3xl); }
.mb-base { margin-bottom: var(--rp-base); }
.hidden { display: none !important; }

/* =========================================================
   15) APP LAYOUT
   ========================================================= */
.app-shell { min-height: 100vh; padding-bottom: 76px; }
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--rp-void);
  padding: var(--rp-base);
  /* iPhone notch / Dynamic Island: empurra o header pra baixo da status bar
     (status-bar-style=black-translucent faz o conteúdo ir atrás dela) */
  padding-top: calc(var(--rp-base) + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
}
.app-header .icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--rp-ink-2);
}
.app-body {
  position: relative;
  padding: var(--rp-base);
  max-width: 600px;
  margin: 0 auto;
}
.app-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--rp-surface);
  border-top: 1px solid var(--rp-line);
  display: flex;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
}
.app-bottom-nav button {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: var(--rp-ink-3);
}
.app-bottom-nav button svg { color: var(--rp-ink-3); }
.app-bottom-nav button span { display: none; }
.app-bottom-nav button.active { color: var(--rp-ink); }
.app-bottom-nav button.active svg { color: var(--rp-ink); }
.app-bottom-nav button.active span { display: block; }

/* Login screen */
.login-screen {
  position: relative;
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: var(--rp-2xl) var(--rp-base);
  /* Respeita notch/Dynamic Island do iPhone (PWA standalone) */
  padding-top: calc(var(--rp-2xl) + env(safe-area-inset-top));
  padding-bottom: calc(var(--rp-2xl) + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
}
.login-screen > * { position: relative; z-index: 1; }

/* Topbar de etapa (Novo Lead) */
.step-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--rp-xl);
}
.step-dots { display: flex; gap: 8px; }
.step-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--rp-line-2);
  transition: background 0.2s ease, transform 0.2s ease;
}
.step-dot.done { background: var(--rp-ink-2); }
.step-dot.now  { background: var(--rp-ink); transform: scale(1.25); }
.step-guide-icon {
  width: 64px; height: 64px; margin: 0 auto var(--rp-base);
  color: var(--rp-ink-2);
}
.upload-bar-track {
  height: 6px; background: var(--rp-surface2);
  border-radius: var(--rp-r-pill); overflow: hidden; margin-top: 8px;
}
.upload-bar-fill {
  height: 100%; width: 0%;
  background: var(--rp-ink);
  transition: width 0.2s ease;
}

/* Slot de câmera (etapa 5) */
.cam-slot {
  position: relative;
  min-height: 120px;
  background: var(--rp-surface2);
  border: 1px dashed var(--rp-line-2);
  border-radius: var(--rp-r-card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--rp-ink-3);
  overflow: hidden;
}
.cam-slot.filled { border-style: solid; border-color: rgba(63,185,80,0.5); color: var(--rp-ink-2); }
.cam-slot input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.cam-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-slot .cam-check {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--rp-st-qualif); color: #06140B;
  display: flex; align-items: center; justify-content: center;
}

.offline-banner {
  background: rgba(201,162,39,0.15);
  border: 1px solid rgba(201,162,39,0.4);
  color: var(--rp-st-analise);
  border-radius: var(--rp-r-input);
  padding: 12px 16px; font-size: 14px;
  text-align: center;
}

/* =========================================================
   16) PREFERS-REDUCED-MOTION (desliga TUDO)
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .rp-lines path { stroke-dashoffset: 0 !important; }
}
