/* ==========================================================================
   Hospitalization Timeline - Clean Rewrite (2025-12-10)
   Uses REAL data from dailyStates, no fake visualizations
   ========================================================================== */

/* Main Container */
.ht-timeline {
    background: var(--sol-bg-elevated, #1c1f2a);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

/* Header */
.ht-header {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ht-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

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

/* Status Summary Pills */
.ht-status-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ht-status-pill {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
}

.ht-status-pill.worsening {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.ht-status-pill.active {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.ht-status-pill.improving {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.ht-status-pill.resolved {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

/* Day Scale */
.ht-scale {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ht-scale-start,
.ht-scale-end {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--sol-text-tertiary, #64748b);
    white-space: nowrap;
}

.ht-scale-track {
    flex: 1;
    display: flex;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

/* Day ticks - clickable (PHASE 4) */
.ht-day-tick {
    flex: 1;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.15s ease;
    min-width: 8px;
}

.ht-day-tick:hover {
    background: rgba(59, 130, 246, 0.3);
}

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

.ht-day-tick.selected {
    background: rgba(59, 130, 246, 0.5);
}

.ht-day-tick.ht-day-today {
    background: rgba(34, 197, 94, 0.2);
}

.ht-day-tick:last-child {
    border-right: none;
}

/* Now button */
.ht-now-btn {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ht-now-btn:hover {
    background: rgba(34, 197, 94, 0.25);
    border-color: rgba(34, 197, 94, 0.6);
}

/* Day selection indicator */
.ht-day-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 6px 16px;
    background: rgba(59, 130, 246, 0.15);
    border-top: 1px solid rgba(59, 130, 246, 0.3);
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

.ht-day-indicator.hidden {
    display: none;
}

.ht-day-indicator-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #93c5fd;
}

.ht-day-indicator-text #htSelectedDay {
    color: #fff;
}

.ht-day-indicator-close {
    font-size: 1rem;
    line-height: 1;
    padding: 2px 6px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #93c5fd;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ht-day-indicator-close:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Problem Rows */
.ht-problems {
    padding: 8px 0;
}

.ht-problem-row {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ht-problem-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.ht-problem-row.selected {
    background: rgba(59, 130, 246, 0.1);
}

.ht-problem-label {
    width: 180px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ht-problem-name {
    font-size: 0.75rem;
    color: var(--sol-text-secondary, #94a3b8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.ht-problem-row:hover .ht-problem-name {
    color: var(--sol-text-primary, #f8fafc);
}

.ht-problem-status {
    font-size: 0.5625rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.ht-problem-status.worsening {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.ht-problem-status.active {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.ht-problem-status.improving {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.ht-problem-status.resolved {
    background: rgba(107, 114, 128, 0.2);
    color: #6b7280;
}

/* Problem Track (the timeline bar area) */
.ht-problem-track {
    flex: 1;
    height: 20px;
    position: relative;
    margin-left: 16px;
}

/* Problem Bar */
.ht-problem-bar {
    position: absolute;
    top: 4px;
    height: 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    transition: transform 0.15s ease;
}

.ht-problem-row:hover .ht-problem-bar {
    transform: scaleY(1.2);
}

.ht-problem-bar.worsening {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.3), rgba(239, 68, 68, 0.5));
    border: 1px solid rgba(239, 68, 68, 0.6);
}

.ht-problem-bar.active {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.5));
    border: 1px solid rgba(245, 158, 11, 0.6);
}

.ht-problem-bar.improving {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.3), rgba(34, 197, 94, 0.5));
    border: 1px solid rgba(34, 197, 94, 0.6);
}

.ht-problem-bar.resolved {
    background: linear-gradient(90deg, rgba(107, 114, 128, 0.3), rgba(107, 114, 128, 0.5));
    border: 1px solid rgba(107, 114, 128, 0.6);
}

/* Markers on the bar */
.ht-marker {
    font-size: 0.625rem;
    z-index: 2;
}

.ht-marker.onset {
    color: var(--sol-text-secondary, #94a3b8);
}

.ht-marker.transition {
    position: absolute;
    transform: translateX(-50%);
}

.ht-marker.transition.worsening { color: #ef4444; }
.ht-marker.transition.active { color: #f59e0b; }
.ht-marker.transition.improving { color: #22c55e; }
.ht-marker.transition.resolved { color: #6b7280; }

.ht-marker.resolved {
    color: #22c55e;
}

.ht-marker.current {
    color: var(--sol-text-primary, #f8fafc);
}

/* Events Section */
.ht-events {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 16px;
}

.ht-events-header {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--sol-text-tertiary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.ht-events-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ht-event-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.6875rem;
    color: var(--sol-text-secondary, #94a3b8);
}

.ht-event-day {
    font-weight: 600;
    color: var(--sol-text-tertiary, #64748b);
    width: 28px;
}

.ht-event-icon {
    width: 12px;
    text-align: center;
}

.ht-event-item.onset .ht-event-icon { color: #3b82f6; }
.ht-event-item.transition .ht-event-icon { color: #f59e0b; }
.ht-event-item.critical .ht-event-icon { color: #ef4444; }

.ht-event-label {
    flex: 1;
}

.ht-events-more {
    font-size: 0.625rem;
    color: var(--sol-text-tertiary, #64748b);
    padding-top: 4px;
}

/* No Data State */
.ht-no-data {
    padding: 32px 24px;
    text-align: center;
}

.ht-no-data-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: var(--sol-text-tertiary, #64748b);
    opacity: 0.5;
}

.ht-no-data-icon svg {
    width: 100%;
    height: 100%;
}

.ht-no-data-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--sol-text-secondary, #94a3b8);
    margin: 0 0 4px;
}

.ht-no-data-desc {
    font-size: 0.75rem;
    color: var(--sol-text-tertiary, #64748b);
    margin: 0 0 8px;
}

.ht-no-data-hint {
    font-size: 0.6875rem;
    color: var(--sol-text-tertiary, #64748b);
    opacity: 0.7;
    margin: 0;
}

/* ==========================================================================
   Medication Timeline (PHASE 3 - 2025-12-10)
   ========================================================================== */

.ht-medications {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 8px;
}

.ht-meds-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
}

.ht-meds-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sol-text-tertiary, #64748b);
}

.ht-meds-count {
    font-size: 0.625rem;
    color: var(--sol-text-tertiary, #64748b);
}

.ht-meds-list {
    padding: 0 0 8px;
}

.ht-meds-more {
    font-size: 0.625rem;
    color: var(--sol-text-tertiary, #64748b);
    padding: 4px 16px;
    text-align: center;
}

/* Medication Row */
.ht-med-row {
    display: flex;
    align-items: center;
    padding: 4px 16px;
    cursor: default;
    transition: background 0.15s ease;
}

.ht-med-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.ht-med-label {
    width: 160px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ht-med-name {
    font-size: 0.6875rem;
    color: var(--sol-text-tertiary, #64748b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.ht-med-row:hover .ht-med-name {
    color: var(--sol-text-secondary, #94a3b8);
}

/* Safety Flags */
.ht-med-flag {
    font-size: 0.625rem;
    flex-shrink: 0;
}

.ht-med-flag.nephrotoxic {
    color: #f59e0b;
}

.ht-med-flag.anticoagulant {
    color: #ef4444;
}

/* Medication row with safety flags gets border highlight */
.ht-med-row.nephrotoxic {
    border-left: 2px solid rgba(245, 158, 11, 0.5);
    padding-left: 14px;
}

.ht-med-row.anticoagulant {
    border-left: 2px solid rgba(239, 68, 68, 0.5);
    padding-left: 14px;
}

/* Medication Track */
.ht-med-track {
    flex: 1;
    height: 16px;
    position: relative;
    margin-left: 12px;
}

/* Medication Bar */
.ht-med-bar {
    position: absolute;
    top: 4px;
    height: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
    transition: transform 0.15s ease;
}

.ht-med-row:hover .ht-med-bar {
    transform: scaleY(1.3);
}

.ht-med-bar.active {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.3), rgba(139, 92, 246, 0.5));
    border: 1px solid rgba(139, 92, 246, 0.6);
}

.ht-med-bar.stopped {
    background: linear-gradient(90deg, rgba(107, 114, 128, 0.3), rgba(107, 114, 128, 0.5));
    border: 1px solid rgba(107, 114, 128, 0.6);
}

.ht-med-bar.held {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.5));
    border: 1px solid rgba(245, 158, 11, 0.6);
    border-style: dashed;
}

/* Medication Markers */
.ht-med-marker {
    font-size: 0.5rem;
    z-index: 2;
}

.ht-med-marker.start {
    color: rgba(139, 92, 246, 0.8);
}

.ht-med-marker.stop {
    color: rgba(107, 114, 128, 0.8);
}

.ht-med-marker.current {
    color: rgba(139, 92, 246, 0.6);
}

/* Event Item Medication Colors */
.ht-event-item.med-start .ht-event-icon {
    color: #8b5cf6;
}

.ht-event-item.med-stop .ht-event-icon {
    color: #6b7280;
}

.ht-event-item.med-held .ht-event-icon {
    color: #f59e0b;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ht-problem-bar,
    .ht-problem-row,
    .ht-med-bar,
    .ht-med-row {
        transition: none;
    }
}
