/**
 * Problem Kanban Board Styles
 *
 * ARCHITECTURE: Kanban board for problem status management
 * WHY: Visual workflow for tracking problem evolution
 * DESIGN: Uses SOL design system tokens
 *
 * Components:
 * - View toggle (list/kanban)
 * - Kanban board with 5 columns
 * - Problem cards with drag-drop
 * - Timeline bands for status history
 */

/* =============================================================================
   VIEW TOGGLE
   ============================================================================= */

.sol-view-toggle {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px;
    border-radius: 6px;
}

.sol-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--sol-text-tertiary, #6b7280);
    transition: all 0.15s ease;
}

.sol-view-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--sol-text-secondary, #9ca3af);
}

.sol-view-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--sol-text-primary, #f3f4f6);
}

.sol-view-btn svg {
    width: 14px;
    height: 14px;
}

/* =============================================================================
   KANBAN BOARD LAYOUT
   ============================================================================= */

.problem-kanban-board {
    display: grid;
    grid-template-columns: repeat(5, minmax(180px, 1fr));
    gap: 12px;
    padding: 12px;
    overflow-x: auto;
    min-height: 300px;
    max-height: calc(100vh - 400px);
}

/* Responsive: 3 columns at medium width */
@media (max-width: 1400px) {
    .problem-kanban-board {
        grid-template-columns: repeat(5, minmax(160px, 1fr));
        gap: 8px;
    }
}

/* Responsive: Horizontal scroll at narrow width */
@media (max-width: 1200px) {
    .problem-kanban-board {
        grid-template-columns: repeat(5, 180px);
        overflow-x: auto;
    }
}

/* Hidden state for view toggle */
.problem-kanban-board.hidden,
.sol-panel-content--list.hidden {
    display: none;
}

/* =============================================================================
   KANBAN COLUMNS
   ============================================================================= */

.kanban-column {
    background: var(--sol-bg-elevated, #1c1f2a);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    min-height: 200px;
    max-height: 100%;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.kanban-column-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Status colors */
.kanban-column-indicator.worsening { background: var(--sol-critical, #ef4444); }
.kanban-column-indicator.active { background: var(--sol-warning, #f59e0b); }
.kanban-column-indicator.improving { background: var(--sol-stable, #22c55e); }
.kanban-column-indicator.on_hold { background: #6366f1; }
.kanban-column-indicator.resolved { background: var(--sol-resolved, #6b7280); }
.kanban-column-indicator.monitor { background: #8b5cf6; }
.kanban-column-indicator.reopened { background: #f97316; }

.kanban-column-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sol-text-secondary, #9ca3af);
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kanban-column-count {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sol-text-tertiary, #6b7280);
    flex-shrink: 0;
}

.kanban-column-content {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Empty column state */
.kanban-column-content:empty::after {
    content: "No problems";
    display: block;
    text-align: center;
    color: var(--sol-text-tertiary, #6b7280);
    font-size: 0.75rem;
    padding: 20px;
    opacity: 0.6;
}

/* Drop target indicator */
.kanban-column.drag-over {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
}

.kanban-column.drag-over .kanban-column-content::after {
    content: '';
    display: block;
    height: 40px;
    border: 2px dashed rgba(59, 130, 246, 0.5);
    border-radius: 8px;
    margin-top: 8px;
}

/* =============================================================================
   PROBLEM CARDS
   ============================================================================= */

.kanban-card {
    background: var(--sol-bg-secondary, #0f1219);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px;
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.kanban-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.kanban-card:active,
.kanban-card.dragging {
    cursor: grabbing;
    transform: rotate(2deg) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.kanban-card:focus-visible {
    outline: 2px solid var(--sol-accent, #3b82f6);
    outline-offset: 2px;
}

/* Card header */
.kanban-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.kanban-card-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--sol-text-primary, #f3f4f6);
    line-height: 1.3;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.kanban-card-severity {
    font-size: 0.5625rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

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

.kanban-card-severity.severe {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.kanban-card-severity.moderate {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.kanban-card-severity.mild {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

/* Card rationale badges (classification reason) */
.kanban-card-rationale {
    margin: 4px 0 6px 0;
}

.kanban-card-rationale .guard-badges-compact {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.kanban-card-rationale .guard-badge-compact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 10px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    cursor: help;
}

.kanban-card-rationale .guard-badge-compact.guard-blocked {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
}

/* Card metrics */
.kanban-card-metrics {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.kanban-metric {
    font-size: 0.6875rem;
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.kanban-metric.abnormal {
    background: rgba(239, 68, 68, 0.15);
}

.kanban-metric .metric-label {
    font-size: 0.5625rem;
    color: var(--sol-text-tertiary, #6b7280);
}

.kanban-metric .metric-value {
    font-weight: 600;
    color: var(--sol-text-secondary, #9ca3af);
}

.kanban-metric.abnormal .metric-value {
    color: #fca5a5;
}

/* Card footer */
.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.kanban-card-time {
    font-size: 0.625rem;
    color: var(--sol-text-tertiary, #6b7280);
}

.kanban-card-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.kanban-card:hover .kanban-card-actions {
    opacity: 1;
}

.kanban-action-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sol-text-secondary, #9ca3af);
    transition: all 0.15s ease;
    padding: 0;
}

.kanban-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--sol-text-primary, #f3f4f6);
}

.kanban-action-btn svg {
    width: 12px;
    height: 12px;
}

/* =============================================================================
   TIMELINE BANDS (in cards)
   ============================================================================= */

.timeline-band {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin: 6px 0;
}

.timeline-band-empty {
    height: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    color: var(--sol-text-tertiary, #6b7280);
}

.timeline-segment {
    position: absolute;
    top: 0;
    height: 100%;
    transition: opacity 0.15s ease;
}

/* Status colors for timeline segments */
.timeline-segment.worsening {
    background: linear-gradient(90deg,
        rgba(239, 68, 68, 0.4),
        rgba(239, 68, 68, 0.7));
}

.timeline-segment.active {
    background: linear-gradient(90deg,
        rgba(245, 158, 11, 0.4),
        rgba(245, 158, 11, 0.7));
}

.timeline-segment.improving {
    background: linear-gradient(90deg,
        rgba(34, 197, 94, 0.4),
        rgba(34, 197, 94, 0.7));
}

.timeline-segment.resolved {
    background: linear-gradient(90deg,
        rgba(107, 114, 128, 0.4),
        rgba(107, 114, 128, 0.6));
}

.timeline-segment.monitor {
    background: linear-gradient(90deg,
        rgba(139, 92, 246, 0.4),
        rgba(139, 92, 246, 0.6));
}

.timeline-segment.on_hold {
    background: linear-gradient(90deg,
        rgba(99, 102, 241, 0.4),
        rgba(99, 102, 241, 0.6));
}

.timeline-segment.reopened {
    background: linear-gradient(90deg,
        rgba(249, 115, 22, 0.4),
        rgba(249, 115, 22, 0.7));
}

.timeline-now-marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 10px;
    background: var(--sol-accent, #3b82f6);
    border-radius: 1px;
    transform: translateX(-50%);
}

/* Hover state for timeline */
.kanban-card:hover .timeline-band {
    height: 8px;
}

/* =============================================================================
   LOADING & EMPTY STATES
   ============================================================================= */

.kanban-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--sol-text-tertiary, #6b7280);
    font-size: 0.875rem;
}

.kanban-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--sol-text-tertiary, #6b7280);
    text-align: center;
}

.kanban-empty-icon {
    width: 48px;
    height: 48px;
    opacity: 0.5;
    margin-bottom: 12px;
}

.kanban-empty-text {
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.kanban-empty-hint {
    font-size: 0.75rem;
    opacity: 0.7;
}

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

@keyframes card-move {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.kanban-card.moving {
    animation: card-move 0.3s ease;
}

/* Smooth transition when cards reorder */
.kanban-column-content {
    transition: background-color 0.2s ease;
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

/* Focus visible for keyboard navigation */
.kanban-card:focus-visible,
.sol-view-btn:focus-visible,
.kanban-action-btn:focus-visible {
    outline: 2px solid var(--sol-accent, #3b82f6);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .kanban-card,
    .timeline-segment,
    .kanban-column-content {
        transition: none;
    }

    .kanban-card.moving {
        animation: none;
    }
}

/* =============================================================================
   ENHANCED TIMELINE BANDS (2025-12-30)
   Per IdeasClinicalTimeline.md: severity-based intensity encoding + sparklines
   ============================================================================= */

/* Enhanced timeline with sparkline overlay */
.timeline-band--enhanced {
    height: 12px;
    position: relative;
}

/* Severity intensity modifiers - per LifeLines "color/thickness for significance" */
.timeline-segment.severity-mild {
    opacity: 0.5;
}

.timeline-segment.severity-moderate {
    opacity: 0.7;
}

.timeline-segment.severity-severe {
    opacity: 0.9;
}

.timeline-segment.severity-critical {
    opacity: 1;
    /* Add pulse for critical segments per Tufte's "highlight the most severe" */
    animation: criticalPulse 2s ease-in-out infinite;
}

@keyframes criticalPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

/* Trajectory indicators on segments */
.timeline-segment[data-trajectory="worsening"]::after,
.timeline-segment[data-trajectory="rapidly_worsening"]::after {
    content: '↑';
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 6px;
    color: rgba(255, 255, 255, 0.7);
}

.timeline-segment[data-trajectory="improving"]::after,
.timeline-segment[data-trajectory="rapidly_improving"]::after {
    content: '↓';
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 6px;
    color: rgba(255, 255, 255, 0.7);
}

/* Sparkline overlay - per Tufte's "sparkline-like double-sided timeline" */
.timeline-sparkline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    color: rgba(255, 255, 255, 0.8);
    z-index: 1;
}

/* Sparkline path styling */
.timeline-sparkline path {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Problem-space specific timeline (inside cards) */
.problem-card-2d .card-timeline .timeline-band {
    height: 8px;
    margin: 0;
}

.problem-card-2d .card-timeline .timeline-band--enhanced {
    height: 14px;
}

/* Hover enhancement - show more detail on hover */
.problem-card-2d:hover .timeline-sparkline {
    color: rgba(6, 182, 212, 0.9);
}

.kanban-card:hover .timeline-band--enhanced {
    height: 16px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .timeline-segment.severity-critical {
        animation: none;
    }
}

/* =============================================================================
   INFECTION DUAL SPARKLINES (2025-12-30)
   Per IdeasClinicalTimeline.md: "temperature curve and WBC count trend"
   "red line for fever... and orange line for WBC"
   ============================================================================= */

/* Infection-enhanced timeline with dual sparkline overlay */
.timeline-band--infection {
    height: 18px;
    position: relative;
}

/* Infection sparkline SVG with more height for dual lines */
.timeline-sparkline--infection {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Temperature sparkline (red) - upper portion */
.sparkline-temp {
    stroke: #ef4444;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* WBC sparkline (orange) - lower portion */
.sparkline-wbc {
    stroke: #f59e0b;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Fever spike markers (circles at >38.3°C points) */
.fever-spike {
    filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.6));
}

/* Animated pulse for fever spikes */
@keyframes feverPulse {
    0%, 100% { r: 2.5; opacity: 1; }
    50% { r: 3.5; opacity: 0.7; }
}

.fever-spike {
    animation: feverPulse 1.5s ease-in-out infinite;
}

/* Legend for dual sparklines */
.sparkline-legend {
    position: absolute;
    top: 0;
    right: 2px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 6px;
    font-weight: 600;
    z-index: 3;
    pointer-events: none;
}

.legend-temp {
    color: #ef4444;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.legend-wbc {
    color: #f59e0b;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

/* Hover state - make lines more prominent */
.timeline-band--infection:hover .sparkline-temp,
.timeline-band--infection:hover .sparkline-wbc {
    stroke-width: 2;
}

.timeline-band--infection:hover .fever-spike {
    animation: none;
    r: 3;
}

/* Problem-space card adjustments for infection timelines */
.problem-card-2d .timeline-band--infection {
    height: 20px;
}

/* Kanban card adjustments */
.kanban-card:hover .timeline-band--infection {
    height: 24px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .fever-spike {
        animation: none;
    }
}

/* Tooltip for fever spikes */
.fever-spike:hover::after {
    content: attr(data-temp) '°C';
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 2px;
    white-space: nowrap;
}
