/* Registro de paciente (/registropaciente) */

:root {
    --brand: #1545CB;
    --brand-dark: #0f3496;
    --brand-soft: #e8eefc;
    --text: #1d2433;
    --muted: #5d6679;
    --border: #d5dbe6;
    --bg: #f3f6fb;
    --surface: #ffffff;
    --error: #c62828;
    --error-soft: #fdecec;
    --success: #1f8a4c;
    --whatsapp: #1fae55;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(21, 69, 203, .10), 0 2px 6px rgba(29, 36, 51, .06);
}

/* El atributo hidden siempre oculta, aunque la clase defina display (ej. .btn) */
[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

svg { width: 1em; height: 1em; fill: currentColor; flex-shrink: 0; }

/* Barra superior */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--brand);
    text-decoration: none;
}

.brand img { width: 36px; height: auto; }

.topbar-link {
    font-size: .9rem;
    color: var(--muted);
    text-decoration: none;
    text-align: right;
}

.topbar-link strong { color: var(--brand); }

/* Estructura */
.layout {
    display: grid;
    gap: 24px;
    max-width: 1040px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.intro h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
    line-height: 1.25;
}

.lead {
    margin: 0 0 20px;
    color: var(--muted);
}

.benefits {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.benefits li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .95rem;
}

.benefit-icon {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 20px;
    flex-shrink: 0;
}

/* Tarjeta del formulario */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 20px;
}

.card-title {
    margin: 0 0 4px;
    font-size: 1.3rem;
}

.card-subtitle {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: .95rem;
}

.form { display: grid; gap: 4px; }

.row { display: grid; gap: 4px; }

.field { display: grid; align-content: start; gap: 6px; margin-bottom: 12px; }

.field label {
    font-weight: 600;
    font-size: .9rem;
}

.field input {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    transition: border-color .15s, box-shadow .15s;
}

.field input::placeholder { color: #a3abbb; }

.field input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(21, 69, 203, .15);
}

.field input[aria-invalid="true"] {
    border-color: var(--error);
    background: #fffafa;
}

.field input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(198, 40, 40, .15); }

.field-hint {
    margin: 0;
    font-size: .82rem;
    color: var(--muted);
}

.field-error {
    margin: 0;
    font-size: .85rem;
    color: var(--error);
}

.field-error:empty { display: none; }

.field-error a { color: inherit; font-weight: 600; }

/* Prefijo +56 */
.input-prefix { display: flex; }

.input-prefix .prefix {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-right: 0;
    border-radius: 10px 0 0 10px;
}

.input-prefix input { border-radius: 0 10px 10px 0; }

/* Botón mostrar contraseña */
.input-action { position: relative; }

.input-action input { padding-right: 52px; }

.toggle-pass {
    position: absolute;
    top: 4px;
    right: 4px;
    bottom: 4px;
    width: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    font-size: 20px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.toggle-pass:hover, .toggle-pass[aria-pressed="true"] { color: var(--brand); background: var(--brand-soft); }

.toggle-pass:focus-visible { outline: 2px solid var(--brand); }

/* Mensaje general */
.alert {
    margin: 4px 0 12px;
    padding: 12px 14px;
    font-size: .92rem;
    color: var(--error);
    background: var(--error-soft);
    border-radius: 10px;
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 52px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color .15s, transform .05s;
}

.btn:active { transform: translateY(1px); }

.btn:focus-visible { outline: 3px solid rgba(21, 69, 203, .4); outline-offset: 2px; }

.btn-primary { color: #fff; background: var(--brand); }

.btn-primary:hover { background: var(--brand-dark); }

.btn-primary[disabled] { opacity: .75; cursor: progress; }

.btn-whatsapp {
    margin-top: 10px;
    min-height: 48px;
    font-weight: 600;
    font-size: .95rem;
    color: var(--whatsapp);
    background: transparent;
    border: 1.5px solid currentColor;
}

.btn-whatsapp svg { font-size: 20px; }

.btn-whatsapp:hover { background: #effaf3; }

.spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: girar .7s linear infinite;
}

.btn.is-loading .spinner { display: inline-block; }

@keyframes girar { to { transform: rotate(360deg); } }

/* Éxito */
.success { text-align: center; }

.success:focus { outline: none; }

.success-icon {
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
    font-size: 34px;
    color: #fff;
    background: var(--success);
    border-radius: 50%;
}

.products { margin-top: 28px; text-align: left; }

.products-title { margin: 0 0 10px; font-weight: 700; }

.products-strip {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 46%;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
}

.product {
    display: grid;
    gap: 6px;
    font-size: .85rem;
    color: var(--text);
    text-decoration: none;
    scroll-snap-align: start;
}

.product img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--bg);
    border-radius: 10px;
}

/* Tablet y escritorio */
@media (min-width: 640px) {
    .row { grid-template-columns: 1fr 1fr; gap: 0 16px; }
    .card { padding: 32px; }
    .products-strip { grid-auto-columns: calc((100% - 36px) / 4); }
}

@media (min-width: 900px) {
    .layout {
        grid-template-columns: 1fr 1.15fr;
        align-items: start;
        gap: 48px;
        padding-top: 56px;
    }
    .intro { position: sticky; top: 32px; padding-top: 16px; }
    .intro h1 { font-size: 2.2rem; }
    .lead { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation-duration: 1.5s !important; }
}

/* Autorización de datos en el registro (Ley 21.719) */
.autorizo { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 6px; padding: 12px 14px; font-size: .9rem; line-height: 1.45; color: var(--text); background: #f3f6fd; border: 1px solid #dfe6fb; border-radius: 12px; cursor: pointer; }
.autorizo input { flex-shrink: 0; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); }
.autorizo-nota { margin: 0 0 14px; font-size: .8rem; color: var(--muted); }

/* Correo: sugerencia de dominio ("¿Quisiste decir …?") y campo con botón "Cambiar" en el editor */
.sugerencia { color: #7a4b00; }
.sugerencia-correo { padding: 0; font: inherit; font-weight: 700; color: var(--brand); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.correo-cuenta { display: flex; gap: 8px; }
.correo-cuenta input { flex: 1; min-width: 0; }
.correo-cuenta .btn { width: auto; flex-shrink: 0; padding: 0 16px; }

/* Ingresar con Google (login y registro) y enlace a la política de privacidad */
.google-box { margin: 0 0 4px; }

.google-btn { display: flex; justify-content: center; min-height: 44px; }

.google-embebido { margin: 0; text-align: center; }

.google-box .alert { margin-top: 12px; }

.google-sep { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; font-size: .85rem; color: var(--muted); }

.google-sep::before, .google-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.google-conectado { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; padding: 12px 14px; font-size: .92rem; background: var(--brand-soft); border-radius: 10px; }

.google-conectado svg { flex-shrink: 0; width: 20px; height: 20px; }

.legal-link { margin: 18px 0 0; text-align: center; font-size: .85rem; }

.legal-link a { color: var(--muted); }

/* Campo bloqueado (correo de Google en el registro): que no parezca editable */
.field input[readonly] { color: var(--muted); background: var(--bg); cursor: default; }

.field input[readonly]:focus { border-color: var(--border); box-shadow: none; }
