/* ============================================================
   FE-3 — Portal del paciente: shell (sidebar >1024, drawer <=1024,
   bottom-nav <=768), banner de delegación y toasts accesibles.
   Tokens A2 (variables.css) · gate responsive 390/768/1280.
   ============================================================ */

.portal-shell { display: flex; min-height: 100vh; }

/* ---- Sidebar (>1024) ---- */
.portal-sidebar {
    width: 248px; flex: 0 0 248px;
    background: #FFFFFF;
    border-right: 1px solid rgba(0, 119, 182, 0.10);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.portal-nav { flex: 1; padding: 0.5rem 0.75rem 1rem; }
.portal-nav-group-title {
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--color-gray-600); padding: 0.9rem 0.75rem 0.35rem;
}
.portal-nav-item {
    display: flex; align-items: center; gap: 0.7rem;
    min-height: 48px; padding: 0.55rem 0.85rem; margin-bottom: 2px;
    border-radius: 12px; color: var(--color-text); text-decoration: none;
    font-size: 0.95rem; border-left: 3px solid transparent;
}
.portal-nav-item i { font-size: 1.1rem; color: var(--color-gray-600); }
.portal-nav-item:hover { background: rgba(0, 119, 182, 0.06); text-decoration: none; }
.portal-nav-item.is-active {
    background: rgba(0, 119, 182, 0.10); color: var(--color-primary-dark); font-weight: 600;
    border-left-color: var(--color-primary);
}
.portal-nav-item.is-active i { color: var(--color-primary); }
.portal-sidebar-foot { color: var(--color-gray-600); margin-top: auto; }

/* ---- Columna principal ---- */
.portal-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.portal-main .app-main { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
.portal-menu-btn { display: none; min-width: 48px; min-height: 44px; }

/* ---- Banner de delegación (persistente, INV-017) ---- */
.delegation-banner {
    display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-dark));
    color: #FFFFFF; padding: 0.55rem 1rem; font-size: 0.92rem; font-weight: 500;
}
.delegation-banner i { font-size: 1.15rem; }

/* ---- Drawer (≤1024) ---- */
.portal-drawer {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 85vw);
    background: #FFFFFF; z-index: 1200;
    transform: translateX(-105%); transition: transform 0.25s ease;
    overflow-y: auto; box-shadow: 0 0 40px rgba(2, 48, 71, 0.25);
    display: flex; flex-direction: column;
}
.portal-drawer.is-open { transform: translateX(0); }
.portal-drawer-overlay {
    position: fixed; inset: 0; background: rgba(2, 48, 71, 0.45); z-index: 1100;
}
@media (prefers-reduced-motion: reduce) {
    .portal-drawer { transition: none; }
}

/* ---- Bottom-nav (≤768): 4 destinos + Más (patrón Material: una línea
   de etiqueta, indicador centrado sobre el icono, altura estable) ---- */
.portal-bottomnav {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    background: #FFFFFF; border-top: 1px solid rgba(0, 119, 182, 0.12);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -6px 20px rgba(2, 48, 71, 0.08);
}
.portal-bottomnav-item {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: 58px; padding: 7px 2px 5px;
    color: var(--color-gray-600); text-decoration: none; background: none; border: none;
    position: relative; cursor: pointer;
}
.portal-bottomnav-item i { font-size: 1.4rem; line-height: 1; }
.portal-bottomnav-item span {
    font-size: 0.68rem; font-weight: 600; line-height: 1.15;
    white-space: nowrap; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis;
}
/* Indicador activo: pastilla centrada sobre el icono (nunca solo color) */
.portal-bottomnav-item::before {
    content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 32px; height: 3px; border-radius: 0 0 4px 4px;
    background: transparent; transition: background 0.15s ease;
}
.portal-bottomnav-item.is-active { color: var(--color-primary-dark); }
.portal-bottomnav-item.is-active i { color: var(--color-primary); font-size: 1.5rem; }
.portal-bottomnav-item.is-active span { font-weight: 700; }
.portal-bottomnav-item.is-active::before { background: var(--color-primary); }
.portal-bottomnav-item:focus-visible { outline: 3px solid var(--color-focus, #4D90FE); outline-offset: -3px; border-radius: 12px; }

/* ---- Toasts accesibles (HC_toasts) ---- */
.hc-toast {
    display: flex; align-items: flex-start; gap: 0.5rem;
    min-width: 280px; max-width: 380px; margin-bottom: 0.6rem;
    background: #FFFFFF; border-radius: 14px; padding: 0.8rem 0.9rem;
    box-shadow: 0 14px 34px rgba(2, 48, 71, 0.18);
    border-left: 4px solid var(--color-gray-400);
    animation: hc-toast-in 0.25s ease;
}
.hc-toast-success { border-left-color: #2E7D32; }
.hc-toast-success i { color: #2E7D32; }
.hc-toast-error { border-left-color: #C62828; }
.hc-toast-error i { color: #C62828; }
.hc-toast-warning { border-left-color: #E65100; }
.hc-toast-warning i { color: #E65100; }
.hc-toast-info { border-left-color: var(--color-primary); }
.hc-toast-info i { color: var(--color-primary); }
.hc-toast-body { flex: 1; font-size: 0.95rem; color: var(--color-text); }
.hc-toast-close {
    background: none; border: none; min-width: 36px; min-height: 36px;
    border-radius: 8px; color: var(--color-gray-600); cursor: pointer;
}
.hc-toast-close:hover { background: rgba(2, 48, 71, 0.06); }
@keyframes hc-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hc-toast { animation: none; } }

/* ============================================================
   Componentes del portal (FE-3): banner de alergias, chips filtro,
   timeline, cards deseo/límite, wizard, estado vacío, skeleton.
   ============================================================ */

/* Banner de alergias (safety-banner) — crítico, siempre arriba */
.allergy-banner {
    display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
    border-radius: 16px; padding: 1rem 1.1rem; border: 2px solid;
}
.allergy-banner-level { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.allergy-banner-level i { font-size: 1.6rem; }
.allergy-banner-critical {
    background: #FDECEA; border-color: #C62828; color: #8E1B12;
}
.allergy-banner-warning { background: #FFF4E5; border-color: #E65100; color: #8A3D00; }
.allergy-banner-ok { background: #E8F5E9; border-color: #2E7D32; color: #1B5E20; }

/* Chips filtro (aria-pressed) */
.filter-chip {
    min-height: 44px; padding: 0.45rem 1rem; border-radius: 999px;
    border: 1.5px solid rgba(0, 119, 182, 0.25); background: #FFFFFF;
    color: var(--color-text); font-size: 0.9rem; cursor: pointer;
}
.filter-chip.is-pressed, .filter-chip[aria-pressed="true"] {
    background: var(--color-primary); border-color: var(--color-primary);
    color: #FFFFFF; font-weight: 600;
}

/* Severidad de alergia: color + icono + texto (nunca solo color) */
.sev-badge { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; }
.sev-leve { color: #1B5E20; }
.sev-moderada { color: #8A3D00; }
.sev-severa, .sev-anafilaxia { color: #8E1B12; }
.allergy-card-critical { border-left: 5px solid #C62828; }
.allergy-card-warning { border-left: 5px solid #E65100; }
.allergy-card-ok { border-left: 5px solid var(--color-gray-300); }

/* Timeline clínico */
.timeline-hc { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline-hc::before {
    content: ''; position: absolute; left: 21px; top: 8px; bottom: 8px;
    width: 2px; background: rgba(0, 119, 182, 0.18);
}
.timeline-item { position: relative; padding: 0 0 1.1rem 56px; }
.timeline-item-dot {
    position: absolute; left: 6px; top: 2px;
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #FFFFFF; border: 2px solid var(--color-primary);
    color: var(--color-primary); font-size: 0.95rem;
}
.timeline-fecha { font-size: 0.82rem; color: var(--color-gray-600); }

/* Cards deseo / límite (preferencias) */
.pref-card-deseo { border-left: 5px solid var(--color-primary); }
.pref-card-limite { border-left: 5px solid #E65100; }
.pref-tipo-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-gray-600); }

/* Wizard (delegaciones) */
.wizard-steps { display: flex; gap: 0.4rem; margin-bottom: 1.2rem; }
.wizard-step {
    flex: 1; height: 6px; border-radius: 999px;
    background: rgba(0, 119, 182, 0.15);
}
.wizard-step.done, .wizard-step.active { background: var(--color-primary); }

/* ===== Alta de cuidadores por invitación (2026-09-30) ===== */
/* Avatar de quién invita (reconocimiento > recuerdo) */
.deleg-inv-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}
/* Botones del landing: columna completa en móvil, fila en desktop con ancho
   por CONTENIDO — un min-width fijo dejaba el texto del CTA apretado/desbordado
   (hallazgo 2026-09-30, dos iteraciones) */
.deleg-inv-botones { max-width: 360px; margin-left: auto; margin-right: auto; }
@media (min-width: 768px) {
    .deleg-inv-botones { max-width: none; flex-direction: row !important; justify-content: center; flex-wrap: wrap; }
    .deleg-inv-botones .btn { white-space: nowrap; }
}
/* Checklist de contraseña en vivo (prevención de errores) */
.deleg-pw-check { font-size: 0.82rem; color: var(--color-gray-600); }
.deleg-pw-check li { margin-bottom: 0.15rem; }
.deleg-pw-check li i { color: var(--color-gray-400); }
.deleg-pw-check li.deleg-pw-ok { color: var(--color-success); color: #0a7d5c; }
.deleg-pw-check li.deleg-pw-ok i { color: #0a7d5c; }
/* Chip pendiente en la lista del paciente */
.deleg-chip-pendiente { font-size: 0.78rem; }

/* Sección grande de toggle (pasaporte) */
.scope-row {
    display: flex; align-items: center; gap: 0.9rem; justify-content: space-between;
    padding: 0.85rem 1rem; border: 1.5px solid rgba(0, 119, 182, 0.15);
    border-radius: 14px; margin-bottom: 0.6rem; background: #FFFFFF;
}
.scope-row-label { font-weight: 600; }
.scope-row-desc { font-size: 0.85rem; color: var(--color-gray-600); }
.scope-row.sensible { border-color: #E65100; background: #FFF8F0; }
.form-switch .form-check-input { width: 3.4em; height: 1.9em; cursor: pointer; }
/* Gate F4-UX6: target táctil ≥44px también en switches (adultos mayores) */
.scope-row .form-check-input {
    width: 4.1em; height: 2.45rem; min-width: 44px; min-height: 44px;
    background-size: 2rem;
}

/* Estados vacíos educativos */
.empty-state {
    text-align: center; padding: 2.2rem 1rem; border-radius: 16px;
    border: 2px dashed rgba(0, 119, 182, 0.20); background: rgba(247, 251, 254, 0.7);
}
.empty-state i { font-size: 2.2rem; color: var(--color-primary); }
.empty-state p { color: var(--color-gray-600); max-width: 42ch; margin: 0.6rem auto 0; }

/* Skeletons (visibilidad de estado, Nielsen #1) */
.skeleton {
    border-radius: 10px; background: linear-gradient(90deg, rgba(0,119,182,0.07) 25%, rgba(0,119,182,0.14) 50%, rgba(0,119,182,0.07) 75%);
    background-size: 200% 100%; animation: skeleton-wave 1.4s infinite;
    min-height: 18px;
}
@keyframes skeleton-wave { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---- Responsive del shell ---- */
@media (max-width: 1024px) {
    .portal-sidebar { display: none; }
    .portal-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
}
@media (min-width: 1025px) {
    .portal-drawer, .portal-drawer-overlay { display: none !important; }
}
@media (max-width: 768px) {
    .portal-bottomnav { display: flex; }
    .portal-main .app-main { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
    .portal-footer { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
}


/* Tabs ARIA (historia) */
.nav-tab-hc {
    text-decoration: none; font-weight: 600; color: var(--color-gray-600);
    border-bottom: 3px solid transparent; border-radius: 0; min-height: 48px;
    padding: 0.6rem 0.9rem;
}
.nav-tab-hc:hover { color: var(--color-primary-dark); }
.nav-tab-hc.is-active-tab {
    color: var(--color-primary-dark); border-bottom-color: var(--color-primary);
}

/* Composer PROM (síntomas) */
.medio-option {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 88px; border: 2px solid rgba(0, 119, 182, 0.18); border-radius: 14px;
    background: #FFFFFF; color: var(--color-text); cursor: pointer; font-weight: 600;
    padding: 0.6rem; text-align: center;
}
.medio-option i { font-size: 1.5rem; color: var(--color-primary); }
.medio-option[aria-pressed="true"] {
    border-color: var(--color-primary); background: rgba(0, 119, 182, 0.06);
}
.medio-option:disabled { opacity: 0.55; cursor: not-allowed; }
.medio-option .badge { font-size: 0.62rem; }
