/* --------------------------------------------------------------------------
 * Sim Racing Telemetry Analytics - CSS Stylesheet
 * -------------------------------------------------------------------------- */

:root {
    /* Color Palette */
    --bg-dark: #0b0e14;
    --bg-card: #121824;
    --bg-card-hover: #182030;
    --border-color: #1e293b;
    --border-focus: #3b82f6;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Neon Telemetry Accents */
    --cyan: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.3);
    --green: #22c55e;
    --green-glow: rgba(34, 197, 94, 0.3);
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.3);
    --amber: #f59e0b;
    --amber-glow: rgba(245, 158, 11, 0.3);
    --purple: #a855f7;
    --purple-glow: rgba(168, 85, 247, 0.3);
    
    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Layout */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
    --transition-fast: 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.dark-theme {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Container */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 2rem;
}

.brand-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-text h1 span {
    color: var(--cyan);
}

.brand-text .subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    touch-action: manipulation;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.775rem;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.btn-secondary {
    background: #1e293b;
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: #334155;
}

.btn-accent {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}
.btn-accent:hover {
    background: linear-gradient(135deg, #047857, #059669);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}

/* Ingestion Panel */
.ingestion-card {
    transition: all 0.3s ease;
}

.ingestion-tabs {
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.tab-btn.active {
    background: #1e293b;
    color: var(--cyan);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.input-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.url-input-wrapper {
    display: flex;
    gap: 10px;
}

.url-input-wrapper input {
    flex: 1;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
}

.url-input-wrapper input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.input-help {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Generated Download Action Cards Grid */
.download-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.panel-download-card {
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.panel-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.panel-card-title h4 {
    font-size: 0.925rem;
    font-weight: 700;
}

.panel-card-desc {
    font-size: 0.775rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}



/* Dropzone */
.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    background: rgba(15, 23, 42, 0.5);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--cyan);
    background: rgba(6, 182, 212, 0.05);
}

.dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.dropzone h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.dropzone p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.file-input {
    display: none;
}

.files-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.file-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #1e293b;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: var(--font-mono);
}

.file-badge.loaded {
    border-left: 3px solid var(--green);
}

/* Status Banner */
.status-banner {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
}

.status-banner.info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.status-banner.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.status-banner.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.hidden {
    display: none !important;
}

/* Session Summary Stats Grid */
.session-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
    margin-top: 4px;
}

/* Controls Bar */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    padding: 14px 20px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.chart-wrapper canvas {
    cursor: crosshair;
}

.chart-wrapper canvas:active {
    cursor: grabbing;
}

.toggle-group {
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--cyan);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Charts Stack */
.charts-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-card {
    padding: 16px 20px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.chart-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-title h3 {
    font-size: 1rem;
    font-weight: 700;
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.cyan-indicator { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.green-indicator { background: var(--green); box-shadow: 0 0 8px var(--green); }
.red-indicator { background: var(--red); box-shadow: 0 0 8px var(--red); }
.amber-indicator { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.purple-indicator { background: var(--purple); box-shadow: 0 0 8px var(--purple); }

.chart-scrub-val {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.chart-wrapper {
    position: relative;
    height: 220px;
    width: 100%;
}

/* Text Accent Utilities */
.text-cyan { color: var(--cyan); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-white { color: var(--text-primary); }
.highlight-text { color: var(--cyan); font-family: var(--font-mono); }

/* Table Styling */
.analysis-section {
    margin-top: 20px;
}

.section-header {
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.section-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.table-responsive {
    overflow-x: auto;
}

.telemetry-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.telemetry-table th {
    background: #0f172a;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.telemetry-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.telemetry-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Mobile Media Queries */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .url-input-wrapper {
        flex-direction: column;
    }
    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .chart-wrapper {
        height: 180px;
    }
}
