/* ==========================================================================
   Problem Detail Panel - Clinical Context Display (2025-12-10)
   Phase 2 of Clinical Dashboard Improvements
   ========================================================================== */

/* Panel container - slides in from right */
.problem-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 90vw;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.problem-detail-panel.visible {
    pointer-events: auto;
    opacity: 1;
    transform: translateX(0);
}

/* Backdrop */
.problem-detail-panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: -1;
}

/* Main content area */
.pdp-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: var(--sol-bg-elevated, #1c1f2a);
    border-left: 1px solid var(--sol-border, rgba(255, 255, 255, 0.1));
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
}

/* Header */
.pdp-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.pdp-header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.pdp-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--sol-text-primary, #f8fafc);
    margin: 0;
    line-height: 1.3;
    flex: 1;
}

.pdp-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: var(--sol-text-secondary, #94a3b8);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.pdp-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.pdp-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.pdp-status {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pdp-severity {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sol-text-secondary, #94a3b8);
}

.pdp-severity-critical {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.pdp-severity-high {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.pdp-severity-moderate {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.pdp-severity-low {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.pdp-category {
    font-size: 0.6875rem;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
}

.pdp-onset {
    font-size: 0.75rem;
    color: var(--sol-text-tertiary, #64748b);
}

/* Body - scrollable */
.pdp-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* Sections */
.pdp-section {
    margin-bottom: 24px;
}

.pdp-section:last-child {
    margin-bottom: 0;
}

.pdp-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sol-text-tertiary, #64748b);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pdp-section-title svg {
    opacity: 0.6;
}

.pdp-section-text {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--sol-text-primary, #f8fafc);
    margin: 0;
}

.pdp-section-empty .pdp-section-title {
    opacity: 0.5;
}

.pdp-empty-text {
    font-size: 0.875rem;
    color: var(--sol-text-tertiary, #64748b);
    font-style: italic;
    margin: 0;
}

/* Bullet lists */
.pdp-bullet-list {
    margin: 0;
    padding: 0 0 0 20px;
    list-style: none;
}

.pdp-bullet-list li {
    position: relative;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--sol-text-primary, #f8fafc);
    margin-bottom: 8px;
    padding-left: 4px;
}

.pdp-bullet-list li:last-child {
    margin-bottom: 0;
}

.pdp-bullet-list li::before {
    content: '•';
    position: absolute;
    left: -16px;
    color: var(--sol-accent, #3b82f6);
    font-weight: bold;
}

/* Stop criteria specific styling */
.pdp-criteria-list li::before {
    content: '○';
    color: #22c55e;
}

/* Followup list styling */
.pdp-followup-list li::before {
    content: '→';
    color: #f59e0b;
}

/* Evidence section */
.pdp-section-evidence {
    background: rgba(0, 0, 0, 0.2);
    margin-left: -24px;
    margin-right: -24px;
    padding: 20px 24px;
}

.pdp-evidence-group {
    margin-bottom: 16px;
}

.pdp-evidence-group:last-child {
    margin-bottom: 0;
}

.pdp-evidence-group-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sol-text-tertiary, #64748b);
    margin: 0 0 8px;
}

/* Status history timeline */
.pdp-evidence-timeline {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pdp-evidence-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border-left: 3px solid transparent;
}

.pdp-evidence-item.pdp-status-worsening {
    border-left-color: #ef4444;
}

.pdp-evidence-item.pdp-status-active {
    border-left-color: #f59e0b;
}

.pdp-evidence-item.pdp-status-improving {
    border-left-color: #22c55e;
}

.pdp-evidence-item.pdp-status-resolved {
    border-left-color: #6b7280;
}

.pdp-evidence-day {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sol-text-secondary, #94a3b8);
    min-width: 48px;
}

.pdp-evidence-status {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--sol-text-primary, #f8fafc);
    flex: 1;
}

.pdp-evidence-date {
    font-size: 0.6875rem;
    color: var(--sol-text-tertiary, #64748b);
}

/* Evidence list */
.pdp-evidence-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pdp-evidence-kind {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    flex-shrink: 0;
}

.pdp-evidence-text {
    font-size: 0.8125rem;
    color: var(--sol-text-primary, #f8fafc);
    flex: 1;
}

/* Lab trends in evidence */
.pdp-lab-trends {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.pdp-lab-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.pdp-lab-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sol-text-tertiary, #64748b);
    min-width: 32px;
}

.pdp-lab-current {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--sol-text-primary, #f8fafc);
}

.pdp-lab-sparkline {
    margin-left: auto;
}

/* Scrollbar */
.pdp-body::-webkit-scrollbar {
    width: 6px;
}

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

.pdp-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.pdp-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .problem-detail-panel {
        transition: opacity 0.1s ease;
        transform: translateX(0);
    }

    .problem-detail-panel:not(.visible) {
        visibility: hidden;
    }
}

/* Responsive - smaller screens */
@media (max-width: 768px) {
    .problem-detail-panel {
        width: 100%;
        max-width: none;
    }

    .pdp-lab-trends {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   DETAILED CHARTS SECTION (2025-12-14)
   Expandable trend charts for labs, vitals, and clinical scores
   ========================================================================== */

/* Charts section */
.pdp-section-charts {
    border: 1px solid rgba(96, 165, 250, 0.2);
    background: rgba(96, 165, 250, 0.05);
}

.pdp-section-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.pdp-section-toggle:hover {
    color: var(--sol-accent, #60a5fa);
}

.pdp-section-toggle:focus {
    outline: 2px solid var(--sol-accent, #60a5fa);
    outline-offset: 2px;
}

.pdp-toggle-icon {
    margin-left: auto;
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--sol-text-secondary, #94a3b8);
    transition: transform 0.2s;
}

.pdp-charts-container {
    padding-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Individual chart card */
.pdp-detail-chart {
    flex: 1 1 calc(50% - 6px);
    min-width: 140px;
    background: var(--sol-bg-elevated, #1e1e2e);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.pdp-score-chart {
    border-color: rgba(96, 165, 250, 0.3);
}

.pdp-detail-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pdp-detail-chart-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sol-text-primary, #e0e0e0);
}

.pdp-detail-chart-current {
    font-size: 0.85rem;
    font-weight: 700;
}

.pdp-detail-chart-current.trend-up {
    color: #ef4444;
}

.pdp-detail-chart-current.trend-down {
    color: #22c55e;
}

.pdp-detail-chart-current.trend-flat {
    color: #64748b;
}

.pdp-detail-chart-body {
    padding: 8px;
}

.pdp-detail-chart-svg {
    width: 100%;
    height: auto;
    max-height: 60px;
}

.pdp-detail-chart-footer {
    display: flex;
    justify-content: space-between;
    padding: 4px 10px;
    font-size: 0.6rem;
    color: var(--sol-text-secondary, #707080);
    background: rgba(0, 0, 0, 0.1);
}

/* Responsive: stack charts on small screens */
@media (max-width: 400px) {
    .pdp-detail-chart {
        flex: 1 1 100%;
    }
}

/* ==========================================================================
   PLAN EVOLUTION SECTION (2025-12-31)
   Side-by-side diff view: Yesterday's Plan vs Today's Plan
   Reuses provenance.css color variables for consistency
   ========================================================================== */

/* Section container with distinctive background */
.pdp-section-plan-evolution {
    background: rgba(0, 0, 0, 0.2);
    margin-left: -24px;
    margin-right: -24px;
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Two-column grid layout */
.pdp-plan-evolution {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Individual column */
.pdp-plan-column {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.pdp-plan-column-header {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sol-text-tertiary, #64748b);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Base bullet styling */
.pdp-plan-bullets {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pdp-plan-bullet {
    font-size: 0.8125rem;
    line-height: 1.5;
    padding: 6px 10px;
    border-radius: 4px;
    border-left: 3px solid transparent;
    transition: background 0.15s ease;
}

/* Unchanged - green (carried forward from yesterday) */
.pdp-plan-bullet-unchanged {
    background: var(--prov-carried-forward-bg, rgba(34, 197, 94, 0.12));
    border-left-color: var(--prov-carried-forward-border, rgba(34, 197, 94, 0.5));
    color: var(--sol-text-primary, #f8fafc);
}

/* Added - blue (new today) */
.pdp-plan-bullet-added {
    background: var(--prov-today-evidence-bg, rgba(59, 130, 246, 0.12));
    border-left-color: var(--prov-today-evidence-border, rgba(59, 130, 246, 0.5));
    color: var(--sol-text-primary, #f8fafc);
}

.pdp-plan-bullet-added::before {
    content: '+ ';
    font-weight: 700;
    color: #3b82f6;
}

/* Removed - red (dropped from today) */
.pdp-plan-bullet-removed {
    background: var(--prov-lost-content-bg, rgba(239, 68, 68, 0.12));
    border-left-color: var(--prov-lost-content-border, rgba(239, 68, 68, 0.5));
    color: var(--sol-text-secondary, #94a3b8);
    text-decoration: line-through;
    opacity: 0.8;
}

.pdp-plan-bullet-removed::before {
    content: '− ';
    font-weight: 700;
    color: #ef4444;
}

/* Changed - amber (modified from yesterday) */
.pdp-plan-bullet-changed {
    background: var(--prov-llm-synthesis-bg, rgba(251, 191, 36, 0.12));
    border-left-color: var(--prov-llm-synthesis-border, rgba(251, 191, 36, 0.5));
    color: var(--sol-text-primary, #f8fafc);
}

.pdp-plan-bullet-changed::before {
    content: '~ ';
    font-weight: 700;
    color: #fbbf24;
}

/* Empty state */
.pdp-plan-empty {
    font-size: 0.8125rem;
    color: var(--sol-text-tertiary, #64748b);
    font-style: italic;
    padding: 8px 0;
}

/* Summary bar */
.pdp-plan-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.pdp-plan-stat {
    font-size: 0.75rem;
    color: var(--sol-text-secondary, #94a3b8);
    display: flex;
    align-items: center;
    gap: 4px;
}

.pdp-plan-stat-count {
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

.pdp-plan-stat-unchanged .pdp-plan-stat-count {
    color: #22c55e;
}

.pdp-plan-stat-added .pdp-plan-stat-count {
    color: #3b82f6;
}

.pdp-plan-stat-removed .pdp-plan-stat-count {
    color: #ef4444;
}

.pdp-plan-stat-changed .pdp-plan-stat-count {
    color: #fbbf24;
}

/* New problem indicator */
.pdp-plan-new-problem {
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed rgba(59, 130, 246, 0.4);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    color: #93c5fd;
    font-size: 0.8125rem;
}

/* Day 1 indicator */
.pdp-plan-day1 {
    background: rgba(139, 92, 246, 0.1);
    border: 1px dashed rgba(139, 92, 246, 0.4);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    color: #c4b5fd;
    font-size: 0.8125rem;
}

/* No changes state */
.pdp-plan-no-changes {
    text-align: center;
    padding: 12px;
    background: rgba(34, 197, 94, 0.08);
    border-radius: 6px;
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #86efac;
    font-size: 0.8125rem;
}

/* Responsive: stack columns on small screens */
@media (max-width: 500px) {
    .pdp-plan-evolution {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   PRIOR GENERATED A&P SECTION (2026-01)
   Shows actual prose from most recently generated note for this problem
   ========================================================================== */

/* Section container - highlighted with cyan accent for visibility */
.pdp-section-prior-ap {
    background: linear-gradient(135deg,
        rgba(34, 211, 238, 0.08) 0%,
        rgba(59, 130, 246, 0.05) 100%);
    margin-left: -24px;
    margin-right: -24px;
    padding: 20px 24px;
    border-top: 1px solid rgba(34, 211, 238, 0.2);
    border-bottom: 1px solid rgba(34, 211, 238, 0.2);
}

/* Date badge in header */
.pdp-prior-ap-date {
    font-weight: 400;
    font-size: 0.6875rem;
    color: var(--sol-text-tertiary, #64748b);
    margin-left: 4px;
}

/* Content wrapper */
.pdp-prior-ap-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Assessment/Plan subsection */
.pdp-prior-ap-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Label (ASSESSMENT / PLAN) */
.pdp-prior-ap-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #22d3ee;
    padding: 2px 8px;
    background: rgba(34, 211, 238, 0.15);
    border-radius: 4px;
    width: fit-content;
}

/* Assessment prose text */
.pdp-prior-ap-text {
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--sol-text-primary, #f8fafc);
    margin: 0;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid rgba(34, 211, 238, 0.4);
    /* Allow text to wrap nicely with proper line breaks */
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Plan bullet list */
.pdp-prior-ap-plan {
    margin: 0;
    padding: 0;
    list-style: none;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid rgba(59, 130, 246, 0.4);
    overflow: hidden;
}

.pdp-prior-ap-plan li {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--sol-text-primary, #f8fafc);
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    position: relative;
    padding-left: 28px;
}

.pdp-prior-ap-plan li:last-child {
    border-bottom: none;
}

.pdp-prior-ap-plan li::before {
    content: '•';
    position: absolute;
    left: 12px;
    color: #3b82f6;
    font-weight: bold;
}

/* Hover effect for readability */
.pdp-prior-ap-text:hover,
.pdp-prior-ap-plan li:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Responsive: ensure readability on small screens */
@media (max-width: 500px) {
    .pdp-section-prior-ap {
        padding: 16px 16px;
        margin-left: -16px;
        margin-right: -16px;
    }

    .pdp-prior-ap-text,
    .pdp-prior-ap-plan li {
        font-size: 0.8125rem;
    }
}
