/* ============================================
   PROBLEM OVERVIEW REDESIGN
   ============================================
   ARCHITECTURE: Large, scannable problem cards replacing tiny tree sidebar
   WHY: Original 9-12px text too small to read; sublines cut off
   TRADEOFF: Takes more vertical space for significantly better readability

   DESIGN PHILOSOPHY:
   - "Clinical Whiteboard" aesthetic - like a nursing station board
   - Large, bold problem titles (18-20px)
   - Clear visual hierarchy for status (included/excluded/merged)
   - Key clinical context visible without hover or truncation
   - Color-coded severity bands with high contrast
   ============================================ */

/* ============================================
   PROBLEM OVERVIEW CONTAINER - Replaces tiny tree
   ============================================ */
.problem-overview-section {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(10, 15, 26, 0.98));
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 20px;
    padding: 0;
    margin-bottom: 24px;
    overflow: hidden;
    animation: overviewFadeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

/* ============================================
   OVERVIEW HEADER - Clear section title
   ============================================ */
.overview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(99, 102, 241, 0.04));
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.overview-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.overview-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.overview-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.overview-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.overview-title {
    font-size: 20px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.01em;
    margin: 0;
}

.overview-subtitle {
    font-size: 14px;
    color: #94a3b8;
}

/* Stats Pills */
.overview-stats {
    display: flex;
    gap: 12px;
}

.overview-stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all 0.2s ease;
}

.overview-stat-pill .stat-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
}

.overview-stat-pill.included {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.3);
}

.overview-stat-pill.included .stat-number {
    color: #22c55e;
}

.overview-stat-pill.excluded {
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.2);
}

.overview-stat-pill.merged {
    color: #a78bfa;
    border-color: rgba(167, 139, 250, 0.3);
}

/* ============================================
   PROBLEM CARDS - Large, readable cards
   ============================================ */
.overview-body {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Category Group */
.overview-category {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.overview-category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.overview-category-header .category-icon {
    font-size: 18px;
}

.overview-category-header .category-count {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
}

/* Category Colors */
.overview-category.critical .overview-category-header {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(255, 107, 107, 0.08));
    color: #fca5a5;
    border-left: 4px solid #ef4444;
}

.overview-category.improving .overview-category-header {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.15), rgba(74, 222, 128, 0.06));
    color: #86efac;
    border-left: 4px solid #22c55e;
}

.overview-category.active .overview-category-header {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(96, 165, 250, 0.06));
    color: #93c5fd;
    border-left: 4px solid #3b82f6;
}

.overview-category.chronic .overview-category-header {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(251, 191, 36, 0.05));
    color: #fcd34d;
    border-left: 4px solid #f59e0b;
}

/* Problem Card List */
.overview-problem-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-left: 8px;
}

/* Individual Problem Card */
.overview-problem-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: start;
    padding: 18px 20px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 14px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.overview-problem-card:hover {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateX(4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Excluded state */
.overview-problem-card.excluded {
    opacity: 0.5;
    border-style: dashed;
}

.overview-problem-card.excluded:hover {
    opacity: 0.7;
}

.overview-problem-card.excluded .problem-title-text {
    text-decoration: line-through;
    color: #64748b;
}

/* Merged state */
.overview-problem-card.merged-into {
    opacity: 0.6;
    border-left: 3px solid #a78bfa;
}

.overview-problem-card.merged-into .problem-title-text::after {
    content: ' → merged';
    color: #a78bfa;
    font-size: 12px;
    font-weight: 500;
    margin-left: 8px;
}

/* Checkbox / Status Indicator */
.overview-checkbox-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 2px;
}

.overview-checkbox {
    appearance: none;
    width: 26px;
    height: 26px;
    border: 2px solid #64748b;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    background: transparent;
}

.overview-checkbox:checked {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: #22c55e;
}

.overview-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    width: 7px;
    height: 12px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

.overview-checkbox:hover {
    border-color: #a78bfa;
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.15);
}

.overview-checkbox:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

/* Problem Content - Main Area */
.overview-problem-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

/* Problem Title Row */
.problem-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.problem-title-text {
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1.3;
}

/* Trend Badge */
.problem-trend-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.problem-trend-badge.worsening {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.problem-trend-badge.worsening svg {
    color: #ef4444;
}

.problem-trend-badge.improving {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.problem-trend-badge.improving svg {
    color: #22c55e;
}

.problem-trend-badge.stable {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.problem-trend-badge.stable svg {
    color: #f59e0b;
}

.problem-trend-badge svg {
    width: 14px;
    height: 14px;
}

/* Source Badge */
.problem-source-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.problem-source-badge.ai {
    background: rgba(167, 139, 250, 0.2);
    color: #c4b5fd;
}

.problem-source-badge.manual {
    background: rgba(96, 165, 250, 0.2);
    color: #93c5fd;
}

/* Key Data Section - THE CRITICAL CONTEXT */
.problem-key-data {
    font-size: 15px;
    color: #cbd5e1;
    line-height: 1.6;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 10px;
    border-left: 3px solid rgba(148, 163, 184, 0.3);
}

.problem-key-data:empty {
    display: none;
}

/* Evidence Quote */
.problem-evidence-quote {
    font-size: 14px;
    color: #99f6e4;
    font-style: italic;
    padding: 10px 14px;
    background: rgba(20, 184, 166, 0.1);
    border-radius: 10px;
    border-left: 3px solid #14b8a6;
    line-height: 1.5;
}

/* Merged Children Indicator */
.problem-merged-children {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.merged-child-tag {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 16px;
    background: rgba(167, 139, 250, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(167, 139, 250, 0.25);
    display: flex;
    align-items: center;
    gap: 6px;
}

.merged-child-tag svg {
    width: 12px;
    height: 12px;
    color: #a78bfa;
}

/* Right Side Actions */
.overview-problem-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.problem-confidence-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.problem-confidence-score.high {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.3);
}

.problem-confidence-score.medium {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
}

.problem-confidence-score.low {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

/* Action Menu Button */
.problem-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.overview-problem-card:hover .problem-action-btn {
    opacity: 1;
}

.problem-action-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
}

.problem-action-btn svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   HOSPITAL CONTEXT SUMMARY - Top-level context
   ============================================ */
.hospital-context-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.context-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.context-item-icon.day {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

.context-item-icon.admission {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
}

.context-item-icon.trend {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

.context-item-text {
    display: flex;
    flex-direction: column;
}

.context-item-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.context-item-value {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
}

/* ============================================
   LEGEND / HELP STRIP
   ============================================ */
.overview-legend {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 10px;
    margin-top: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
}

.legend-indicator {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.legend-indicator.included {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.legend-indicator.excluded {
    background: transparent;
    border: 2px dashed #64748b;
}

.legend-indicator.merged {
    background: rgba(167, 139, 250, 0.3);
    border-left: 3px solid #a78bfa;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.overview-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.overview-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: #64748b;
}

.overview-empty-icon svg {
    width: 32px;
    height: 32px;
}

.overview-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 8px;
}

.overview-empty-description {
    font-size: 14px;
    color: #64748b;
    max-width: 300px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 900px) {
    .overview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .overview-stats {
        flex-wrap: wrap;
    }

    .overview-problem-card {
        grid-template-columns: auto 1fr;
    }

    .overview-problem-actions {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: flex-end;
        margin-top: 8px;
        padding-top: 12px;
        border-top: 1px solid rgba(148, 163, 184, 0.1);
    }

    .hospital-context-bar {
        flex-wrap: wrap;
        gap: 16px;
    }
}

@media (max-width: 600px) {
    .overview-header {
        padding: 16px 18px;
    }

    .overview-body {
        padding: 16px 18px;
    }

    .overview-icon {
        width: 40px;
        height: 40px;
    }

    .overview-title {
        font-size: 18px;
    }

    .overview-stat-pill {
        padding: 8px 14px;
    }

    .overview-stat-pill .stat-number {
        font-size: 16px;
    }

    .problem-title-text {
        font-size: 16px;
    }

    .problem-key-data {
        font-size: 14px;
    }

    .overview-problem-card {
        padding: 14px 16px;
    }
}

/* ============================================
   HIDE OLD TREE SIDEBAR WHEN OVERVIEW IS PRESENT
   ============================================ */
.problem-approval-body:has(.problem-overview-section) .problem-tree-sidebar {
    display: none;
}

.problem-approval-body:has(.problem-overview-section) .problem-modal-content {
    grid-template-columns: 1fr;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .problem-overview-section {
        background: white;
        border: 1px solid #ccc;
    }

    .overview-problem-card {
        background: white;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }

    .problem-title-text {
        color: #111;
    }

    .problem-key-data {
        color: #333;
        background: #f9f9f9;
    }
}
