/* =====================================================================
   Páginas públicas e de acesso (cadastro, recuperação de senha,
   confirmação, anamnese pública, busca).

   São páginas que rodam fora da área logada e antes tinham cada uma o
   seu próprio :root duplicado. Aqui a identidade vem dos tokens.
   Mobile-first. Depende de tokens.css.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

.pub-page {
    margin: 0;
    padding: 1rem;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-family);
    color: var(--bg-text);
    background:
        radial-gradient(120% 70% at 100% 0%, var(--bg-accent-soft) 0%, transparent 55%),
        linear-gradient(180deg, var(--bg-surface), var(--bg-primary-soft) 90%);
    overflow-x: hidden;
}

/* Centraliza a coluna de conteúdo em qualquer largura */
.pub-wrap {
    width: 100%;
    max-width: 520px;
    margin-inline: auto;
    padding-block: 2rem;
}
.pub-wrap--wide { max-width: 720px; }

/* ---------- Marca ---------- */
.pub-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}
.pub-brand a { display: inline-flex; text-decoration: none; }
.pub-brand .bg-logo { height: 38px; width: auto; }

/* ---------- Card ---------- */
.pub-card {
    background: var(--bg-surface);
    padding: 2rem 1.5rem;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-pop);
}
.pub-card + .pub-card { margin-top: 1rem; }

.pub-card h1 {
    margin: 0 0 .4rem;
    font-size: clamp(1.4rem, 5vw, 1.75rem);
    font-weight: var(--font-bold);
    line-height: 1.2;
    color: var(--bg-ink);
}
.pub-card h2 {
    margin: 0 0 .75rem;
    font-size: 1.05rem;
    font-weight: var(--font-semi);
    color: var(--bg-ink);
}
.pub-sub {
    margin: 0 0 1.5rem;
    color: var(--bg-muted);
    font-size: .97rem;
    line-height: 1.6;
}

/* ---------- Card centrado (confirmação, ativação, sucesso) ---------- */
.pub-card--center { text-align: center; }
.pub-status-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 2.2rem;
}
.pub-status-icon--brand {
    background: var(--bg-gradient);
    color: #fff;
    border-radius: var(--radius-selo);
    box-shadow: var(--shadow-cta);
}
.pub-status-icon--ok    { background: var(--bg-success-bg); color: var(--bg-success); }
.pub-status-icon--warn  { background: var(--bg-warning-bg); color: var(--bg-warning); }
.pub-status-icon--err   { background: var(--bg-danger-bg);  color: var(--bg-danger); }
.pub-status-icon--info  { background: var(--bg-accent-soft); color: var(--bg-accent); }

/* ---------- Formulários ---------- */
.pub-field { margin-bottom: 1.15rem; }
.pub-field > label {
    display: block;
    margin-bottom: .4rem;
    font-size: .9rem;
    font-weight: var(--font-semi);
    color: var(--bg-ink);
}
.pub-field .req { color: var(--bg-primary); }

.pub-input-wrap { position: relative; }
.pub-input-wrap > i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bg-faint);
    z-index: 2;
    pointer-events: none;
}
.pub-input-wrap > i.fa-whatsapp { color: #25D366; }

.pub-page input[type="text"],
.pub-page input[type="email"],
.pub-page input[type="tel"],
.pub-page input[type="password"],
.pub-page input[type="date"],
.pub-page input[type="number"],
.pub-page select,
.pub-page textarea {
    width: 100%;
    min-height: 48px;
    padding: .75rem 1rem;
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-btn);
    background: var(--bg-surface);
    color: var(--bg-ink);
    font-family: inherit;
    font-size: 16px;              /* evita zoom automático no iOS */
    transition: border-color .2s, box-shadow .2s;
}
.pub-input-wrap input { padding-left: 44px !important; }

.pub-page input:focus,
.pub-page select:focus,
.pub-page textarea:focus {
    outline: 0;
    border-color: var(--bg-primary);
    box-shadow: 0 0 0 3px var(--bg-primary-ring);
}
.pub-page textarea { min-height: 110px; resize: vertical; }

.pub-hint {
    display: flex;
    gap: .55rem;
    margin: .6rem 0 0;
    padding: .7rem .9rem;
    background: var(--bg-primary-soft);
    border-radius: var(--radius-btn);
    font-size: .87rem;
    color: var(--bg-text);
    line-height: 1.55;
}
.pub-hint i { color: var(--bg-primary); margin-top: .15rem; flex-shrink: 0; }

/* ---------- Seleção em cartões (tipo de conta) ---------- */
.pub-choice { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1.35rem; }
.pub-choice input { position: absolute; opacity: 0; pointer-events: none; }
.pub-choice label {
    display: block;
    padding: 1.15rem .85rem;
    text-align: center;
    background: var(--bg-surface);
    border: 2px solid var(--bg-border);
    border-radius: var(--radius-card);
    cursor: pointer;
    transition: border-color .2s, background .2s, transform .15s;
}
.pub-choice label:hover { border-color: var(--bg-primary-light); transform: translateY(-1px); }
.pub-choice label i {
    display: block;
    margin-bottom: .5rem;
    font-size: 1.35rem;
    color: var(--bg-primary);
}
.pub-choice label strong {
    display: block;
    font-size: .95rem;
    font-weight: var(--font-semi);
    color: var(--bg-ink);
}
.pub-choice label small { display: block; margin-top: .15rem; color: var(--bg-muted); font-size: .82rem; }
/* Destaque do selecionado.
   Duas vias de propósito: `:checked + label` cobre o caso sem JS, e a
   classe .is-selected (aplicada pelo JS) garante o destaque mesmo quando
   o navegador não reavalia o combinador de irmão ao trocar o radio. */
.pub-choice input:checked + label,
.pub-choice label.is-selected {
    border-color: var(--bg-primary);
    background: var(--bg-primary-soft);
}
.pub-choice input:focus-visible + label { box-shadow: 0 0 0 3px var(--bg-primary-ring); }

/* ---------- Alertas ---------- */
.pub-alert {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    margin-bottom: 1.15rem;
    padding: .85rem 1rem;
    border-radius: var(--radius-btn);
    font-size: .92rem;
    line-height: 1.55;
}
.pub-alert i { margin-top: .15rem; flex-shrink: 0; }
.pub-alert--ok   { background: var(--bg-success-bg); color: var(--bg-success-ink); }
.pub-alert--err  { background: var(--bg-danger-bg);  color: var(--bg-danger-ink); }
.pub-alert--warn { background: var(--bg-warning-bg); color: var(--bg-warning-ink); }
.pub-alert--info { background: var(--bg-accent-soft); color: var(--bg-info-ink); }

/* ---------- Rodapé do card ---------- */
.pub-foot {
    margin-top: 1.35rem;
    text-align: center;
    font-size: .92rem;
    color: var(--bg-muted);
}
.pub-foot a { color: var(--bg-primary-deep); font-weight: var(--font-semi); text-decoration: none; }
.pub-foot a:hover { text-decoration: underline; }

.pub-terms {
    margin: 1.15rem 0 0;
    text-align: center;
    font-size: .82rem;
    color: var(--bg-muted);
    line-height: 1.6;
}
.pub-terms a { color: var(--bg-primary-deep); text-decoration: underline; }

/* Botão em bloco reaproveitando .bg-btn dos tokens */
.pub-card .bg-btn--block { margin-top: .35rem; }

@media (prefers-reduced-motion: reduce) {
    * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
