/**
 * Objectives Dark Mode - SOL Theme Integration
 *
 * ARCHITECTURE: CSS variable overrides for dark theme
 * WHY: Objectives CSS was built light-first; SOL is dark-first
 * NOTE: Load after objectives.css and sol-layout.css
 */

/* =============================================================================
   VARIABLE MAPPINGS: --obj-* → --sol-*
   ============================================================================= */

.sol-app,
[data-theme="dark"],
:root {
    /* Clinical Status Colors */
    --obj-normal: var(--sol-stable);
    --obj-normal-bg: var(--sol-stable-bg);
    --obj-abnormal: var(--sol-warning);
    --obj-abnormal-bg: var(--sol-warning-bg);
    --obj-critical: var(--sol-critical);
    --obj-critical-bg: var(--sol-critical-bg);
    --obj-pending: var(--sol-text-tertiary);
    --obj-pending-bg: var(--sol-bg-elevated);

    /* UI Colors */
    --obj-primary: var(--sol-accent-primary);
    --obj-primary-hover: var(--sol-accent-hover);
    --obj-border: var(--sol-border);
    --obj-border-dark: var(--sol-border-strong);
    --obj-bg: var(--sol-bg-secondary);
    --obj-bg-alt: var(--sol-bg-tertiary);
    --obj-text: var(--sol-text-primary);
    --obj-text-muted: var(--sol-text-secondary);
    --obj-text-light: var(--sol-text-tertiary);

    /* Shadows - Darker for dark mode */
    --obj-shadow-sm: var(--sol-shadow-sm);
    --obj-shadow-md: var(--sol-shadow-md);
    --obj-shadow-lg: var(--sol-shadow-lg);

    /* Spacing - Use SOL scale */
    --obj-space-xs: var(--sol-space-xs);
    --obj-space-sm: var(--sol-space-sm);
    --obj-space-md: var(--sol-space-md);
    --obj-space-lg: var(--sol-space-lg);
    --obj-space-xl: var(--sol-space-xl);

    /* Borders */
    --obj-radius-sm: var(--sol-radius-sm);
    --obj-radius-md: var(--sol-radius-md);
    --obj-radius-lg: var(--sol-radius-lg);

    /* Transitions */
    --obj-transition-fast: var(--sol-transition-fast);
    --obj-transition-normal: var(--sol-transition-base);
}

/* =============================================================================
   S/I/R MATRIX STYLES (Culture Antibiogram)
   ============================================================================= */

.culture-matrix-container {
    overflow-x: auto;
    margin: var(--sol-space-md) 0;
    border-radius: var(--sol-radius-md);
    background: var(--sol-bg-tertiary);
}

.culture-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    font-family: var(--obj-font-mono);
}

.culture-matrix th,
.culture-matrix td {
    padding: 6px 8px;
    text-align: center;
    border: 1px solid var(--sol-border);
    white-space: nowrap;
}

/* Header row - organism names */
.culture-matrix thead th {
    background: var(--sol-bg-elevated);
    color: var(--sol-text-secondary);
    font-weight: 500;
    font-size: 0.7rem;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* First column - antibiotic names */
.culture-matrix tbody th {
    background: var(--sol-bg-tertiary);
    color: var(--sol-text-primary);
    font-weight: 500;
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 140px;
}

/* Antibiotic class group headers */
.culture-matrix .antibiotic-group {
    background: var(--sol-bg-primary);
    color: var(--sol-text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.culture-matrix .antibiotic-group td {
    text-align: left;
    padding-left: var(--sol-space-md);
}

/* S/I/R/NT Cells */
.sir-cell {
    font-weight: 600;
    min-width: 32px;
    cursor: default;
    transition: transform 0.1s ease;
}

.sir-cell:hover {
    transform: scale(1.1);
}

/* Sensitive - Green */
.sir-S {
    background: rgba(34, 197, 94, 0.25);
    color: var(--sol-stable);
}

/* Intermediate - Amber */
.sir-I {
    background: rgba(245, 158, 11, 0.25);
    color: var(--sol-warning);
}

/* Resistant - Red (emphasized) */
.sir-R {
    background: rgba(239, 68, 68, 0.3);
    color: var(--sol-critical);
    font-weight: 700;
}

/* Not Tested - Gray */
.sir-NT {
    background: var(--sol-bg-tertiary);
    color: var(--sol-text-muted);
    font-style: italic;
    font-weight: 400;
}

/* MIC tooltip */
.sir-cell[data-mic]::after {
    content: attr(data-mic);
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--sol-bg-primary);
    color: var(--sol-text-primary);
    padding: 4px 8px;
    border-radius: var(--sol-radius-sm);
    font-size: 0.7rem;
    white-space: nowrap;
    box-shadow: var(--sol-shadow-md);
    z-index: 10;
}

.sir-cell[data-mic]:hover::after {
    display: block;
}

/* =============================================================================
   SNAPSHOT MODAL STYLES
   ============================================================================= */

.snapshot-selector-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

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

.snapshot-selector-modal {
    background: var(--sol-bg-secondary);
    border: 1px solid var(--sol-border-strong);
    border-radius: var(--sol-radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.2s ease;
}

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

.snapshot-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sol-space-lg);
    border-bottom: 1px solid var(--sol-border);
    background: var(--sol-bg-tertiary);
}

.snapshot-selector-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--sol-text-primary);
}

.snapshot-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--sol-text-secondary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: var(--sol-radius-sm);
    transition: all 0.15s ease;
}

.snapshot-close-btn:hover {
    color: var(--sol-text-primary);
    background: var(--sol-bg-hover);
}

.snapshot-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sol-space-lg);
}

.snapshot-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--sol-space-sm);
    padding: var(--sol-space-md) var(--sol-space-lg);
    border-top: 1px solid var(--sol-border);
    background: var(--sol-bg-tertiary);
}

.snapshot-cancel-btn {
    background: var(--sol-bg-hover);
    border: 1px solid var(--sol-border);
    color: var(--sol-text-secondary);
    padding: 8px 16px;
    border-radius: var(--sol-radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.snapshot-cancel-btn:hover {
    background: var(--sol-bg-elevated);
    color: var(--sol-text-primary);
}

.snapshot-select-btn {
    background: var(--sol-accent-primary);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: var(--sol-radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.snapshot-select-btn:hover:not(:disabled) {
    background: var(--sol-accent-hover);
}

.snapshot-select-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =============================================================================
   DARK MODE PANEL OVERRIDES
   ============================================================================= */

/* Lab panels in dark mode */
.lab-panel {
    background: var(--sol-bg-elevated);
    border-color: var(--sol-border);
}

.lab-panel:hover {
    box-shadow: var(--sol-shadow-md);
    border-color: var(--sol-border-strong);
}

.lab-panel-header {
    background: var(--sol-bg-tertiary);
    border-color: var(--sol-border);
}

.lab-summary-banner {
    background: var(--sol-bg-tertiary);
}

/* Critical/abnormal badges in dark mode - already use --obj-* which now map to --sol-* */
.lab-critical-badge {
    background: var(--sol-critical-bg);
    color: var(--sol-critical);
    border: 1px solid var(--sol-critical-border);
}

.lab-abnormal-badge {
    background: var(--sol-warning-bg);
    color: var(--sol-warning);
    border: 1px solid var(--sol-warning-border);
}

/* Vital panels in dark mode */
.vital-card {
    background: var(--sol-bg-elevated);
    border-color: var(--sol-border);
}

.vital-label {
    color: var(--sol-text-secondary);
}

.vital-value {
    color: var(--sol-text-primary);
}

.vital-value.high {
    color: var(--sol-critical);
}

.vital-value.low {
    color: var(--sol-warning);
}

/* Culture panels in dark mode */
.culture-card {
    background: var(--sol-bg-elevated);
    border-color: var(--sol-border);
}

.culture-card.positive {
    border-left: 3px solid var(--sol-critical);
    background: linear-gradient(90deg, var(--sol-critical-bg), transparent);
}

.culture-card.pending {
    border-left: 3px solid var(--sol-warning);
}

.culture-card.no-growth {
    border-left: 3px solid var(--sol-stable);
    opacity: 0.8;
}

/* Snapshot cards in dark mode */
.snapshot-card {
    background: var(--sol-bg-elevated);
    border: 1px solid var(--sol-border);
    border-radius: var(--sol-radius-md);
    transition: all 0.15s ease;
}

.snapshot-card:hover {
    border-color: var(--sol-accent-primary);
    box-shadow: 0 0 0 1px var(--sol-accent-primary);
}

.snapshot-card.selected {
    border-color: var(--sol-accent-primary);
    box-shadow: var(--sol-card-shadow-selected);
}

/* =============================================================================
   SPARKLINE DARK MODE ADJUSTMENTS
   ============================================================================= */

.sparkline-svg {
    filter: brightness(1.1);
}

/* Reference band more visible in dark mode */
.sparkline-ref-band {
    fill: rgba(34, 197, 94, 0.2);
}

/* =============================================================================
   ECHARTS DARK MODE THEME
   ============================================================================= */

.vitals-chart-container {
    background: var(--sol-bg-elevated);
    border-radius: var(--sol-radius-md);
    padding: var(--sol-space-md);
}

/* Tooltip styling handled via ECharts options in JS */

/* =============================================================================
   SNAPSHOT PANEL STYLES
   ============================================================================= */

.sol-snapshot-panel {
    border-left: 3px solid var(--sol-accent-primary);
}

.sol-snapshot-panel .sol-panel-icon {
    font-size: 1.1rem;
    margin-right: var(--sol-space-xs);
}

#snapshotsList {
    max-height: 200px;
    overflow-y: auto;
}

/* Snapshot card list */
.snapshot-cards-list {
    display: flex;
    flex-direction: column;
    gap: var(--sol-space-sm);
}

.snapshot-card {
    display: flex;
    align-items: flex-start;
    gap: var(--sol-space-sm);
    padding: var(--sol-space-sm);
    background: var(--sol-bg-elevated);
    border: 1px solid var(--sol-border);
    border-radius: var(--sol-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.snapshot-card:hover {
    border-color: var(--sol-accent-primary);
    box-shadow: 0 0 0 1px var(--sol-accent-primary);
}

.snapshot-card.selected {
    border-color: var(--sol-accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.snapshot-card-select {
    flex-shrink: 0;
    padding-top: 2px;
}

.snapshot-card-select input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--sol-accent-primary);
}

.snapshot-card-content {
    flex: 1;
    min-width: 0;
}

.snapshot-card-header {
    display: flex;
    align-items: center;
    gap: var(--sol-space-xs);
    margin-bottom: 4px;
}

.snapshot-icon {
    font-size: 1rem;
}

.snapshot-label {
    font-weight: 500;
    color: var(--sol-text-primary);
    font-size: 0.875rem;
}

.snapshot-linked-badge {
    font-size: 0.7rem;
    color: var(--sol-text-secondary);
    margin-left: auto;
}

.snapshot-card-meta {
    display: flex;
    align-items: center;
    gap: var(--sol-space-xs);
    font-size: 0.75rem;
    color: var(--sol-text-secondary);
}

.snapshot-time-ago {
    color: var(--sol-text-muted);
}

.snapshot-card-counts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sol-space-sm);
    margin-top: var(--sol-space-xs);
    font-size: 0.7rem;
}

.snapshot-count {
    color: var(--sol-text-secondary);
}

.snapshot-critical-badge {
    color: var(--sol-critical);
    font-weight: 500;
}

/* Snapshot list header */
.snapshot-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sol-space-sm);
    font-size: 0.75rem;
    color: var(--sol-text-secondary);
}

.snapshot-create-btn {
    background: var(--sol-bg-hover);
    border: 1px solid var(--sol-border);
    color: var(--sol-accent-primary);
    padding: 4px 8px;
    border-radius: var(--sol-radius-sm);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.snapshot-create-btn:hover {
    background: var(--sol-accent-primary);
    color: white;
}

/* Empty/loading states */
.snapshot-loading,
.snapshot-empty,
.snapshot-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sol-space-lg);
    text-align: center;
    color: var(--sol-text-secondary);
}

.snapshot-empty-icon,
.snapshot-error-icon {
    font-size: 2rem;
    margin-bottom: var(--sol-space-sm);
}

.snapshot-retry-btn,
.snapshot-create-new-btn {
    margin-top: var(--sol-space-sm);
    background: var(--sol-accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--sol-radius-md);
    cursor: pointer;
    font-size: 0.875rem;
}

.snapshot-retry-btn:hover,
.snapshot-create-new-btn:hover {
    background: var(--sol-accent-hover);
}

/* Create form */
.snapshot-create-form {
    background: var(--sol-bg-tertiary);
    border: 1px solid var(--sol-border);
    border-radius: var(--sol-radius-md);
    padding: var(--sol-space-md);
    margin-bottom: var(--sol-space-md);
}

.snapshot-create-header h4 {
    margin: 0 0 var(--sol-space-sm);
    color: var(--sol-text-primary);
    font-size: 0.875rem;
}

.snapshot-create-fields {
    display: flex;
    flex-direction: column;
    gap: var(--sol-space-sm);
}

.snapshot-create-fields label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--sol-text-secondary);
}

.snapshot-create-fields input,
.snapshot-create-fields select {
    padding: 8px 12px;
    border: 1px solid var(--sol-border);
    border-radius: var(--sol-radius-sm);
    background: var(--sol-bg-primary);
    color: var(--sol-text-primary);
    font-size: 0.875rem;
}

.snapshot-create-fields input:focus,
.snapshot-create-fields select:focus {
    outline: none;
    border-color: var(--sol-accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.snapshot-create-fields input.input-error {
    border-color: var(--sol-critical);
}

.snapshot-create-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--sol-space-sm);
    margin-top: var(--sol-space-md);
}

.snapshot-create-cancel {
    background: var(--sol-bg-hover);
    border: 1px solid var(--sol-border);
    color: var(--sol-text-secondary);
    padding: 6px 12px;
    border-radius: var(--sol-radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
}

.snapshot-create-save {
    background: var(--sol-accent-primary);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: var(--sol-radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
}

.snapshot-create-save:hover:not(:disabled) {
    background: var(--sol-accent-hover);
}

.snapshot-create-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.snapshot-create-error {
    color: var(--sol-critical);
    font-size: 0.75rem;
    margin-top: var(--sol-space-sm);
}

/* =============================================================================
   CULTURE MATRIX TOGGLE BUTTON
   ============================================================================= */

#toggleMatrixBtn {
    font-size: 0.875rem;
    padding: 4px 8px;
    transition: all 0.15s ease;
}

#toggleMatrixBtn.active {
    background: var(--sol-accent-primary);
    color: white;
    border-radius: var(--sol-radius-sm);
}
