/* ============================================================
   FORMULARIO DE PACIENTE — Liquid Glass
   Vista única, compacta y sin scroll interno.
   Se apoya en las clases existentes (.patient-form-card,
   .patient-form-grid, .patient-field) sin romper sus IDs.
   ============================================================ */

.patient-form-card {
    --pf-glass: rgba(255, 255, 255, .62);
    --pf-glass-strong: rgba(255, 255, 255, .78);
    --pf-stroke: rgba(255, 255, 255, .7);
    --pf-hairline: rgba(15, 23, 42, .08);
    --pf-ink: #0f172a;
    --pf-muted: #64748b;
    --pf-accent: #0a84ff;

    position: relative;
    padding: 0 !important;
    overflow: hidden;
    isolation: isolate;
    border: 1px solid var(--pf-hairline) !important;
    border-radius: 26px !important;
    background:
        linear-gradient(150deg, rgba(255, 255, 255, .75), rgba(255, 255, 255, .5)),
        radial-gradient(120% 90% at 8% -10%, rgba(10, 132, 255, .18), transparent 60%),
        radial-gradient(100% 80% at 100% 0%, rgba(52, 199, 190, .16), transparent 62%),
        #eef2f7 !important;
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    box-shadow:
        0 24px 60px -28px rgba(15, 23, 42, .38),
        inset 0 1px 0 rgba(255, 255, 255, .85) !important;
}

/* Reflejo superior tipo cristal */
.patient-form-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 42%;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, .5), transparent);
    z-index: 0;
}

.patient-form-card>* {
    position: relative;
    z-index: 1;
}

/* ---------- Encabezado ---------- */
.pf-head {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, .25));
    border-bottom: 1px solid var(--pf-hairline);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
}

.pf-head-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(160deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .55));
    border: 1px solid rgba(255, 255, 255, .9);
    box-shadow: 0 6px 16px -8px rgba(15, 23, 42, .45), inset 0 1px 0 #fff;
}

.pf-head-icon .material-symbols-outlined {
    font-size: 22px;
    background: linear-gradient(150deg, #0a84ff, #34c7be);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.pf-head-text {
    display: block;
    flex: 1;
    min-width: 0;
}

/* Blindaje: reglas globales (p. ej. .patient-form-title .material-symbols-outlined
   en styles.css) pintaban un recuadro oscuro detrás del icono de cada botón. */
.patient-form-card button .material-symbols-outlined {
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    /* El glifo trae métricas propias: sin esto queda descentrado en el círculo */
    display: block;
    width: 1em;
    height: 1em;
    line-height: 1 !important;
    font-size: 18px;
    text-align: center;
    vertical-align: middle;
    overflow: visible;
}

.pf-head-text h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -.015em;
    color: var(--pf-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pf-head-text p {
    margin: 1px 0 0;
    font-size: .74rem;
    font-weight: 600;
    color: var(--pf-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pf-head-close {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    padding: 0;
    box-sizing: border-box;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--pf-muted);
    background: rgba(255, 255, 255, .6);
    border: 1px solid var(--pf-hairline);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all .2s;
}

.pf-head-close:hover {
    background: #fff;
    color: var(--pf-ink);
    transform: scale(1.06);
}

/* Botón de dictado por voz (inyectado por JS en el header, junto al de cerrar) */
.patient-form-card #btn-paciente-smart-voice {
    all: unset;
    box-sizing: border-box;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    cursor: pointer;
    color: #0a6fd8;
    background: rgba(255, 255, 255, .6);
    border: 1px solid rgba(10, 132, 255, .28);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9);
    transition: transform .2s cubic-bezier(.4, 0, .2, 1), background .2s, color .2s, border-color .2s;
}

.patient-form-card #btn-paciente-smart-voice:hover {
    background: #0a84ff;
    border-color: #0a84ff;
    color: #fff;
    transform: scale(1.06);
}

.patient-form-card #btn-paciente-smart-voice:active {
    transform: scale(.94);
}

.patient-form-card #btn-paciente-smart-voice .material-symbols-outlined {
    font-size: 18px;
    line-height: 1;
}

.patient-form-card #btn-paciente-smart-voice.is-listening {
    background: #ff453a;
    border-color: #ff453a;
    color: #fff;
    animation: pfListenPulse 1.5s ease-out infinite;
}

@keyframes pfListenPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 69, 58, .5);
    }

    70% {
        box-shadow: 0 0 0 9px rgba(255, 69, 58, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 69, 58, 0);
    }
}

/* ---------- Barra de estado RIPS ---------- */
.pf-rips-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 9px 18px;
    border-bottom: 1px solid var(--pf-hairline);
    background: linear-gradient(180deg, rgba(255, 247, 237, .8), rgba(255, 247, 237, .45));
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    backdrop-filter: blur(16px) saturate(160%);
    transition: background .3s;
}

.pf-rips-bar.is-ok {
    background: linear-gradient(180deg, rgba(232, 250, 242, .85), rgba(232, 250, 242, .45));
}

.pf-rips-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .8);
    border: 1px solid rgba(251, 146, 60, .35);
    color: #c2410c;
}

.pf-rips-bar.is-ok .pf-rips-icon {
    border-color: rgba(16, 185, 129, .35);
    color: #047857;
}

.pf-rips-icon .material-symbols-outlined {
    font-size: 16px;
}

.pf-rips-text {
    flex: 1;
    min-width: 160px;
    font-size: .77rem;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #9a3412;
}

.pf-rips-bar.is-ok .pf-rips-text {
    color: #065f46;
}

.pf-rips-progress {
    width: 96px;
    height: 6px;
    border-radius: 99px;
    background: rgba(15, 23, 42, .1);
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, .12);
}

.pf-rips-progress span {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #ff9f0a, #ff6b35);
    transition: width .4s cubic-bezier(.4, 0, .2, 1);
}

.pf-rips-bar.is-ok .pf-rips-progress span {
    background: linear-gradient(90deg, #30d158, #34c7be);
}

.pf-rips-count {
    font-size: .7rem;
    font-weight: 800;
    color: #9a3412;
    font-variant-numeric: tabular-nums;
}

.pf-rips-bar.is-ok .pf-rips-count {
    color: #065f46;
}

/* Chips de campos faltantes (clic = ir al campo) */
.pf-rips-missing {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
}

.pf-rips-missing:empty {
    display: none;
}

.pf-chip-missing {
    border: 1px solid rgba(251, 146, 60, .45);
    background: rgba(255, 255, 255, .8);
    color: #9a3412;
    border-radius: 99px;
    padding: 2px 10px;
    font-size: .68rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: all .18s;
}

.pf-chip-missing:hover {
    background: #ea580c;
    border-color: #ea580c;
    color: #fff;
    transform: translateY(-1px);
}

.pf-chip-missing .material-symbols-outlined {
    font-size: 12px;
}

/* ---------- Cuerpo: 2 columnas, sin scroll propio ---------- */
.pf-body {
    padding: 12px 18px 2px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
}

/* La identidad ocupa el ancho completo; el resto se reparte */
.pf-body>.pf-from-cita,
.pf-body>.pf-section:first-of-type {
    grid-column: 1 / -1;
}

.pf-section {
    border: 1px solid var(--pf-hairline);
    border-radius: 18px;
    background: linear-gradient(160deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .42));
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    backdrop-filter: blur(18px) saturate(170%);
    box-shadow: 0 8px 22px -18px rgba(15, 23, 42, .5), inset 0 1px 0 rgba(255, 255, 255, .8);
    overflow: hidden;
}

.pf-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .6), rgba(255, 255, 255, .2));
    border-bottom: 1px solid var(--pf-hairline);
}

.pf-section-num {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #0a84ff, #34c7be);
    color: #fff;
    font-size: .64rem;
    font-weight: 800;
    box-shadow: 0 3px 8px -4px rgba(10, 132, 255, .8);
}

.pf-section-head h5 {
    margin: 0;
    font-size: .72rem;
    font-weight: 800;
    color: var(--pf-ink);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.pf-section-hint {
    margin-left: auto;
    font-size: .63rem;
    font-weight: 600;
    color: #94a3b8;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 45%;
}

.pf-section-body {
    padding: 9px 12px 11px;
}

/* ---------- Campos compactos ---------- */
.patient-form-card .patient-form-grid {
    gap: 7px 8px;
}

.patient-form-card .patient-form-grid input,
.patient-form-card .patient-form-grid select {
    height: 33px;
    padding: 5px 10px;
    font-size: .82rem;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, .12);
    background: rgba(255, 255, 255, .78);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: all .18s;
}

.patient-form-card .patient-form-grid textarea {
    min-height: 40px !important;
    padding: 7px 10px;
    font-size: .82rem;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, .12);
    background: rgba(255, 255, 255, .78);
    width: 100%;
}

.patient-form-card .patient-form-grid input:focus,
.patient-form-card .patient-form-grid select:focus,
.patient-form-card .patient-form-grid textarea:focus {
    border-color: var(--pf-accent);
    background: #fff;
    box-shadow: 0 0 0 3.5px rgba(10, 132, 255, .16);
    outline: none;
}

.patient-form-card .patient-field label {
    margin: 0 0 2px 3px;
    font-size: .66rem;
    font-weight: 750;
    letter-spacing: .015em;
    color: #5b6879;
    text-transform: uppercase;
}

.patient-form-card .patient-field .patient-hint {
    margin-top: 2px;
    font-size: .63rem;
    color: #94a3b8;
    font-weight: 550;
    letter-spacing: 0;
    text-transform: none;
}

/* Marca de obligatorio */
.patient-field label .pf-req {
    color: #ff453a;
    font-weight: 900;
    margin-left: 2px;
}

.patient-field label .pf-tag-rips {
    display: inline-block;
    margin-left: 5px;
    padding: 0 5px;
    border-radius: 5px;
    background: rgba(10, 132, 255, .12);
    color: #0a6fd8;
    font-size: .55rem;
    font-weight: 800;
    letter-spacing: .05em;
    vertical-align: middle;
}

/* Campo con error tras intentar guardar */
.patient-form-card .patient-form-grid .pf-invalid,
.patient-form-card .patient-form-grid .pf-invalid:focus {
    border-color: #ff453a !important;
    background: rgba(255, 241, 240, .9);
    box-shadow: 0 0 0 3.5px rgba(255, 69, 58, .16) !important;
}

@keyframes pfFieldPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(10, 132, 255, 0);
    }

    35% {
        box-shadow: 0 0 0 6px rgba(10, 132, 255, .28);
    }
}

.pf-focus-pulse {
    animation: pfFieldPulse 1s ease-out 2;
}

/* Botón de escanear cédula, junto al número de documento */
.pf-icon-btn {
    width: 33px;
    height: 33px;
    flex: 0 0 33px;
    padding: 0;
    box-sizing: border-box;
    display: grid;
    place-items: center;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid rgba(15, 23, 42, .12);
    background: rgba(255, 255, 255, .8);
    color: #0a6fd8;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: all .18s;
}

.pf-icon-btn:hover {
    background: #0a84ff;
    border-color: #0a84ff;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px -7px rgba(10, 132, 255, .9);
}

.pf-icon-btn .material-symbols-outlined {
    font-size: 18px;
}

/* Aviso paciente venido de citas */
.pf-from-cita {
    display: none;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(235, 245, 255, .85), rgba(235, 245, 255, .5));
    border: 1px solid rgba(10, 132, 255, .22);
    color: #0a5cb8;
    font-size: .75rem;
    font-weight: 650;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.pf-from-cita.is-visible {
    display: flex;
}

.pf-from-cita .material-symbols-outlined {
    font-size: 17px;
}

/* ---------- Pie ---------- */
.pf-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    border-top: 1px solid var(--pf-hairline);
    background: linear-gradient(180deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, .6));
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    flex-wrap: wrap;
}

.pf-foot-note {
    flex: 1;
    min-width: 170px;
    font-size: .69rem;
    color: var(--pf-muted);
    font-weight: 600;
}

.pf-btn-cancel {
    padding: 9px 20px;
    border-radius: 99px;
    font-weight: 700;
    font-size: .82rem;
    cursor: pointer;
    background: rgba(255, 255, 255, .7);
    border: 1px solid var(--pf-hairline);
    color: var(--pf-muted);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all .2s;
}

.pf-btn-cancel:hover {
    background: #fff;
    color: var(--pf-ink);
}

.pf-btn-save {
    padding: 10px 26px;
    border-radius: 99px;
    font-weight: 750;
    font-size: .84rem;
    letter-spacing: -.01em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: linear-gradient(165deg, #0a84ff, #0a6fd8 60%, #34c7be);
    border: 1px solid rgba(255, 255, 255, .28);
    color: #fff;
    box-shadow: 0 10px 24px -12px rgba(10, 132, 255, .95), inset 0 1px 0 rgba(255, 255, 255, .4);
    cursor: pointer;
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
}

.pf-btn-save:hover {
    transform: translateY(-1.5px);
    box-shadow: 0 14px 30px -12px rgba(10, 132, 255, 1), inset 0 1px 0 rgba(255, 255, 255, .5);
}

.pf-btn-save:active {
    transform: scale(.98);
}

.pf-btn-save .material-symbols-outlined {
    font-size: 19px;
}

/* ---------- Aviso en tarjeta de cita ---------- */
.cita-card-rips-warn {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    padding: 6px 11px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 247, 237, .9), rgba(255, 247, 237, .6));
    border: 1px solid rgba(251, 146, 60, .35);
    color: #9a3412;
    font-size: .73rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all .18s;
}

.cita-card-rips-warn:hover {
    border-color: #fb923c;
    transform: translateX(2px);
}

.cita-card-rips-warn .material-symbols-outlined {
    font-size: 16px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .pf-body {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 820px) {
    .patient-form-card {
        border-radius: 20px !important;
    }

    .pf-body {
        padding: 10px 12px 2px;
    }

    .pf-head,
    .pf-foot {
        padding: 11px 13px;
    }

    .pf-rips-bar {
        padding: 9px 13px;
    }

    .pf-head-text p {
        display: none;
    }

    .pf-foot-note {
        order: 3;
        flex-basis: 100%;
    }

    .pf-btn-cancel,
    .pf-btn-save {
        flex: 1;
    }
}

/* ---------- Modo oscuro ---------- */
[data-theme="dark"] .patient-form-card {
    --pf-hairline: rgba(255, 255, 255, .1);
    --pf-ink: #f1f5f9;
    --pf-muted: #94a3b8;
    border-color: rgba(255, 255, 255, .1) !important;
    background:
        linear-gradient(150deg, rgba(30, 41, 59, .8), rgba(15, 23, 42, .7)),
        radial-gradient(120% 90% at 8% -10%, rgba(10, 132, 255, .22), transparent 60%),
        #0b1220 !important;
    box-shadow: 0 24px 60px -28px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .1) !important;
}

[data-theme="dark"] .patient-form-card::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, .07), transparent);
}

[data-theme="dark"] .pf-head,
[data-theme="dark"] .pf-foot {
    background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02));
}

[data-theme="dark"] .pf-section {
    background: linear-gradient(160deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .03));
}

[data-theme="dark"] .pf-section-head {
    background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .01));
}

[data-theme="dark"] .pf-head-icon,
[data-theme="dark"] .pf-head-close,
[data-theme="dark"] .pf-icon-btn,
[data-theme="dark"] .pf-btn-cancel {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .12);
    color: #cbd5e1;
}

[data-theme="dark"] .patient-form-card .patient-form-grid input,
[data-theme="dark"] .patient-form-card .patient-form-grid select,
[data-theme="dark"] .patient-form-card .patient-form-grid textarea {
    background: rgba(15, 23, 42, .6);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, .12);
}

[data-theme="dark"] .patient-form-card .patient-field label {
    color: #94a3b8;
}

[data-theme="dark"] .pf-rips-bar {
    background: linear-gradient(180deg, rgba(120, 53, 15, .35), rgba(120, 53, 15, .15));
}

[data-theme="dark"] .pf-rips-bar.is-ok {
    background: linear-gradient(180deg, rgba(6, 78, 59, .4), rgba(6, 78, 59, .15));
}

[data-theme="dark"] .pf-rips-text,
[data-theme="dark"] .pf-rips-count {
    color: #fdba74;
}

[data-theme="dark"] .pf-rips-bar.is-ok .pf-rips-text,
[data-theme="dark"] .pf-rips-bar.is-ok .pf-rips-count {
    color: #6ee7b7;
}

[data-theme="dark"] .pf-rips-icon,
[data-theme="dark"] .pf-chip-missing {
    background: rgba(255, 255, 255, .1);
    color: #fdba74;
}

[data-theme="dark"] .pf-from-cita {
    background: rgba(10, 132, 255, .16);
    border-color: rgba(10, 132, 255, .3);
    color: #93c5fd;
}

[data-theme="dark"] .patient-form-card #btn-paciente-smart-voice {
    background: rgba(10, 132, 255, .18);
    border-color: rgba(10, 132, 255, .35);
    color: #7cc0ff;
}

[data-theme="dark"] .patient-form-card #btn-paciente-smart-voice.is-listening {
    background: #ff453a;
    border-color: #ff453a;
    color: #fff;
}

[data-theme="dark"] .cita-card-rips-warn {
    background: rgba(120, 53, 15, .3);
    border-color: rgba(251, 146, 60, .35);
    color: #fdba74;
}

@media (prefers-reduced-motion: reduce) {

    .patient-form-card *,
    .pf-focus-pulse {
        animation: none !important;
        transition-duration: .01ms !important;
    }
}
