/* ARCHITECTURE: H&P Approval Modal Styles
   WHY: Extends problem-approval-modal patterns for H&P sections + problems
   NOTE: Section cards are expandable/editable, problems use checkbox selection
   THEME: Terminal theme — uses --term-* tokens from .aw-page / note-rail-terminal.
   All colors, glows, radii, and typography reference the Phosphor Theatre system. */


/* ============================================================
   H&P SECTION CARDS
   Expandable cards showing extracted H&P sections
   ============================================================ */

.handp-sections-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.handp-section-card {
    border-radius: var(--term-radius-sm, 2px);
    border: 1px solid var(--term-border-subtle);
    background: var(--term-bg-elevated);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.handp-section-card.is-selected {
    border-color: var(--term-accent-dim);
    box-shadow: var(--term-glow-accent);
}

.handp-section-card.is-expanded {
    box-shadow: var(--term-glow-accent);
    border-color: var(--term-border-default);
}

.handp-section-header {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    background: var(--term-bg-surface);
}

.handp-section-header:hover {
    background: var(--term-bg-elevated);
}

.handp-section-header input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--term-accent);
}

.handp-section-title {
    font-family: var(--term-font-mono);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.05em;
    color: var(--term-fg-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.handp-section-toggle {
    color: var(--term-fg-muted);
    transition: transform 0.2s;
    font-size: 10px;
    padding: 4px;
}

.handp-section-card.is-expanded .handp-section-toggle {
    transform: rotate(180deg);
}

.handp-section-preview {
    padding: 0 14px 10px 42px;  /* Aligned with checkbox */
    font-family: var(--term-font-mono);
    font-size: 12px;
    color: var(--term-fg-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.handp-section-card.is-expanded .handp-section-preview {
    display: none;
}

.handp-section-body {
    padding: 0 14px 14px;
    border-top: 1px solid var(--term-border-subtle);
}

.handp-section-content {
    background: var(--term-bg-input);
    border-radius: var(--term-radius-sm, 2px);
    border: 1px solid var(--term-border-subtle);
    padding: 10px 12px;
    font-family: var(--term-font-mono);
    font-size: 12px;
    line-height: 1.7;
    color: var(--term-fg-secondary);
    white-space: pre-wrap;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 10px;
}

.handp-section-content[contenteditable="true"] {
    background: var(--term-bg-input);
    border: 1px solid var(--term-accent-dim);
    box-shadow: var(--term-glow-accent);
    outline: none;
    cursor: text;
    color: var(--term-fg-primary);
}

.handp-section-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: flex-end;
}

.handp-edit-btn {
    padding: 5px 12px;
    border-radius: var(--term-radius-sm, 2px);
    font-family: var(--term-font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--term-accent-subtle);
    color: var(--term-accent);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.handp-edit-btn:hover {
    background: rgba(0, 255, 208, 0.12);
    border-color: var(--term-accent-dim);
    box-shadow: var(--term-glow-accent);
}

.handp-edit-btn.is-editing {
    background: rgba(34, 197, 94, 0.12);
    color: var(--term-status-ready);
    border-color: rgba(34, 197, 94, 0.35);
    box-shadow: var(--term-glow-green, 0 0 10px rgba(34, 197, 94, 0.25), 0 0 24px rgba(34, 197, 94, 0.08));
}


/* ============================================================
   H&P PROBLEM CARDS
   Checkbox selection for detected problems
   ============================================================ */

.handp-problem-card {
    border-radius: var(--term-radius-sm, 2px);
    border: 1px solid var(--term-border-subtle);
    background: var(--term-bg-elevated);
    padding: 10px 12px;
    margin-bottom: 6px;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.handp-problem-card.is-selected {
    border-color: var(--term-accent-dim);
    background: var(--term-accent-ghost);
    box-shadow: var(--term-glow-accent);
}

.handp-problem-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.handp-problem-header input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--term-accent);
    flex-shrink: 0;
}

.handp-problem-title {
    flex: 1;
    font-family: var(--term-font-mono);
    font-weight: 500;
    font-size: 13px;
    color: var(--term-fg-primary);
    cursor: pointer;
}

.handp-problem-body {
    margin-top: 8px;
    padding-left: 25px;  /* Aligned with checkbox */
}


/* ============================================================
   CONFIDENCE CHIPS & TREND PILLS
   ============================================================ */

.confidence-chip {
    font-family: var(--term-font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: var(--term-radius-sm, 2px);
    border: 1px solid var(--term-border-subtle);
    background: var(--term-bg-surface);
    color: var(--term-fg-muted);
}

.confidence-chip.high {
    background: rgba(34, 197, 94, 0.10);
    color: var(--term-status-ready);
    border-color: rgba(34, 197, 94, 0.35);
    text-shadow: var(--term-glow-green, 0 0 10px rgba(34, 197, 94, 0.25), 0 0 24px rgba(34, 197, 94, 0.08));
}

.confidence-chip.medium {
    background: rgba(245, 158, 11, 0.10);
    color: var(--term-status-editing);
    border-color: rgba(245, 158, 11, 0.35);
    text-shadow: var(--term-glow-amber, 0 0 10px rgba(245, 158, 11, 0.25), 0 0 24px rgba(245, 158, 11, 0.08));
}

.confidence-chip.low {
    background: rgba(239, 68, 68, 0.10);
    color: var(--term-status-error);
    border-color: rgba(239, 68, 68, 0.35);
    text-shadow: var(--term-glow-red, 0 0 10px rgba(239, 68, 68, 0.30), 0 0 24px rgba(239, 68, 68, 0.10));
}

.trend-pill {
    display: inline-block;
    font-family: var(--term-font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: var(--term-radius-sm, 2px);
    border: 1px solid var(--term-border-subtle);
}

.trend-pill.trend-active {
    background: var(--term-accent-subtle);
    color: var(--term-accent);
    border-color: var(--term-accent-dim);
}

.trend-pill.trend-stable {
    background: rgba(34, 197, 94, 0.08);
    color: var(--term-status-ready);
    border-color: rgba(34, 197, 94, 0.30);
}

.trend-pill.trend-improving {
    background: rgba(34, 197, 94, 0.12);
    color: var(--term-status-ready);
    border-color: rgba(34, 197, 94, 0.35);
    box-shadow: var(--term-glow-green, 0 0 10px rgba(34, 197, 94, 0.25), 0 0 24px rgba(34, 197, 94, 0.08));
}

.trend-pill.trend-worsening {
    background: rgba(239, 68, 68, 0.10);
    color: var(--term-status-error);
    border-color: rgba(239, 68, 68, 0.30);
}


/* ============================================================
   EMPTY STATE
   ============================================================ */

.handp-sections-list .empty-state,
.handp-problems-list .empty-state {
    padding: 24px;
    text-align: center;
    font-family: var(--term-font-mono);
    color: var(--term-fg-muted);
    font-size: 12px;
    letter-spacing: 0.05em;
}


/* ============================================================
   LOADING & ERROR STATES
   ============================================================ */

/* FIX (2026-01-13): Override V2 absolute positioning for H&P modal states */
#handp-modal-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    background: var(--term-bg-surface);
    z-index: 2;
}

#handp-modal-loading.hidden {
    display: none;
}

#handp-modal-loading .spinner {
    width: 30px;
    height: 30px;
    border: 2px solid var(--term-border-default);
    border-top-color: var(--term-accent);
    border-radius: 50%;
    animation: handp-spin 0.8s linear infinite;
    margin-bottom: 16px;
    box-shadow: var(--term-glow-accent);
}

@keyframes handp-spin {
    to { transform: rotate(360deg); }
}

#handp-loading-text {
    font-family: var(--term-font-mono);
    color: var(--term-fg-muted);
    font-size: 12px;
    letter-spacing: 0.08em;
}

/* FIX (2026-01-13): Override V2 absolute positioning for H&P error state */
#handp-modal-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 80px);
    max-width: 500px;
    padding: 32px 20px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.30);
    border-radius: var(--term-radius-sm, 2px);
    box-shadow: var(--term-glow-red, 0 0 10px rgba(239, 68, 68, 0.30), 0 0 24px rgba(239, 68, 68, 0.10));
    z-index: 2;
}

#handp-modal-error.hidden {
    display: none;
}

#handp-modal-error strong {
    display: block;
    font-family: var(--term-font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--term-status-error);
    margin-bottom: 8px;
}

#handp-modal-error-text {
    font-family: var(--term-font-mono);
    color: var(--term-fg-muted);
    font-size: 12px;
}


/* ============================================================
   PRIOR ADMISSIONS SECTION
   ============================================================ */

.handp-prior-admissions {
    margin-top: 14px;
    padding: 10px 12px;
    background: var(--term-gold-ghost);
    border: 1px solid var(--term-gold-dim);
    border-radius: var(--term-radius-sm, 2px);
}

.handp-prior-admissions h5 {
    margin: 0 0 8px;
    font-family: var(--term-font-mono);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--term-gold);
    text-shadow: var(--term-glow-gold, 0 0 10px rgba(212, 168, 87, 0.30), 0 0 24px rgba(212, 168, 87, 0.10));
}

.handp-prior-admission-item {
    font-family: var(--term-font-mono);
    font-size: 12px;
    color: var(--term-fg-secondary);
    padding: 3px 0;
}

.handp-prior-admission-item strong {
    color: var(--term-fg-primary);
}


/* ============================================================
   REDUCED MOTION (Fix D7)
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    #handp-modal-loading .spinner {
        animation: none;
    }
    .handp-section-card,
    .handp-problem-card,
    .handp-section-toggle {
        transition: none;
    }
}
