/* =========================================================
   Inicio de sesión y registro de pacientes
   Usa las variables de style.css (--primary, --accent, ...)
   ========================================================= */

.auth-page {
    min-height: calc(100vh - 82px);
    display: grid;
    grid-template-columns: minmax(300px, 5fr) 7fr;
    background: var(--background);
}

.auth-page--single {
    grid-template-columns: 1fr;
    justify-items: center;
    align-items: start;
    padding: 48px 20px 72px;
    background: linear-gradient(120deg, #f0f7fb, #f7fafc 60%);
}

/* ---------- Panel lateral (solo en login) ---------- */
.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    padding: 64px 9%;
    color: var(--white);
    background-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cpath d='M36 28v16M28 36h16' stroke='%23ffffff' stroke-opacity='.07' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.auth-aside img {
    width: 84px;
    height: 84px;
    object-fit: contain;
    padding: 8px;
    border-radius: 18px;
    background: var(--white);
}

.auth-aside h2 {
    margin: 0;
    max-width: 14ch;
    font-size: clamp(30px, 3.2vw, 42px);
    line-height: 1.12;
    letter-spacing: -0.5px;
}

.auth-aside p {
    margin: 0;
    max-width: 34ch;
    font-size: 16px;
    line-height: 1.6;
    color: #cfe3ee;
}

/* ---------- Columna del formulario ---------- */
.auth-main {
    display: grid;
    place-items: center;
    padding: 48px 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 36px 34px 32px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(18, 61, 90, 0.08);
}

.auth-card--wide {
    max-width: 760px;
    padding: 40px 44px 36px;
}

.auth-card h1 {
    margin: 0 0 6px;
    font-size: 28px;
    letter-spacing: -0.3px;
    color: var(--primary);
}

.auth-lead {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.5;
}

/* ---------- Campos ---------- */
.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.auth-field label,
.auth-legend {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="tel"],
.auth-field input[type="password"],
.auth-field select {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--white);
    border: 1px solid #c5d3dd;
    border-radius: 9px;
    transition: border-color .15s, box-shadow .15s;
}

.auth-field select {
    appearance: none;
    padding-right: 38px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
}

.auth-field input::placeholder {
    color: #9aaab6;
}

.auth-field input:focus,
.auth-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 138, 157, 0.22);
}

.auth-field .is-invalid {
    border-color: #c8382b;
}

.auth-field .is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(200, 56, 43, 0.18);
}

.auth-error {
    min-height: 0;
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: #b42318;
}

.auth-error:empty {
    display: none;
}

.auth-hint {
    margin: 0;
    font-size: 12.5px;
    color: var(--muted);
}

.auth-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 20px;
}

.auth-row-doc {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 12px;
}

.auth-col-full {
    grid-column: 1 / -1;
}

/* ---------- Contraseña con ojo ---------- */
.auth-pw {
    position: relative;
}

.auth-pw input {
    padding-right: 50px !important;
}

.auth-pw-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.auth-pw-toggle:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.auth-pw-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.auth-pw-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-pw-toggle .icon-off,
.auth-pw-toggle[aria-pressed="true"] .icon-on {
    display: none;
}

.auth-pw-toggle[aria-pressed="true"] .icon-off {
    display: block;
}

/* ---------- Reglas de contraseña ---------- */
.auth-rules {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--muted);
}

.auth-rules li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.auth-rules li::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #c5d3dd;
    transition: all .15s;
}

.auth-rules li.is-ok {
    color: #1d7a5a;
}

.auth-rules li.is-ok::before {
    border-color: #1d7a5a;
    background: #1d7a5a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center / 80% no-repeat;
}

/* ---------- Secciones del registro ---------- */
.auth-section {
    margin: 30px 0 0;
    padding: 26px 0 0;
    border: 0;
    border-top: 1px solid var(--border);
}

.auth-section h2 {
    margin: 0 0 16px;
    font-size: 18px;
    color: var(--primary);
}

/* ---------- Casilla de términos ---------- */
.auth-field label.auth-check,
.auth-check {
    font-weight: 400;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.45;
    cursor: pointer;
}

.auth-check input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.auth-linkbtn {
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--accent);
    background: none;
    border: 0;
    text-decoration: underline;
    cursor: pointer;
}

.auth-linkbtn:hover {
    color: var(--primary);
}

/* ---------- Botones ---------- */
.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 48px;
    padding: 0 20px;
    font: inherit;
    font-size: 15px;
    font-weight: 650;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}

.auth-btn:focus-visible {
    outline: 3px solid rgba(43, 138, 157, 0.45);
    outline-offset: 2px;
}

.auth-btn-primary {
    color: var(--white);
    background: var(--primary);
}

.auth-btn-primary:hover {
    background: #0d2f45;
}

.auth-btn-primary:disabled {
    opacity: .7;
    cursor: progress;
}

.auth-btn-outline {
    color: var(--primary);
    background: var(--white);
    border-color: var(--primary);
}

.auth-btn-outline:hover {
    background: var(--primary-light);
}

.auth-btn-google {
    color: var(--text);
    background: var(--white);
    border-color: #c5d3dd;
}

.auth-btn-google:hover {
    background: var(--background);
    border-color: #9db3c2;
}

.auth-btn-google svg {
    width: 20px;
    height: 20px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 22px 0;
    font-size: 13px;
    color: var(--muted);
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-note {
    margin: 10px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
    text-align: center;
    color: var(--muted);
}

.auth-register {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.auth-register p {
    margin: 0 0 12px;
    font-size: 15px;
    color: var(--text);
}

.auth-submit {
    margin-top: 26px;
}

.auth-back {
    margin: 18px 0 0;
    font-size: 14px;
    text-align: center;
    color: var(--muted);
}

.auth-back a {
    font-weight: 600;
    color: var(--accent);
}

.auth-back a:hover {
    text-decoration: underline;
}

/* ---------- Avisos ---------- */
.auth-alert {
    margin: 0 0 20px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.45;
    border-radius: 9px;
    border: 1px solid;
}

.auth-alert--error {
    color: #8f1d12;
    background: #fdecea;
    border-color: #f5c2bd;
}

.auth-alert--ok {
    color: #135d43;
    background: #e7f6ef;
    border-color: #b7e2d0;
}

/* ---------- Calendario de fecha de nacimiento ---------- */
.dp {
    position: relative;
}

.dp input {
    padding-right: 50px !important;
}

.dp-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.dp-toggle:hover,
.dp-toggle[aria-expanded="true"] {
    color: var(--primary);
    background: var(--primary-light);
}

.dp-toggle:focus-visible {
    outline: 2px solid var(--accent);
}

.dp-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dp-popup {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    width: 308px;
    max-width: calc(100vw - 40px);
    padding: 14px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(18, 61, 90, 0.18);
}

.dp-popup[hidden] {
    display: none;
}

.dp-head {
    display: grid;
    grid-template-columns: 34px 1fr 84px 34px;
    gap: 6px;
    margin-bottom: 10px;
}

.dp-nav {
    display: grid;
    place-items: center;
    height: 34px;
    padding: 0;
    color: var(--primary);
    background: var(--primary-light);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.dp-nav:hover:not(:disabled) {
    background: #d6e8f1;
}

.dp-nav:disabled {
    opacity: .35;
    cursor: default;
}

.dp-nav svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dp-head select {
    height: 34px;
    padding: 0 6px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--white);
    border: 1px solid #c5d3dd;
    border-radius: 8px;
    cursor: pointer;
}

.dp-week,
.dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.dp-week span {
    padding: 4px 0 6px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.dp-day {
    height: 36px;
    padding: 0;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.dp-day:hover:not(:disabled) {
    background: var(--primary-light);
}

.dp-day:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.dp-day:disabled {
    color: #b9c6d0;
    cursor: default;
}

.dp-day.is-today {
    border-color: var(--accent);
}

.dp-day.is-selected,
.dp-day.is-selected:hover {
    color: var(--white);
    background: var(--primary);
    border-color: var(--primary);
}

.dp-foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.dp-foot button {
    padding: 6px 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.dp-foot button:hover {
    background: var(--primary-light);
}

/* ---------- Diálogo de términos ---------- */
.auth-dialog {
    width: min(560px, calc(100vw - 32px));
    padding: 28px;
    color: var(--text);
    border: 0;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(18, 61, 90, 0.35);
}

.auth-dialog::backdrop {
    background: rgba(18, 61, 90, 0.55);
}

.auth-dialog h2 {
    margin: 0 0 12px;
    font-size: 20px;
    color: var(--primary);
}

.auth-dialog p {
    margin: 0 0 12px;
    font-size: 14.5px;
    line-height: 1.6;
}

.auth-dialog .auth-btn {
    margin-top: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        padding: 34px 7%;
        gap: 14px;
    }

    .auth-aside img {
        width: 60px;
        height: 60px;
    }

    .auth-aside h2 {
        max-width: none;
        font-size: 26px;
    }

    .auth-main {
        padding: 28px 16px 48px;
    }
}

@media (max-width: 640px) {
    .auth-card,
    .auth-card--wide {
        padding: 28px 20px 26px;
    }

    .auth-grid {
        grid-template-columns: 1fr;
    }

    .auth-row-doc {
        grid-template-columns: 1fr;
    }

    .auth-page--single {
        padding: 24px 12px 56px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
