/* ==========================================================================
   Base compartilhada (página pública + painel): tokens, temas, formulários,
   botões, modal/folha inferior, toast. A cor da marca vem do servidor em --brand.
   ========================================================================== */

:root {
  --brand: #7c3aed;
  --on-brand: #ffffff;
  --brand-soft: color-mix(in srgb, var(--brand) 12%, var(--surface));
  --brand-line: color-mix(in srgb, var(--brand) 35%, var(--border));

  --bg: #f5f4f8;
  --surface: #ffffff;
  --surface-2: #f8f7fb;
  --border: #e7e5ee;
  --text: #17151f;
  --muted: #6b6879;
  --star: #f5b301;
  --star-empty: #dcd9e4;
  --ok: #12a150;
  --danger: #e5484d;
  --warn: #f59e0b;
  --shadow-sm: 0 1px 2px rgb(23 21 31 / 0.06);
  --shadow: 0 10px 30px -12px rgb(23 21 31 / 0.18);
  --shadow-lg: 0 24px 60px -20px rgb(23 21 31 / 0.35);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0c12;
    --surface: #17151f;
    --surface-2: #1d1b27;
    --border: #2b2838;
    --text: #f2f0f7;
    --muted: #a19db0;
    --star-empty: #3a3648;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 10px 30px -12px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 24px 60px -20px rgb(0 0 0 / 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0c12;
  --surface: #17151f;
  --surface-2: #1d1b27;
  --border: #2b2838;
  --text: #f2f0f7;
  --muted: #a19db0;
  --star-empty: #3a3648;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 10px 30px -12px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 24px 60px -20px rgb(0 0 0 / 0.8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
p { margin: 0; }
[hidden] { display: none !important; }

.i { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 26px; height: 26px; }

.so-leitor {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 700; font-size: 15px; text-decoration: none;
  cursor: pointer; user-select: none;
  transition: transform 0.15s ease-out, background-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primario { background: var(--brand); color: var(--on-brand); box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn-primario:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn-secundario { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secundario:hover:not(:disabled) { border-color: var(--brand-line); background: var(--surface-2); }
.btn-fantasma { background: transparent; color: var(--muted); }
.btn-fantasma:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-perigo { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.btn-perigo:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 20%, var(--surface)); }
.btn-google { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-whats { background: #25d366; color: #0b2e17; }
.btn-bloco { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-icone { width: 42px; min-height: 42px; padding: 0; border-radius: 50%; }
.btn .carregando { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: girar 0.7s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- formulários ---------- */
.campo { display: grid; gap: 6px; }
.campo + .campo { margin-top: 14px; }
.rotulo { font-size: 13px; font-weight: 700; color: var(--text); }
.ajuda { font-size: 12.5px; color: var(--muted); }
.entrada {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.entrada::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.entrada:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
textarea.entrada { min-height: 110px; resize: vertical; line-height: 1.5; }
select.entrada { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 40px; }
.isca { position: absolute; left: -5000px; width: 1px; height: 1px; opacity: 0; }

/* senha com olhinho */
.senha { position: relative; }
.senha .entrada { padding-right: 52px; }
.senha .olhinho {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
}
.senha .olhinho:hover { color: var(--text); background: var(--surface); }

.forca { display: flex; gap: 4px; margin-top: 2px; }
.forca span { flex: 1; height: 4px; border-radius: 4px; background: var(--border); transition: background-color 0.2s; }
.forca[data-nivel="1"] span:nth-child(-n+1) { background: var(--danger); }
.forca[data-nivel="2"] span:nth-child(-n+2) { background: var(--warn); }
.forca[data-nivel="3"] span:nth-child(-n+3) { background: #84cc16; }
.forca[data-nivel="4"] span { background: var(--ok); }

/* interruptor */
.chave { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; cursor: pointer; }
.chave + .chave { border-top: 1px solid var(--border); }
.chave input { position: absolute; opacity: 0; pointer-events: none; }
.chave .trilho { position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--border); transition: background-color 0.2s; }
.chave .trilho::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.2s ease-out; }
.chave input:checked + .trilho { background: var(--brand); }
.chave input:checked + .trilho::after { transform: translateX(18px); }
.chave input:focus-visible + .trilho { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

.erro-form { padding: 10px 14px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); font-size: 13.5px; font-weight: 600; }

.sugestoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.sugestoes button { text-align: left; line-height: 1.3; min-height: 32px; padding: 6px 12px; border-radius: 16px; border: 1px dashed var(--brand-line); background: var(--brand-soft); color: var(--text); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sugestoes button:active { transform: scale(0.96); }
.acoes-form { display: grid; gap: 10px; margin-top: 20px; }

/* ---------- estrelas ---------- */
.estrelas { display: inline-flex; gap: 2px; color: var(--star); }
.estrelas .vazia { color: var(--star-empty); }

/* ---------- modal / folha inferior ---------- */
.fundo-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgb(10 9 14 / 0.55); backdrop-filter: blur(4px);
  animation: aparecer 0.2s ease-out;
}
.modal {
  position: relative; width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto;
  padding: 28px 22px calc(22px + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-lg);
  animation: subir 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.modal::before { content: ""; position: absolute; top: 10px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--border); }
.modal-fechar { position: absolute; top: 14px; right: 14px; }
.modal h2 { font-size: 22px; margin-bottom: 6px; padding-right: 40px; }
.modal .sub { color: var(--muted); margin-bottom: 20px; }
@media (min-width: 640px) {
  .fundo-modal { align-items: center; padding: 24px; }
  .modal { border-radius: 28px; animation-name: surgir; }
  .modal::before { display: none; }
}
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
@keyframes surgir { from { transform: translateY(12px) scale(0.98); opacity: 0; } }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  background: var(--text); color: var(--bg); border-radius: 999px; box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: 14px; animation: subir 0.25s ease-out;
}
.toast.erro { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
