/* =====================================================
   FLUORESCENCE CROSS-TALK PREDICTOR
   Design System & Core Styles
   ===================================================== */

/* CSS Custom Properties - Design Tokens */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #0a0d14;
    --bg-secondary: #12161f;
    --bg-tertiary: #1a1f2e;
    --bg-elevated: #222838;
    --bg-overlay: rgba(10, 13, 20, 0.85);
    
    /* Accent Colors */
    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-secondary: #22d3ee;
    
    /* Channel Colors */
    --channel-a: #22c55e;
    --channel-a-light: #4ade80;
    --channel-a-bg: rgba(34, 197, 94, 0.15);
    --channel-b: #f43f5e;
    --channel-b-light: #fb7185;
    --channel-b-bg: rgba(244, 63, 94, 0.15);
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-muted: #475569;
    
    /* Status Colors */
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Borders */
    --border-subtle: rgba(148, 163, 184, 0.1);
    --border-default: rgba(148, 163, 184, 0.2);
    --border-strong: rgba(148, 163, 184, 0.3);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Layout */
    --header-height: 64px;
    --sidebar-width: 380px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(ellipse at 0% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(34, 197, 94, 0.05) 0%, transparent 50%);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

p {
    color: var(--text-secondary);
}

/* =====================================================
   HEADER
   ===================================================== */
.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-content {
    max-width: 100%;
    height: 100%;
    padding: 0 var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-text h1 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.logo-text .subtitle {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Disclaimer Banner */
.disclaimer-banner {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    color: var(--warning);
}

.disclaimer-banner svg {
    flex-shrink: 0;
}

.disclaimer-banner strong {
    font-weight: 600;
}

/* =====================================================
   MAIN LAYOUT
   ===================================================== */
.main-content {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: calc(100vh - var(--header-height) - 40px);
}

/* =====================================================
   CONFIGURATION PANEL (Sidebar)
   ===================================================== */
.config-panel {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    padding: var(--space-lg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.panel-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--border-subtle);
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-title svg {
    color: var(--accent-primary);
}

/* Fluorophore Selector */
.fluorophore-selector {
    margin-bottom: var(--space-md);
}

.fluorophore-selector:last-child {
    margin-bottom: 0;
}

.selector-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.channel-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
}

.channel-badge.channel-a {
    background: var(--channel-a-bg);
    color: var(--channel-a);
    border: 1px solid var(--channel-a);
}

.channel-badge.channel-b {
    background: var(--channel-b-bg);
    color: var(--channel-b);
    border: 1px solid var(--channel-b);
}

/* Search Select */
.search-select {
    position: relative;
}

.search-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: var(--shadow-lg);
}

.search-dropdown.active {
    display: block;
}

.dropdown-item {
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
}

.dropdown-item .name {
    font-weight: 500;
    color: var(--text-primary);
}

.dropdown-item .info {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.dropdown-empty {
    padding: var(--space-md);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Selected Fluorophore Info */
.selected-info {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    display: none;
}

.selected-info.active {
    display: block;
}

.selected-info .fp-name {
    font-weight: 600;
    color: var(--text-primary);
}

.selected-info .fp-peaks {
    display: flex;
    gap: var(--space-md);
    margin-top: 4px;
}

.selected-info .peak {
    display: flex;
    align-items: center;
    gap: 4px;
}

.selected-info .peak-label {
    color: var(--text-muted);
}

.selected-info .peak-value {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* Toggle Group */
.toggle-group {
    display: flex;
    gap: var(--space-xs);
    background: var(--bg-primary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle-btn:hover {
    color: var(--text-primary);
}

.toggle-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.mode-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent-primary);
}

/* Config Rows */
.excitation-config,
.detection-config {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.excitation-config:last-child,
.detection-config:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.config-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.config-row:last-child {
    margin-bottom: 0;
}

.config-row.hidden {
    display: none;
}

.config-label {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Form Inputs */
.select-input {
    flex: 1;
    max-width: 180px;
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.select-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.number-input {
    width: 60px;
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: var(--font-mono);
    text-align: center;
}

.number-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.dual-input {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Calculate Button */
.btn-calculate {
    width: 100%;
    margin-top: auto;
    padding: var(--space-md);
    font-size: 1rem;
}

/* =====================================================
   RESULTS PANEL
   ===================================================== */
.results-panel {
    padding: var(--space-xl);
    overflow-y: auto;
    position: relative;
}

/* Loading State */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-2xl);
    min-height: 400px;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-sm);
}

.empty-state p {
    max-width: 400px;
    color: var(--text-muted);
}

/* Results Content */
.results-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.results-content.hidden {
    display: none;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

.summary-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border-subtle);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.card-header svg {
    color: var(--text-muted);
}

.card-body {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.metric {
    text-align: center;
}

.metric-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.metric-value.low {
    color: var(--success);
}

.metric-value.medium {
    color: var(--warning);
}

.metric-value.high {
    color: var(--error);
}

.card-warning {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding: var(--space-sm);
    background: rgba(245, 158, 11, 0.1);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--warning);
}

.card-warning.hidden {
    display: none;
}

/* Interpretation Box */
.interpretation-box {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--accent-primary);
}

.interpretation-box h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    font-size: 0.875rem;
    color: var(--accent-primary);
}

.interpretation-box p {
    font-size: 0.9375rem;
    line-height: 1.7;
}

/* Plot Container */
.plot-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border-subtle);
}

.plot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.plot-header h3 {
    font-size: 1rem;
}

.plot-controls {
    display: flex;
    gap: var(--space-md);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

#spectral-plot {
    width: 100%;
    height: 400px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* Summary Table */
.summary-table-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border-subtle);
}

.summary-table-container h3 {
    margin-bottom: var(--space-md);
    font-size: 1rem;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.summary-table th,
.summary-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.summary-table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.summary-table td {
    font-family: var(--font-mono);
}

.summary-table tbody tr:hover {
    background: var(--bg-tertiary);
}

/* Export Section */
.export-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border-subtle);
}

.export-section h3 {
    margin-bottom: var(--space-md);
    font-size: 1rem;
}

.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: 1.125rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    max-height: 60vh;
}

/* Assumptions List */
.assumptions-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.assumptions-list li {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.assumption-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.assumptions-list strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.assumptions-list p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

/* Share Modal */
.share-url-container {
    display: flex;
    gap: var(--space-sm);
    margin: var(--space-md) 0;
}

.share-url-input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-mono);
}

.share-note {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    z-index: 300;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.info {
    border-left: 4px solid var(--info);
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */
.hidden {
    display: none !important;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 340px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .config-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        max-height: 50vh;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 var(--space-md);
    }
    
    .logo-text h1 {
        font-size: 1rem;
    }
    
    .logo-text .subtitle {
        display: none;
    }
    
    .results-panel {
        padding: var(--space-md);
    }
    
    .export-buttons {
        flex-direction: column;
    }
    
    .export-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}
