/* Edit patient (Client/Pages/DetailView/EditPatient.razor): a header naming the patient, a section list on the left,
   one section at a time, and a sticky Save changes footer. Radzen theme variables keep it legible in light and dark. */
.pe {
    --pe-accent: var(--rz-primary, #1d4ed8);
    --pe-text: var(--rz-text-color, #1e293b);
    --pe-muted: var(--rz-text-secondary-color, #64748b);
    --pe-border: var(--rz-base-300, #e2e8f0);
    --pe-surface: var(--rz-base-background-color, #fff);
    --pe-raised: var(--rz-base-50, #f8fafc);
    --pe-ok: var(--rz-success, #16a34a);
    --pe-warn: var(--rz-warning, #d97706);
    --pe-bad: var(--rz-danger, #dc2626);
    color: var(--pe-text);
    display: flex;
    flex-direction: column;
    /* Never wider than the dialog. No min-height: 100% either — with the dialog's own scrollbars that made the
       layout flip between "scrollbars" and "no scrollbars" on every frame (a horizontal bar steals height, which
       forces a vertical bar, which changes the width again). */
    max-width: 100%;
    overflow-x: clip;
}

/* Header */
.pe-head { display: flex; align-items: center; gap: 16px; padding: 4px 0 14px; border-bottom: 1px solid var(--pe-border); }
.pe-avatar { width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden;
    background: color-mix(in srgb, var(--pe-accent) 14%, transparent); color: var(--pe-accent); font-weight: 700; font-size: 20px; }
.pe-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pe-ident { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pe-ident h2 { margin: 0; font-size: 18px; font-weight: 500; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.pe-name { font-weight: 700; }
.pe-sep { color: var(--pe-muted); }
.pe-photo-menu { position: relative; align-self: flex-start; }
.pe-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 180px; padding: 4px; border-radius: 8px;
    border: 1px solid var(--pe-border); background: var(--pe-surface); box-shadow: 0 6px 18px rgb(0 0 0 / 0.12); display: flex; flex-direction: column; }
.pe-menu button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 6px; background: none;
    color: var(--pe-text); font-size: 13.5px; text-align: left; cursor: pointer; }
.pe-menu button:hover, .pe-menu button:focus-visible { background: var(--pe-raised); }
.pe-photo-panel { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--pe-border); }
.pe-photo-panel[hidden], .pe-photo-panel [hidden] { display: none !important; }
.pe-camera { width: 200px; max-height: 160px; overflow: hidden; border-radius: 8px; margin-bottom: 8px; }

/* Buttons and links */
.pe-btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.pe-btn-outline { border: 1px solid var(--pe-border); background: var(--pe-surface); color: var(--pe-text); }
.pe-btn-outline:hover { border-color: var(--pe-accent); }
.pe-btn-sm { padding: 4px 10px; font-size: 12.5px; }
.pe-link { border: 0; background: none; padding: 2px 4px; color: var(--pe-accent); font-weight: 600; text-decoration: underline; cursor: pointer; }

/* Body: section list + section */
.pe-body { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.pe-nav { display: flex; flex-direction: column; gap: 4px; padding: 14px 12px 14px 0; border-right: 1px solid var(--pe-border); }
.pe-nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none;
    color: var(--pe-text); font-size: 14px; text-align: left; cursor: pointer; }
.pe-nav-item:hover { background: var(--pe-raised); }
.pe-nav-item.on { background: color-mix(in srgb, var(--pe-accent) 13%, transparent); color: var(--pe-accent); font-weight: 700; }
.pe-nav-item i:first-child { width: 18px; text-align: center; }
.pe-nav-item span { flex: 1; }
.pe-nav-err { color: var(--pe-bad); }
.pe-main { padding: 14px 0 14px 22px; min-width: 0; }
.pe-main section[hidden] { display: none !important; }
.pe-title { font-size: 20px; font-weight: 700; margin: 0 0 12px; }

/* Panels */
.pe-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.pe-panel { border: 1px solid var(--pe-border); border-radius: 10px; padding: 10px 14px 14px; margin: 0 0 14px; background: var(--pe-surface); min-width: 0; }
.pe-panel legend { font-weight: 700; font-size: 15px; padding: 0 4px; width: auto; float: none; margin: 0; }
.pe-half { width: calc(50% - 7px); }
.pe-muted { color: var(--pe-muted); font-size: 13px; }

/* Demographics extras */
.pe-ids { margin-top: 14px; border: 1px solid var(--pe-border); border-radius: 8px; background: var(--pe-raised); }
.pe-ids-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none;
    color: var(--pe-text); text-align: left; cursor: pointer; font-size: 14px; }
.pe-ids-sum { margin-left: auto; font-size: 13px; color: var(--pe-muted); }
.pe-ids-sum b { color: var(--pe-text); }
.pe-ids-body { padding: 0 12px 12px; }
.pe-portal { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--pe-border); }

/* Badges */
.pe-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pe-badge i { font-size: 9px; }
.pe-badge.ok { color: var(--pe-ok); background: color-mix(in srgb, var(--pe-ok) 12%, transparent); }
.pe-badge.warn { color: #92400e; background: color-mix(in srgb, var(--pe-warn) 18%, transparent); }
.pe-badge.bad { color: var(--pe-bad); background: color-mix(in srgb, var(--pe-bad) 12%, transparent); }
.pe-badge.neutral { color: var(--pe-muted); background: var(--pe-raised); border: 1px solid var(--pe-border); }
.pe-validate .pe-badge i, .pe-validate .pe-badge { font-size: 12.5px; }

/* Contact */
.pe-validate { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.pe-emergency { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding: 12px 14px; border: 1px solid var(--pe-border);
    border-radius: 10px; background: var(--pe-raised); }
.pe-emergency .pe-link { margin-left: auto; }

/* Notes & record status */
.pe-note { width: 100%; min-height: 110px; resize: vertical; white-space: pre-wrap; }
.pe-deceased { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }

/* Footer: one Save changes for the whole form */
/* No negative margins: bleeding past the dialog's padding made the form wider than the dialog (the flicker above). */
.pe-foot { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 14px;
    border-top: 1px solid var(--pe-border); border-radius: 0 0 8px 8px; background: var(--pe-raised); }
.pe-foot-info { color: var(--pe-muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.pe-foot-err { color: var(--pe-bad); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.pe-spacer { flex: 1; }

/* Edit relationship (EditPatientRelationship.razor) reuses the editor above; only its header differs. */
.pr-head { justify-content: space-between; flex-wrap: wrap; }
.pr-patient { font-size: 15px; color: var(--pe-muted); }
.pr-summary { padding: 8px 14px; border: 1px solid var(--pe-border); border-radius: 8px; background: var(--pe-raised); font-size: 14px; }
.pr-emergency { display: flex; align-items: center; gap: 10px; margin-top: 14px; }

@media (max-width: 900px) {
    .pe-body { grid-template-columns: minmax(0, 1fr); }
    .pe-nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--pe-border); padding: 10px 0; }
    .pe-nav-item { width: auto; }
    .pe-main { padding: 14px 0; }
    /* Stacked, each location stays under its own parent. */
    .pe-grid2 { grid-template-columns: minmax(0, 1fr); }
    .pe-half { width: 100%; }
    .pe-ids-sum { margin-left: 0; }
}
