/**
 * Problem Card Styles
 * 
 * Unified problem card component for the somaCURA clinical cockpit.
 * Each card shows: trajectory badge, name, hero metric, A&P, linked meds.
 */

/* ============================================================================
   CARD CONTAINER
   ============================================================================ */

.problem-card {
    --card-bg: var(--surface-color, #1e293b);
    --card-border: var(--border-color, #334155);
    --card-radius: 8px;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    
    /* Trajectory state colors */
    --worsening-color: #ef4444;
    --improving-color: #22c55e;
    --stable-color: #64748b;
    --unknown-color: #475569;
    
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.problem-card:hover {
    border-color: color-mix(in srgb, var(--card-border) 60%, white 40%);
}

/* Enhanced hover/glow effects for problem list cards */
.problem-card.card-enhanced {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    cursor: default;
}

.problem-card.card-enhanced::before {
    border-radius: var(--card-radius);
}

.problem-card.card-enhanced:hover {
    border-color: color-mix(in srgb, var(--card-border) 60%, white 40%);
    box-shadow: var(--card-shadow-hover);
}

/* Preserve trajectory accent borders when card-enhanced is applied */
.problem-card.card-enhanced.problem-card--worsening {
    border-left: 3px solid var(--worsening-color);
}

.problem-card.card-enhanced.problem-card--improving {
    border-left: 3px solid var(--improving-color);
}

.problem-card.card-enhanced.problem-card--stable {
    border-left: 3px solid var(--stable-color);
}

.problem-card.card-enhanced.problem-card--unknown {
    border-left: 3px solid var(--unknown-color);
}

/* Trajectory state indicator (left border accent) */
.problem-card--worsening {
    border-left: 3px solid var(--worsening-color);
}

.problem-card--improving {
    border-left: 3px solid var(--improving-color);
}

.problem-card--stable {
    border-left: 3px solid var(--stable-color);
}

.problem-card--unknown {
    border-left: 3px solid var(--unknown-color);
}

/* ============================================================================
   HEADER
   ============================================================================ */

.problem-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
}

.problem-card__header:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Toggle button */
.problem-card__toggle {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.problem-card__toggle:hover {
    color: var(--text-color, #e2e8f0);
}

.problem-card__toggle-icon {
    transition: transform 0.15s ease;
}

/* Trajectory badge */
.problem-card__trajectory {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.problem-card__trajectory--worsening {
    background: rgba(239, 68, 68, 0.15);
    color: var(--worsening-color);
}

.problem-card__trajectory--improving {
    background: rgba(34, 197, 94, 0.15);
    color: var(--improving-color);
}

.problem-card__trajectory--stable {
    background: rgba(100, 116, 139, 0.15);
    color: var(--stable-color);
}

.problem-card__trajectory--unknown {
    background: rgba(71, 85, 105, 0.15);
    color: var(--unknown-color);
}

/* Title area */
.problem-card__title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.problem-card__name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color, #e2e8f0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.problem-card__status-badge {
    flex-shrink: 0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted, #94a3b8);
}

/* Summary (hero metric + A&P preview) */
.problem-card__summary {
    flex-shrink: 0;
    text-align: right;
    max-width: 200px;
}

.problem-card__hero-summary {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-color, #e2e8f0);
    font-variant-numeric: tabular-nums;
}

.problem-card__ap-preview {
    display: block;
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* ============================================================================
   BODY (EXPANDABLE)
   ============================================================================ */

.problem-card__body {
    padding: 0 12px 12px 12px;
    border-top: 1px solid var(--card-border);
}

.problem-card__body--collapsed {
    display: none;
}

/* ============================================================================
   METRIC PANEL
   ============================================================================ */

.metric-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 12px 0;
}

.metric-panel--empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
}

/* Metric item */
.metric-item {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    padding: 8px 10px;
}

.metric-item--hero {
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.05);
}

.metric-item__header {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 4px;
}

.metric-item__label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #94a3b8);
}

.metric-item__unit {
    font-size: 9px;
    color: var(--text-muted, #94a3b8);
    opacity: 0.7;
}

.metric-item__body {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
}

.metric-item__value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color, #e2e8f0);
    font-variant-numeric: tabular-nums;
}

.metric-item__delta {
    font-size: 12px;
    font-weight: 500;
}

.metric-delta--bad {
    color: var(--worsening-color);
}

.metric-delta--good {
    color: var(--improving-color);
}

.metric-item__spark {
    display: flex;
    align-items: center;
}

.metric-spark--empty {
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
}

.metric-item__gaps {
    font-size: 9px;
    color: var(--text-muted, #94a3b8);
    opacity: 0.6;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ============================================================================
   A&P SECTION
   ============================================================================ */

.problem-card__ap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--card-border);
}

.problem-card__assessment,
.problem-card__plan {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.problem-card__ap-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #94a3b8);
}

.problem-card__ap-source {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.problem-card__ap-source--draft {
    color: #f59e0b;
}

.problem-card__ap-source--prior {
    color: #64748b;
}

.problem-card__ap-source--empty {
    color: #475569;
}

.problem-card__ap-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-color, #e2e8f0);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 36px;
    max-height: 200px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.problem-card__ap-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: rgba(0, 0, 0, 0.3);
}

.problem-card__ap-input::placeholder {
    color: var(--text-muted, #94a3b8);
    opacity: 0.5;
}

/* ============================================================================
   LINKED MEDICATIONS
   ============================================================================ */

.problem-card__meds {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    border-top: 1px solid var(--card-border);
}

.problem-card__meds-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #94a3b8);
    margin-right: 4px;
}

.med-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.med-tag--held {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}

.med-tag--dc {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
    text-decoration: line-through;
}

.med-tag--more {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted, #94a3b8);
}

/* ============================================================================
   HISTORY SECTION
   ============================================================================ */

.problem-card__history {
    padding: 8px 0;
    border-top: 1px solid var(--card-border);
}

.problem-card__history-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 0;
}

.problem-card__history-btn:hover {
    color: var(--text-color, #e2e8f0);
}

.problem-card__history-day {
    background: transparent;
    border: none;
    color: #60a5fa;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
    margin: 0 2px;
    border-radius: 3px;
}

.problem-card__history-day:hover {
    background: rgba(96, 165, 250, 0.1);
}

.problem-card__history-content {
    margin-top: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
}

.problem-card__history-entry {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-color, #e2e8f0);
}

.problem-card__history-entry strong {
    color: var(--text-muted, #94a3b8);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 640px) {
    .problem-card__header {
        flex-wrap: wrap;
    }
    
    .problem-card__summary {
        width: 100%;
        text-align: left;
        margin-top: 4px;
        max-width: none;
    }
    
    .metric-panel {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .metric-panel {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes pulse-save {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.problem-card__ap-source--saving {
    animation: pulse-save 0.6s ease-in-out infinite;
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .problem-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .problem-card__toggle {
        display: none;
    }
    
    .problem-card__body--collapsed {
        display: block !important;
    }
    
    .problem-card__ap-input {
        border: none;
        background: transparent;
        resize: none;
    }
}

/* ============================================================================
   PROBLEM LIST CONTAINER
   ============================================================================ */

.problem-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.problem-list__section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.problem-list__section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #94a3b8);
    border-bottom: 1px solid var(--border-color, #333);
}

.problem-list__section-header--deteriorating {
    color: #ef4444;
    border-bottom-color: rgba(239, 68, 68, 0.3);
}

.problem-list__section-header--active {
    color: #f59e0b;
    border-bottom-color: rgba(245, 158, 11, 0.2);
}

.problem-list__section-header--stable {
    color: #64748b;
}

.problem-list__section-header--background {
    color: var(--text-muted, #64748b);
    cursor: pointer;
}

.problem-list__section-header--background:hover {
    color: var(--text-color, #f1f5f9);
}

/* Primary section - visually distinct, indigo accent */
.problem-list__section--primary {
    margin-bottom: 16px;
}

.problem-list__section-header--primary {
    background: rgba(99, 102, 241, 0.15);
    border-left: 3px solid #6366f1;
    color: #a5b4fc;
    font-weight: 600;
    padding-left: 12px;
}

/* Primary indicator for collapsed sections containing primaries */
.problem-list__section-primary-indicator {
    color: #6366f1;
    margin-right: 6px;
    font-size: 12px;
}

.problem-list__section-title {
    flex: 1;
}

.problem-list__section-count {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
}

.problem-list__section-arrow {
    font-size: 10px;
    color: var(--text-muted, #94a3b8);
}

.problem-list__section-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.problem-list__section-body--collapsed {
    display: none;
}

/* ----------------------------------------------------------------------------
   RELATIONSHIP GROUPING (Phase 15)
   Visual grouping of child problems under parents within trajectory tier
   ---------------------------------------------------------------------------- */

/* Parent problem in a relationship group */
.problem-list__group-parent {
    /* No special styling needed - parent looks normal */
}

/* Child problem indented under parent */
.problem-list__group-child {
    margin-left: 16px;
    padding-left: 12px;
    border-left: 2px solid rgba(139, 92, 246, 0.3); /* Purple connector */
    position: relative;
}

/* First child has top connection to parent */
.problem-list__group-child:first-of-type {
    margin-top: 2px;
}

/* Last child has rounded bottom border */
.problem-list__group-child:last-of-type {
    border-bottom-left-radius: 4px;
}

/* Hover highlight for grouped children */
.problem-list__group-child:hover {
    border-left-color: rgba(139, 92, 246, 0.5);
}

/* Divergent child (in different trajectory tier) - no indent but has badge */
.problem-list__divergent-child .problem-card {
    /* Normal styling, badge indicates relationship */
}

.problem-list__empty {
    padding: 32px;
    text-align: center;
    color: var(--text-muted, #94a3b8);
    font-size: 14px;
}

/* ============================================================================
   PROBLEM LIST FOOTER (GENERATE BUTTON)
   ============================================================================ */

.problem-list__footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 0;
    margin-top: 8px;
    border-top: 1px solid var(--border-color, #334155);
}

.problem-list__generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.problem-list__generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.problem-list__generate-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.2);
}

.problem-list__generate-btn--has-pending {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.problem-list__generate-btn--has-pending:hover {
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.problem-list__generate-icon {
    font-size: 16px;
}

.problem-list__pending-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

/* ============================================================================
   PENDING EDITS BADGE (PROBLEM CARD)
   ============================================================================ */

.problem-card__pending-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.problem-card__pending-dot {
    width: 6px;
    height: 6px;
    background: #f59e0b;
    border-radius: 50%;
    animation: pending-pulse 1.5s ease-in-out infinite;
}

@keyframes pending-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ============================================================================
   HISTORY SECTION (NEW)
   ============================================================================ */

.problem-card__history-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--card-border);
}

/* History toggle header */
.problem-card__history-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.problem-card__history-toggle:hover {
    background: rgba(255, 255, 255, 0.02);
}

.problem-card__history-toggle-icon {
    flex-shrink: 0;
    width: 12px;
    font-size: 10px;
    color: var(--text-muted, #94a3b8);
    transition: transform 0.15s ease;
}

.problem-card__history-toggle-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #94a3b8);
}

/* History body (collapsible) */
.problem-card__history-body {
    max-height: 500px;
    overflow-y: auto;
    padding-top: 8px;
    transition: max-height 0.2s ease, padding 0.2s ease;
}

.problem-card__history-body--collapsed {
    max-height: 0;
    padding: 0;
    overflow: hidden;
}

/* History item */
.problem-card__history-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.problem-card__history-item:last-child {
    margin-bottom: 0;
}

.problem-card__history-item-header {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.problem-card__history-day {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color, #e2e8f0);
}

.problem-card__history-date {
    font-size: 11px;
    color: var(--text-muted, #64748b);
}

/* Source badges - rounded rectangle shape (not pill) for clinical clarity */
.problem-card__history-source {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.problem-card__history-source--generated {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}

.problem-card__history-source--edited {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

.problem-card__history-source--seeded {
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.4);
    color: #c084fc;
}

/* History item preview */
.problem-card__history-item-preview {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.problem-card__history-assessment,
.problem-card__history-plan {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Use button */
.problem-card__history-use-btn {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #94a3b8);
    background: transparent;
    border: 1px solid #475569;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 44px;
    min-height: 32px;
}

.problem-card__history-use-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color, #e2e8f0);
    border-color: #64748b;
}

.problem-card__history-use-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

/* Seeded badge for A&P label */
.problem-card__seeded-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    color: #60a5fa;
    text-transform: none;
    letter-spacing: 0;
}

/* Seed flash animation (for successful seeding in Plan 02) */
@keyframes seeded-flash {
    0% {
        box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.6);
    }
    50% {
        box-shadow: 0 0 20px 4px rgba(96, 165, 250, 0.4);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
    }
}

.problem-card__ap-input.seeded-flash {
    animation: seeded-flash 0.5s ease-out;
    border-color: #60a5fa;
}

/* Responsive adjustments for history section */
@media (max-width: 640px) {
    .problem-card__history-item {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .problem-card__history-use-btn {
        grid-column: 1;
        grid-row: 3;
        justify-self: start;
        margin-top: 8px;
    }
}

/* ============================================================================
   PHASE 6: VISUAL POLISH (2026-01-20)
   Enhanced styling for history section, provenance badges, and seed buttons
   ============================================================================ */

/* ----------------------------------------------------------------------------
   HISTORY SECTION LAYOUT POLISH
   Improved toggle, density, and visual fit within card
   ---------------------------------------------------------------------------- */

/* Enhanced toggle button */
.problem-card__history-toggle {
    border-radius: 6px;
    margin: 0 -8px;
    padding: 8px 12px;
    transition: background 0.15s ease;
}

.problem-card__history-toggle:hover {
    background: rgba(255, 255, 255, 0.04);
}

.problem-card__history-toggle:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.problem-card__history-toggle-icon {
    color: #64748b;
    font-weight: 600;
}

.problem-card__history-toggle:hover .problem-card__history-toggle-icon {
    color: #94a3b8;
}

.problem-card__history-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* History count badge */
.problem-card__history-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: rgba(100, 116, 139, 0.25);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
}

/* Improved history body scrolling */
.problem-card__history-body {
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}

.problem-card__history-body::-webkit-scrollbar {
    width: 4px;
}

.problem-card__history-body::-webkit-scrollbar-track {
    background: transparent;
}

.problem-card__history-body::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 2px;
}

.problem-card__history-body::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ----------------------------------------------------------------------------
   PROVENANCE BADGES - Enhanced Colors & Visibility
   Distinctive styling for seeded, edited, and generated indicators
   ---------------------------------------------------------------------------- */

/* Base badge refinements */
.problem-card__history-source {
    font-weight: 600;
    letter-spacing: 0.4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.problem-card__history-source:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* Generated badge - Blue (AI-produced) */
.problem-card__history-source--generated {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0.15) 100%);
    border: 1px solid rgba(59, 130, 246, 0.5);
    color: #60a5fa;
}

/* Edited badge - Green (Human-modified) */
.problem-card__history-source--edited {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.25) 0%, rgba(34, 197, 94, 0.15) 100%);
    border: 1px solid rgba(34, 197, 94, 0.5);
    color: #4ade80;
}

/* Seeded badge - Purple (Pulled from history) */
.problem-card__history-source--seeded {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25) 0%, rgba(168, 85, 247, 0.15) 100%);
    border: 1px solid rgba(168, 85, 247, 0.5);
    color: #c084fc;
}

/* Current A&P seeded badge - more prominent */
.problem-card__seeded-badge {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.25) 0%, rgba(96, 165, 250, 0.15) 100%);
    border: 1px solid rgba(96, 165, 250, 0.5);
    color: #60a5fa;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(96, 165, 250, 0.2);
}

/* ----------------------------------------------------------------------------
   SEED BUTTON POLISH
   Enhanced CTA styling, hover states, and loading indicator
   ---------------------------------------------------------------------------- */

/* Base Use button improvements */
.problem-card__history-use-btn {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #60a5fa;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.problem-card__history-use-btn:hover {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.55);
    color: #93c5fd;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.25);
    transform: translateY(-1px);
}

.problem-card__history-use-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.problem-card__history-use-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Loading state */
.problem-card__history-use-btn--loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.problem-card__history-use-btn--loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(96, 165, 250, 0.3);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: btn-spinner 0.6s linear infinite;
}

@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

/* Disabled state */
.problem-card__history-use-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ----------------------------------------------------------------------------
   VISUAL HIERARCHY - Recency Emphasis & Item Separation
   Older items are de-emphasized, recent items stand out
   ---------------------------------------------------------------------------- */

/* History item refinements */
.problem-card__history-item {
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.problem-card__history-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

/* First (most recent) item emphasis */
.problem-card__history-item:first-child {
    background: rgba(59, 130, 246, 0.06);
    border-left-color: rgba(59, 130, 246, 0.5);
}

.problem-card__history-item:first-child:hover {
    background: rgba(59, 130, 246, 0.10);
}

.problem-card__history-item:first-child .problem-card__history-day {
    color: #93c5fd;
}

/* Day label refinements */
.problem-card__history-day {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Date styling */
.problem-card__history-date {
    font-size: 10px;
    color: #64748b;
}

/* Older items fade progressively (2nd, 3rd, etc.) */
.problem-card__history-item:nth-child(n+3) {
    opacity: 0.85;
}

.problem-card__history-item:nth-child(n+4) {
    opacity: 0.75;
}

.problem-card__history-item:nth-child(n+5) {
    opacity: 0.65;
}

/* Divider between history items for better separation */
.problem-card__history-item + .problem-card__history-item {
    margin-top: 10px;
    position: relative;
}

.problem-card__history-item + .problem-card__history-item::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 12px;
    right: 12px;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(100, 116, 139, 0.25) 20%, rgba(100, 116, 139, 0.25) 80%, transparent 100%);
}

/* Preview text truncation with ellipsis */
.problem-card__history-assessment,
.problem-card__history-plan {
    font-size: 11px;
    line-height: 1.5;
}

/* Label prefixes */
.problem-card__history-assessment::before {
    content: 'A: ';
    font-weight: 600;
    color: #64748b;
}

.problem-card__history-plan::before {
    content: 'P: ';
    font-weight: 600;
    color: #64748b;
}

/* Empty history state */
.problem-card__history-empty {
    padding: 16px;
    text-align: center;
    color: #64748b;
    font-size: 12px;
    font-style: italic;
}

/* ----------------------------------------------------------------------------
   SEEDED FLASH ANIMATION REFINEMENT
   More prominent visual feedback on successful seed
   ---------------------------------------------------------------------------- */

@keyframes seeded-flash {
    0% {
        box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.7);
        border-color: #60a5fa;
    }
    30% {
        box-shadow: 0 0 16px 4px rgba(96, 165, 250, 0.5);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
        border-color: var(--card-border);
    }
}

.problem-card__ap-input.seeded-flash {
    animation: seeded-flash 0.6s ease-out;
}

/* ============================================================================
   PHASE 7: DIFF VIEW (2026-01)
   Word-level diff highlighting and change count badges for A&P history
   ============================================================================ */

/* ----------------------------------------------------------------------------
   DIFF HIGHLIGHTING
   Green for additions, red for deletions, following existing color tokens
   ---------------------------------------------------------------------------- */

.diff-added {
    background: rgba(34, 197, 94, 0.25);
    color: var(--improving-color, #22c55e);
    padding: 1px 2px;
    border-radius: 2px;
    text-decoration: none;
}

.diff-removed {
    background: rgba(239, 68, 68, 0.25);
    color: var(--worsening-color, #ef4444);
    padding: 1px 2px;
    border-radius: 2px;
    text-decoration: line-through;
}

.diff-unchanged {
    color: var(--text-color, #e2e8f0);
}

/* ----------------------------------------------------------------------------
   CHANGE COUNT BADGE
   Displayed in history item header, after source badge
   ---------------------------------------------------------------------------- */

.problem-card__diff-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: 6px;
}

/* Has changes - amber/yellow to draw attention */
.problem-card__diff-badge--changes {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

/* No changes - subtle gray */
.problem-card__diff-badge--unchanged {
    background: rgba(100, 116, 139, 0.15);
    border: 1px solid rgba(100, 116, 139, 0.3);
    color: #94a3b8;
}

/* Initial entry (no prior day to compare) - blue */
.problem-card__diff-badge--initial {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

/* ----------------------------------------------------------------------------
   DIFF DISPLAY SECTION
   Shown when history item is expanded, below preview
   ---------------------------------------------------------------------------- */

.problem-card__diff-section {
    margin-top: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border-left: 3px solid rgba(100, 116, 139, 0.4);
}

.problem-card__diff-section--hidden {
    display: none;
}

.problem-card__diff-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 6px;
}

.problem-card__diff-content {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-color, #e2e8f0);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.problem-card__diff-content--assessment {
    margin-bottom: 12px;
}

.problem-card__diff-content--plan {
    /* Last item, no bottom margin */
}

/* Diff section divider */
.problem-card__diff-divider {
    height: 1px;
    background: rgba(100, 116, 139, 0.3);
    margin: 12px 0;
}

/* Empty diff message */
.problem-card__diff-empty {
    font-size: 11px;
    font-style: italic;
    color: #64748b;
    padding: 8px 0;
}

/* ----------------------------------------------------------------------------
   CLICKABLE HISTORY ITEM HEADERS
   Visual affordance for expand/collapse diff interaction
   ---------------------------------------------------------------------------- */

.problem-card__history-item-header {
    cursor: pointer;
    padding: 4px 0;
    margin: -4px 0;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.problem-card__history-item-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Chevron indicator for expandable diff */
.problem-card__history-item-header::before {
    content: '\25B8';  /* Right-pointing triangle */
    display: inline-block;
    width: 12px;
    font-size: 8px;
    color: #64748b;
    margin-right: 4px;
    transition: transform 0.15s ease;
}

/* Rotated chevron when diff is visible */
.problem-card__history-item:has(.problem-card__diff-section:not(.problem-card__diff-section--hidden))
.problem-card__history-item-header::before {
    transform: rotate(90deg);
    color: #94a3b8;
}

/* Don't show chevron for first entry (no diff to show) */
.problem-card__history-item:has(.problem-card__diff-badge--initial)
.problem-card__history-item-header::before {
    visibility: hidden;
}

/* ============================================================================
   PHASE 13: PRIMARY PROBLEM HIGHLIGHTING (2026-01)
   Visual treatment for primary/core admission problems
   ============================================================================ */

/* ----------------------------------------------------------------------------
   PRIMARY CARD COLOR VARIABLE
   ---------------------------------------------------------------------------- */

.problem-card {
    --primary-color: #6366f1;  /* Indigo-500 */
}

/* ----------------------------------------------------------------------------
   PRIMARY CARD LEFT BORDER
   4px indigo border, overrides trajectory 3px borders
   ---------------------------------------------------------------------------- */

.problem-card--primary {
    border-left: 4px solid var(--primary-color) !important;
}

/* ----------------------------------------------------------------------------
   PRIMARY STAR ICON
   Shows filled star for primary, hollow on hover for non-primary
   ---------------------------------------------------------------------------- */

.problem-card__primary-star {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.problem-card--primary .problem-card__primary-star {
    color: var(--primary-color);
}

.problem-card:not(.problem-card--primary) .problem-card__primary-star {
    opacity: 0;
}

.problem-card:not(.problem-card--primary):hover .problem-card__primary-star {
    opacity: 1;
}

.problem-card__primary-star:disabled {
    cursor: wait;
    opacity: 0.5;
}

/* ----------------------------------------------------------------------------
   PRIMARY BADGE
   Appears next to problem name for primary problems
   ---------------------------------------------------------------------------- */

.problem-card__primary-badge {
    display: inline-flex;
    padding: 2px 6px;
    margin-left: 6px;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    color: #818cf8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ----------------------------------------------------------------------------
   RELATIONSHIP BADGES (Phase 15)
   Child badge shows parent, parent badge shows child count
   ---------------------------------------------------------------------------- */

/* Child badge (shows parent) - Purple tint per CONTEXT.md */
.problem-card__parent-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    margin-left: 6px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    color: #a78bfa;
    white-space: nowrap;
}

.problem-card__parent-badge::before {
    content: '→';
    font-size: 11px;
    margin-right: 2px;
}

/* Parent badge (shows child count) - Green tint per CONTEXT.md */
.problem-card__related-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    margin-left: 6px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    color: #4ade80;
    white-space: nowrap;
}

/* Suggested relationship modifier - dashed border, muted */
.problem-card__parent-badge--suggested {
    border-style: dashed;
    opacity: 0.85;
}

.problem-card__parent-badge--suggested::after {
    content: '?';
    font-size: 9px;
    margin-left: 2px;
    opacity: 0.7;
}

/* Suggested parent badge also dashed */
.problem-card__related-badge--suggested {
    border-style: dashed;
    opacity: 0.85;
}

/* ----------------------------------------------------------------------------
   SMOOTH TIER MOVEMENT TRANSITION
   For re-sorting when primary status changes
   ---------------------------------------------------------------------------- */

.problem-card {
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.25s ease-out;
}

/* ----------------------------------------------------------------------------
   ACID-BASE INSIGHT BADGES (Phase 7 - 2026-01-22)
   Clinical decision support badges for acid-base disorder analysis
   ---------------------------------------------------------------------------- */

.problem-card__insight-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 500;
    padding: 2px 6px;
    margin-left: 6px;
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    white-space: nowrap;
    vertical-align: middle;
    cursor: help;
}

/* Critical acid-base disorder - red with subtle pulse */
.problem-card__insight-badge--critical {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    animation: pulse-insight-badge 2s ease-in-out infinite;
}

@keyframes pulse-insight-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Dark theme adjustments */
@media (prefers-color-scheme: dark) {
    .problem-card__insight-badge {
        background: rgba(59, 130, 246, 0.25);
        color: #60a5fa;
    }

    .problem-card__insight-badge--critical {
        background: rgba(239, 68, 68, 0.3);
        color: #f87171;
    }
}

/* ============================================================================
   THREE-DOT MENU (Phase 16)
   Problem card action menu for link/unlink operations
   ============================================================================ */

/* Menu container - positions dropdown relative to button */
.problem-card__menu-container {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}

/* Three-dot button */
.problem-card__menu-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted, #64748b);
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    opacity: 0;
}

.problem-card__header:hover .problem-card__menu-btn,
.problem-card__menu-btn:focus,
.problem-card__menu-btn[aria-expanded="true"] {
    opacity: 1;
}

.problem-card__menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color, #e2e8f0);
}

.problem-card__menu-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Dropdown menu */
.problem-card__menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 160px;
    background: var(--surface-color, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 100;
    overflow: hidden;
    animation: menuFadeIn 0.1s ease-out;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Menu item */
.problem-card__menu-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-color, #e2e8f0);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.problem-card__menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.problem-card__menu-item:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
}

/* Danger item (unlink) */
.problem-card__menu-item--danger {
    color: #f87171;
}

.problem-card__menu-item--danger:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Divider between menu sections */
.problem-card__menu-divider {
    height: 1px;
    background: var(--border-color, #334155);
    margin: 4px 0;
}

/* ============================================================================
   PHASE 16: PROBLEM LINK MODAL (2026-01)
   Searchable problem picker for manual linking
   ============================================================================ */

/* Modal overlay */
.sol-link-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: linkModalFadeIn 0.15s ease-out;
}

@keyframes linkModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal container */
.sol-link-modal {
    background: var(--surface-color, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    width: 90%;
    max-width: 400px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    animation: linkModalSlideUp 0.2s ease-out;
}

@keyframes linkModalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.sol-link-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #334155);
}

.sol-link-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color, #e2e8f0);
}

/* Search input */
.sol-link-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #334155);
}

.sol-link-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #334155);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-color, #e2e8f0);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease;
}

.sol-link-search-input:focus {
    border-color: #3b82f6;
}

.sol-link-search-input::placeholder {
    color: var(--text-muted, #64748b);
}

/* Problem list */
.sol-link-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    max-height: 300px;
}

.sol-link-list::-webkit-scrollbar {
    width: 6px;
}

.sol-link-list::-webkit-scrollbar-track {
    background: transparent;
}

.sol-link-list::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

/* Problem option button */
.sol-link-option {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-color, #e2e8f0);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.sol-link-option:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
}

.sol-link-option:focus {
    outline: none;
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.5);
}

.sol-link-option:last-child {
    margin-bottom: 0;
}

/* Empty state */
.sol-link-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted, #64748b);
    font-size: 13px;
    font-style: italic;
}

/* Footer */
.sol-link-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, #334155);
    display: flex;
    justify-content: flex-end;
}

/* Generic button styles (if not already defined) */
.sol-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sol-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color, #475569);
    color: var(--text-muted, #94a3b8);
}

.sol-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #64748b;
    color: var(--text-color, #e2e8f0);
}

/* ----------------------------------------------------------------------------
   MANUAL LINK INDICATOR (chain icon on parent badge)
   Shows when relationship is source='user' (manual) vs 'ontology'
   ---------------------------------------------------------------------------- */

.problem-card__parent-badge--manual::after {
    content: ' \1F517';  /* Chain link emoji */
    font-size: 10px;
    margin-left: 2px;
}

/* Alternative: Use CSS chain icon if emoji not rendering well */
.problem-card__parent-badge--manual-icon::after {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 4px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    vertical-align: middle;
}

/* ============================================================================
   PHASE 20: GENERATION STATUS INDICATORS (2026-01)
   Visual feedback for per-problem generation workflow states
   ============================================================================ */

/* Generation status colors */
.problem-card {
    --census-blue: #3b82f6;
    --census-blue-light: #dbeafe;
    --census-green: #22c55e;
    --census-green-light: #dcfce7;
    --census-green-dark: #166534;
    --census-red: #ef4444;
    --census-red-light: #fee2e2;
    --census-red-dark: #991b1b;
    --census-gray-100: #f3f4f6;
    --census-gray-400: #9ca3af;
    --census-gray-600: #4b5563;
}

/* ----------------------------------------------------------------------------
   STATUS BORDER INDICATORS
   Left border for visual scanning of generation state
   ---------------------------------------------------------------------------- */

.problem-card--pending {
    border-left: 3px solid var(--census-gray-400, #9ca3af);
}

.problem-card--generating {
    border-left: 3px solid var(--census-blue, #3b82f6);
    animation: generating-pulse 2s ease-in-out infinite;
}

.problem-card--generated {
    border-left: 3px solid var(--census-green, #22c55e);
}

.problem-card--failed {
    border-left: 3px solid var(--census-red, #ef4444);
}

@keyframes generating-pulse {
    0%, 100% { border-left-color: var(--census-blue, #3b82f6); }
    50% { border-left-color: rgba(59, 130, 246, 0.5); }
}

/* ----------------------------------------------------------------------------
   GENERATION STATUS BADGE
   Displayed in problem card header to indicate generation state
   ---------------------------------------------------------------------------- */

.problem-card__generation-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(100, 116, 139, 0.15);
    color: var(--census-gray-600, #64748b);
    margin-left: 8px;
}

.problem-card__generation-badge--generating {
    background: rgba(59, 130, 246, 0.15);
    color: var(--census-blue, #3b82f6);
}

.problem-card__generation-badge--generating .badge-icon {
    animation: spin 1s linear infinite;
}

.problem-card__generation-badge--generated {
    background: rgba(34, 197, 94, 0.15);
    color: var(--census-green-dark, #166534);
}

.problem-card__generation-badge--accepted {
    background: var(--census-green, #22c55e);
    color: white;
}

.problem-card__generation-badge--failed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--census-red, #ef4444);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------------------
   A&P SKELETON LOADING
   Shimmer animation while waiting for LLM generation
   ---------------------------------------------------------------------------- */

.problem-card__ap-skeleton {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
}

.problem-card__ap-skeleton .skeleton-line {
    height: 14px;
    background: linear-gradient(
        90deg,
        rgba(107, 114, 128, 0.1) 0%,
        rgba(107, 114, 128, 0.2) 50%,
        rgba(107, 114, 128, 0.1) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ----------------------------------------------------------------------------
   ERROR BANNER
   Displayed when generation fails, with retry option
   ---------------------------------------------------------------------------- */

.problem-card__error-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--census-red-dark, #991b1b);
}

.problem-card__error-banner .error-icon {
    font-size: 16px;
    color: var(--census-red, #ef4444);
}

.problem-card__error-banner .error-text {
    flex: 1;
}

.problem-card__retry-btn {
    padding: 4px 12px;
    background: var(--census-red, #ef4444);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.problem-card__retry-btn:hover {
    background: #dc2626;
}

.problem-card__retry-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ----------------------------------------------------------------------------
   ACCEPTED BADGE (Phase 18/20 unified)
   Shows when A&P has been accepted by clinician
   ---------------------------------------------------------------------------- */

.problem-card__accepted-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    color: #4ade80;
    margin-left: auto;
}

.problem-card__accepted-badge .badge-icon {
    font-weight: 700;
}

/* Staleness modifiers for accepted badge */
.problem-card__accepted-badge--stale {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

.problem-card__accepted-badge--very-stale {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* Expand hint for collapsed accepted cards */
.problem-card__expand-hint {
    padding: 4px 10px;
    margin-left: 8px;
    background: transparent;
    border: 1px solid rgba(100, 116, 139, 0.3);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    transition: all 0.15s ease;
}

.problem-card__expand-hint:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(100, 116, 139, 0.5);
    color: var(--text-color, #e2e8f0);
}

/* Collapsed card state */
.problem-card--collapsed .problem-card__body {
    display: none;
}

/* ============================================================================
   PHASE 20: Include Prior A&P Toggle and Generate Button
   ============================================================================ */

/* Include Prior A&P Toggle */
.problem-card__include-prior {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}

.problem-card__include-prior-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--census-blue, #3b82f6);
}

.problem-card__include-prior-label {
    user-select: none;
}

/* Generate button (Phase 20) */
.problem-card__generate-btn {
    padding: 6px 12px;
    background: var(--census-blue, #3b82f6);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.problem-card__generate-btn:hover {
    background: #2563eb;
}

.problem-card__generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Action button group layout */
.problem-card__ap-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* ============================================================================
   REFINE PANEL (Phase 21)
   Collapsible panel for natural language A&P refinement
   Pattern: Matches history section (lines 771-823)
   ============================================================================ */

.problem-card__refine-section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--card-border);
}

.problem-card__refine-section--collapsed .problem-card__refine-body {
    display: none;
}

/* Refine toggle button (matches history toggle) */
.problem-card__refine-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    margin: 0 -8px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    color: var(--text-muted, #94a3b8);
    transition: background 0.15s ease;
}

.problem-card__refine-toggle:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.04);
}

.problem-card__refine-toggle:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.problem-card__refine-toggle:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.problem-card__refine-toggle-icon {
    flex-shrink: 0;
    width: 12px;
    font-size: 10px;
    color: #64748b;
    transition: transform 0.15s ease;
}

.problem-card__refine-toggle:hover:not(:disabled) .problem-card__refine-toggle-icon {
    color: #94a3b8;
}

.problem-card__refine-toggle-label {
    font-size: 12px;
    font-weight: 500;
}

/* Refine body (collapsed by default) */
.problem-card__refine-body {
    padding: 12px 0;
}

.problem-card__refine-body--collapsed {
    display: none;
}

/* Refine textarea input */
.problem-card__refine-input {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-primary, #f1f5f9);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}

.problem-card__refine-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.problem-card__refine-input::placeholder {
    color: var(--text-muted, #64748b);
}

/* Refine actions row */
.problem-card__refine-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

/* Apply button */
.problem-card__refine-apply-btn {
    padding: 6px 16px;
    background: #3b82f6;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.problem-card__refine-apply-btn:hover:not(:disabled) {
    background: #2563eb;
}

.problem-card__refine-apply-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.problem-card__refine-apply-btn:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

/* Refine diff container (populated in Plan 02) */
.problem-card__refine-diff {
    margin-top: 12px;
}

.problem-card__refine-diff:empty {
    display: none;
}

/* ----------------------------------------------------------------------------
   Refinement Diff Display (Phase 21)
   ---------------------------------------------------------------------------- */

.problem-card__refine-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
}

.problem-card__refine-no-change {
    padding: 12px;
    text-align: center;
    color: var(--text-muted, #64748b);
    font-size: 13px;
    font-style: italic;
}

.problem-card__refine-diff-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.problem-card__refine-diff-summary {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}

.problem-card__refine-diff-content {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 12px;
    border-left: 3px solid rgba(59, 130, 246, 0.5);
}

.problem-card__refine-diff-assessment,
.problem-card__refine-diff-plan {
    margin-bottom: 12px;
}

.problem-card__refine-diff-assessment:last-child,
.problem-card__refine-diff-plan:last-child {
    margin-bottom: 0;
}

.problem-card__refine-diff-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.problem-card__refine-diff-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary, #f1f5f9);
}

/* Diff word styling - reuse from conflict modal */
.problem-card__refine-diff-text .diff-added {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    padding: 1px 2px;
    border-radius: 2px;
}

.problem-card__refine-diff-text .diff-removed {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    text-decoration: line-through;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Accept/Reject decision buttons */
.problem-card__refine-decision {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.problem-card__refine-accept-btn {
    padding: 6px 16px;
    background: #22c55e;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.problem-card__refine-accept-btn:hover {
    background: #16a34a;
}

.problem-card__refine-accept-btn:focus-visible {
    outline: 2px solid #86efac;
    outline-offset: 2px;
}

.problem-card__refine-reject-btn {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.problem-card__refine-reject-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.problem-card__refine-reject-btn:focus-visible {
    outline: 2px solid #64748b;
    outline-offset: 2px;
}
