/* ==========================================
   NOTAS DE EVOLUCIÓN — Liquid Glass
   Panel de seguimiento (.nev-panel, dentro de cada módulo clínico)
   y formulario de firma (#nev-modal). Ver js/modules/notas-evolucion.js
   ========================================== */

.nev-panel, #nev-modal {
    --nev-spring: cubic-bezier(.22, 1, .36, 1);
    --nev-accent: var(--glass-primary, #4f46e5);
    --nev-text: #0f172a;
    --nev-muted: #64748b;
    --nev-card: rgba(255, 255, 255, .5);
    --nev-line: rgba(148, 163, 184, .35);
}
[data-theme="dark"] .nev-panel, [data-theme="dark"] #nev-modal {
    --nev-text: #e2e8f0;
    --nev-muted: #94a3b8;
    --nev-card: rgba(30, 41, 59, .5);
    --nev-line: rgba(148, 163, 184, .22);
}

/* ---------- Panel dentro del expediente (sin blur: vive sobre otros vidrios) ---------- */
.nev-panel {
    margin: 0 0 12px;
    border: 1px solid var(--nev-line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--nev-accent) 7%, var(--nev-card));
    color: var(--nev-text);
    overflow: hidden;
}
.nev-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.nev-toggle {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
    background: none; border: 0; padding: 4px; cursor: pointer; color: inherit; text-align: left;
}
.nev-toggle > .material-symbols-outlined:first-child { color: var(--nev-accent); }
.nev-toggle b { display: block; font-size: .9rem; }
.nev-toggle small { display: block; color: var(--nev-muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nev-toggle > span:nth-child(2) { min-width: 0; flex: 1; }
.nev-chevron { margin-left: auto; transition: transform .35s var(--nev-spring); }
.nev-panel.is-open .nev-chevron { transform: rotate(180deg); }

.nev-primary, .nev-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    height: 36px; padding: 0 14px; border-radius: 10px; cursor: pointer;
    font-weight: 800; font-size: .8rem; white-space: nowrap;
    transition: transform .3s var(--nev-spring), box-shadow .3s var(--nev-spring), opacity .2s;
}
.nev-primary .material-symbols-outlined, .nev-ghost .material-symbols-outlined { font-size: 18px; }
.nev-primary {
    border: 0; color: #fff;
    background: linear-gradient(135deg, color-mix(in srgb, var(--nev-accent) 92%, transparent), color-mix(in srgb, var(--glass-primary-deep, #3730a3) 92%, transparent));
    box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--nev-accent) 80%, transparent);
}
.nev-ghost { border: 1px solid var(--nev-line); background: var(--nev-card); color: var(--nev-text); }
.nev-ghost[data-nev-print], .nev-ghost[data-nev-wa] { padding: 0 9px; }
.nev-wa { color: #16a34a; font-size: 1.15rem; }
.nev-primary:hover:not(:disabled), .nev-ghost:hover { transform: translateY(-1px); }
.nev-primary:disabled { opacity: .5; cursor: default; }

.nev-timeline { position: relative; padding: 4px 14px 14px 36px; display: flex; flex-direction: column; gap: 10px; }
.nev-timeline::before {
    content: ""; position: absolute; left: 21px; top: 10px; bottom: 22px;
    width: 2px; background: var(--nev-line); border-radius: 2px;
}
.nev-note {
    position: relative; padding: 10px 12px; border-radius: 12px;
    border: 1px solid var(--nev-line); background: var(--nev-card); font-size: .84rem;
}
.nev-dot {
    position: absolute; left: -21px; top: 14px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--nev-ev); box-shadow: 0 0 0 3px color-mix(in srgb, var(--nev-ev) 22%, transparent);
}
.nev-note header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.nev-note header small { color: var(--nev-muted); }
.nev-badge {
    padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800;
    color: var(--nev-ev); background: color-mix(in srgb, var(--nev-ev) 13%, transparent);
}
.nev-muted { color: var(--nev-muted); margin: 4px 0 0; font-size: .8rem; }
.nev-soap { display: grid; grid-template-columns: 22px 1fr; gap: 6px; margin-top: 8px; }
.nev-soap > i {
    font-style: normal; font-weight: 900; font-size: .75rem; width: 22px; height: 22px; border-radius: 7px;
    display: grid; place-items: center; color: var(--nev-accent);
    background: color-mix(in srgb, var(--nev-accent) 12%, transparent);
}
.nev-soap span { display: block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--nev-muted); }
.nev-soap p { margin: 2px 0; white-space: pre-wrap; }
.nev-obj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px 12px; margin: 3px 0; }
.nev-obj-grid span { font-size: .68rem; text-transform: none; letter-spacing: 0; font-weight: 600; }
.nev-aclaracion {
    display: flex; gap: 8px; margin-top: 8px; padding: 8px 10px; border-radius: 10px;
    background: color-mix(in srgb, #f59e0b 10%, transparent); border: 1px solid color-mix(in srgb, #f59e0b 30%, transparent);
}
.nev-aclaracion .material-symbols-outlined { color: #d97706; font-size: 18px; }
.nev-aclaracion small { color: var(--nev-muted); }
.nev-aclaracion p { margin: 2px 0; white-space: pre-wrap; }
.nev-note footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--nev-line); }
.nev-note footer small { color: var(--nev-muted); font-size: .72rem; }
.nev-link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--nev-accent); font-weight: 700; font-size: .74rem; }

/* Contador en el botón de la tarjeta del historial */
.nev-count {
    display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px; background: #4338ca; color: #fff; font-size: .68rem; font-weight: 800;
}
.nev-count[hidden] { display: none; }

.nev-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.nev-tipo {
    padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800;
    color: var(--nev-text); background: var(--nev-card); border: 1px solid var(--nev-line);
}
.nev-hint { display: block; font-size: .7rem; font-weight: 600; color: var(--nev-muted); line-height: 1.3; }
.nev-hint[hidden] { display: none; }
.nev-precarga {
    display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px;
    font-size: .75rem; font-weight: 700; color: #047857; background: rgba(16, 185, 129, .12);
}
.nev-precarga[hidden] { display: none; }
.nev-precarga .material-symbols-outlined { font-size: 16px; }
.nev-chips-tipo { --nev-ev: var(--nev-accent); }
.nev-chips.nev-chips-tipo > label > span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; }
.nev-chips.nev-chips-tipo > label > span .material-symbols-outlined { display: inline; transition: none; font-size: 18px; padding: 0; border: 0; background: none; color: inherit; }

/* ---------- Ventana de seguimiento (abierta desde la tarjeta del historial) ---------- */
/* Encima de .premium-modal-overlay (z-index 1000000 en styles.css) */
#nev-viewer {
    position: fixed; inset: 0; z-index: 1000010;
    display: grid; place-items: center; padding: 12px;
    background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px);
    --nev-spring: cubic-bezier(.22, 1, .36, 1);
    --nev-accent: var(--glass-primary, #4f46e5);
    --nev-text: #0f172a; --nev-muted: #64748b;
    --nev-card: #f8fafc; --nev-line: #e2e8f0;
}
[data-theme="dark"] #nev-viewer { --nev-text: #e2e8f0; --nev-muted: #94a3b8; --nev-card: #1e293b; --nev-line: #334155; }
/* Fondo blanco sólido: sobre el historial (que ya es vidrio) se lee mejor que translúcido */
#nev-viewer .nev-viewer-box {
    position: relative; width: min(820px, 100%); max-height: 92vh; display: flex; flex-direction: column;
    overflow: hidden; overflow: clip; border-radius: 20px; color: var(--nev-text);
    background: #fff; border: 1px solid #e2e8f0;
    box-shadow: 0 30px 60px -24px rgba(15, 23, 42, .45), 0 10px 24px -12px rgba(15, 23, 42, .22);
    animation: nev-in .45s var(--nev-spring);
}
[data-theme="dark"] #nev-viewer .nev-viewer-box { background: #0f172a; border-color: #1e293b; }
#nev-viewer .nev-viewer-body { overflow-y: auto; padding: 14px 18px 18px; }
#nev-viewer .nev-panel { margin: 0; background: #fff; }
[data-theme="dark"] #nev-viewer .nev-panel { background: #0f172a; }
#nev-modal { --nev-card: #f8fafc; --nev-line: #e2e8f0; }
[data-theme="dark"] #nev-modal { --nev-card: #1e293b; --nev-line: #334155; }

/* ---------- Formulario (modal) ---------- */
#nev-modal {
    position: fixed; inset: 0; z-index: 1000020;
    display: grid; place-items: center; padding: 12px;
    background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px);
}
#nev-modal .nev-dialog {
    position: relative; width: min(760px, 100%); max-height: 94vh;
    display: flex; flex-direction: column; overflow: hidden; overflow: clip; border-radius: 20px;
    color: var(--nev-text);
    background: #fff; border: 1px solid #e2e8f0;
    box-shadow: 0 30px 60px -24px rgba(15, 23, 42, .45), 0 10px 24px -12px rgba(15, 23, 42, .22);
    animation: nev-in .45s var(--nev-spring);
}
#nev-modal .nev-dialog-sm { width: min(520px, 100%); }
[data-theme="dark"] #nev-modal .nev-dialog { background: #0f172a; border-color: #1e293b; box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .7); }
@keyframes nev-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.nev-head {
    display: flex; justify-content: space-between; gap: 12px; padding: 16px 20px 12px;
    border-bottom: 1px solid var(--nev-line); background: #fff;
}
[data-theme="dark"] .nev-head { background: #0f172a; }
.nev-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 800; color: var(--nev-accent); text-transform: uppercase; letter-spacing: .04em; }
.nev-eyebrow .material-symbols-outlined { font-size: 17px; }
.nev-head h2 { margin: 2px 0; font-size: 1.2rem; }
.nev-head p { margin: 0; color: var(--nev-muted); font-size: .82rem; }
.nev-close { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--nev-muted); align-self: flex-start; }

.nev-body { position: relative; overflow-y: auto; padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; }
.nev-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.nev-card { padding: 10px 12px; border-radius: 14px; background: var(--nev-card); border: 1px solid var(--nev-line); display: flex; flex-direction: column; gap: 8px; }
.nev-card h3 { margin: 0; font-size: .85rem; display: flex; align-items: center; gap: 8px; }
.nev-card h3 i {
    font-style: normal; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: .75rem;
    color: var(--nev-accent); background: color-mix(in srgb, var(--nev-accent) 14%, transparent);
}
.nev-card h3 .material-symbols-outlined { font-size: 20px; color: var(--nev-accent); }
.nev-proximo { display: grid; grid-template-columns: minmax(140px, 180px) 1fr; gap: 8px; }
.nev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.nev-field { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--nev-muted); }
.nev-field.nev-inline { flex-direction: row; align-items: center; gap: 8px; }
#nev-modal input:not([type="checkbox"]):not([type="radio"]), #nev-modal select, #nev-modal textarea {
    width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 10px; font: inherit; font-size: .88rem; font-weight: 500;
    color: var(--nev-text); background: #fff; border: 1px solid var(--nev-line);
    transition: border-color .25s var(--nev-spring), box-shadow .25s var(--nev-spring);
}
[data-theme="dark"] #nev-modal input:not([type="checkbox"]):not([type="radio"]), [data-theme="dark"] #nev-modal select, [data-theme="dark"] #nev-modal textarea { background: #0f172a; }
#nev-modal .nev-inline input { width: auto; }
#nev-modal textarea { resize: vertical; }
#nev-modal input:focus, #nev-modal select:focus, #nev-modal textarea:focus {
    outline: none; border-color: var(--nev-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--nev-accent) 20%, transparent);
}
.nev-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nev-chips label { position: relative; cursor: pointer; }
/* La casilla real queda encima de su botón: al enfocarla, el navegador no tiene que desplazar nada */
.nev-chips input { position: absolute; inset: 0; margin: 0; opacity: 0; pointer-events: none; }
.nev-chips span {
    display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: .8rem; font-weight: 700;
    border: 1px solid var(--nev-line); background: var(--nev-card); color: var(--nev-text);
    transition: all .25s var(--nev-spring);
}
.nev-chips input:checked + span { color: #fff; background: var(--nev-ev); border-color: var(--nev-ev); }
.nev-chips input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--nev-ev) 30%, transparent); }
.nev-legal { display: flex; gap: 8px; align-items: flex-start; font-size: .8rem; color: var(--nev-muted); cursor: pointer; }
.nev-legal input { margin-top: 3px; }
.nev-error { display: none; padding: 8px 10px; border-radius: 10px; font-size: .82rem; font-weight: 700; color: #b91c1c; background: rgba(254, 226, 226, .7); }
.nev-error.is-visible { display: block; }
.nev-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--nev-line); }

@media (max-width: 560px) {
    .nev-bar { flex-wrap: wrap; }
    .nev-toggle { flex-basis: 100%; }
    .nev-bar .nev-primary { flex: 1; justify-content: center; }
    .nev-timeline { padding-left: 30px; padding-right: 10px; }
    .nev-timeline::before { left: 16px; }
    .nev-dot { left: -19px; }
    #nev-modal { padding: 0; align-items: end; }
    #nev-modal .nev-dialog { border-radius: 20px 20px 0 0; max-height: 96vh; }
}

@media (prefers-reduced-motion: reduce) {
    #nev-modal, #nev-viewer { backdrop-filter: none !important; }
    .nev-panel *, #nev-modal * { transition: none !important; animation: none !important; }
    #nev-modal .nev-dialog { animation: none !important; }
}

@media print {
    .nev-panel, #nev-modal { display: none !important; }
}
