/* Styling Variables & Design Tokens */
:root {
    /* Sophisticated Matte Charcoal & Titanium Palette */
    --bg-primary: #0a0d14;
    --bg-panel: #111520;
    --bg-panel-hover: #151a28;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    
    /* Typography Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    
    /* Unified Theme Accent Colors */
    --accent-blue: #3b82f6;       /* Steel Blue */
    --accent-green: #10b981;      /* Emerald Green */
    --accent-orange: #f59e0b;     /* Amber Orange */
    --accent-indigo: #8b5cf6;     /* Indigo Violet */
    --accent-slate: #64748b;      /* Slate Grey */
    
    /* Device Color Codes */
    --left-side-color: #3b82f6;   
    --right-side-color: #f59e0b;  
    
    /* Typographic Hierarchy */
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Pro Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    
    /* Micro-interactions & Spacers */
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 10px;
    --radius-md: 6px;
    --radius-sm: 4px;
}

/* Global Reset & Base Structure */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Subtle scientific background grid overlay */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 0);
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 0;
}

/* App Container */
.app-container {
    max-width: 1680px;
    margin: 0 auto;
    padding: 32px 24px;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header Section */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

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

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
    transition: var(--transition-fast);
}

.logo-icon:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
    transform: scale(1.03);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator.ready {
    background-color: var(--accent-blue);
    box-shadow: 0 0 8px var(--accent-blue);
}

.status-indicator.loading {
    background-color: var(--accent-orange);
    box-shadow: 0 0 8px var(--accent-orange);
    animation: pulse 1.5s infinite;
}

.status-indicator.active {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Dashboard Responsive Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Panel Design System */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.panel:hover {
    border-color: var(--border-hover);
    background: var(--bg-panel-hover);
}

/* Custom left accent bars on panels to establish visual identity and remove AI template look */
.control-panel {
    grid-row: 1 / 6;
}

@media (max-width: 1024px) {
    .control-panel {
        grid-row: auto;
    }
}

.chart-panel {
    border-top: 3px solid var(--accent-blue);
}

.path-panel, .timeseries-panel {
    border-top: 3px solid var(--accent-blue);
    grid-column: 2 / 3;
}

@media (max-width: 1024px) {
    .path-panel, .timeseries-panel {
        grid-column: auto;
    }
}

.timeline-panel {
    border-top: 3px solid var(--accent-green);
    grid-column: 2 / 3;
}

.stats-panel {
    border-top: 3px solid var(--accent-orange);
}

.asymmetry-chart-panel {
    border-top: 3px solid var(--accent-indigo);
}

.table-panel {
    border-top: 3px solid var(--accent-slate);
    grid-column: 2 / 3;
}

@media (max-width: 1024px) {
    .timeline-panel, .table-panel {
        grid-column: auto;
    }
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 14px;
    letter-spacing: -0.01em;
}

.panel-title svg {
    color: var(--text-secondary);
}

/* Control Panel Groupings */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.control-help {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.label-with-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

/* File Drag & Drop Zone */
.file-uploader {
    border: 1.5px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 22px 16px;
    text-align: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.15);
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.file-uploader:hover, .file-uploader.drag-over {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.03);
}

.file-input-hidden {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.uploader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.upload-icon {
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.file-uploader:hover .upload-icon {
    color: var(--accent-blue);
    transform: translateY(-2px);
}

.upload-text {
    font-size: 0.82rem;
    color: var(--text-primary);
}

.upload-subtext {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Form Selector Elements */
.custom-select-wrapper {
    position: relative;
}

.custom-select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.88rem;
    appearance: none;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
}

.custom-select:focus {
    border-color: var(--accent-blue);
    background: rgba(0, 0, 0, 0.35);
}

.custom-select-wrapper::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--text-secondary);
    pointer-events: none;
}

/* Sliders */
.custom-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.06);
    outline: none;
    margin: 10px 0;
}

.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 2px solid var(--bg-primary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.custom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: #60a5fa;
}

.custom-slider:disabled::-webkit-slider-thumb {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Action Buttons */
.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--accent-blue);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.15);
}

.primary-btn:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.25);
}

.primary-btn:active:not(:disabled) {
    transform: translateY(0);
}

.primary-btn:disabled {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.06);
}

/* Active File Indicator status bar */
.active-file-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin-top: 4px;
    font-size: 0.78rem;
    transition: var(--transition-fast);
}

.active-file-indicator.loaded {
    background: rgba(16, 185, 129, 0.03);
    border-color: rgba(16, 185, 129, 0.15);
}

.active-file-indicator .indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #ef4444; /* red when empty */
    box-shadow: 0 0 6px #ef4444;
    transition: var(--transition-fast);
}

.active-file-indicator.loaded .indicator-dot {
    background-color: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
}

.active-file-indicator .active-file-text {
    color: var(--text-secondary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.active-file-indicator.loaded .active-file-text {
    color: var(--text-primary);
}

/* Charts Containers */
.chart-panel, .path-panel, .timeseries-panel {
    min-height: 480px;
    display: flex;
    flex-direction: column;
}

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

.chart-container-outer {
    flex-grow: 1;
    position: relative;
    width: 100%;
    height: 400px;
}

#echarts-plot, #echarts-path, #echarts-timeseries, #echarts-timeline, #echarts-asymmetry {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.panel.has-data .empty-state {
    display: none !important;
}

.chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    border: 1px dashed rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.1);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 320px;
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
}

.empty-state svg {
    color: var(--text-muted);
}

.empty-state p {
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Stats Summary Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition-fast);
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.1);
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card.accent-left {
    border-left: 3px solid var(--left-side-color);
}

.stat-card.accent-right {
    border-left: 3px solid var(--right-side-color);
}

.stat-card.accent-warning {
    border-left: 3px solid var(--text-muted); /* neutral gray to avoid side confusion */
}

/* Row for Stats and Asymmetry Chart */
.stats-asymmetry-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    grid-column: 2 / 3;
}

.asymmetry-chart-panel {
    min-height: 360px;
}

@media (max-width: 1200px) {
    .stats-asymmetry-row {
        grid-template-columns: 1fr;
    }
}

/* Telemetry Table Log Panel */
.table-container {
    overflow-x: auto;
    max-height: 250px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.2);
}

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

th {
    background-color: #0e121b;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2;
}

td {
    padding: 10px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-family: var(--font-mono); /* Monospace numbers look extremely clean and precise */
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.01);
    color: var(--text-primary);
}

.table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-family: var(--font-body);
    font-style: italic;
}

/* Badge Layouts in Table */
.side-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    font-family: var(--font-body);
}

.side-left {
    background-color: rgba(59, 130, 246, 0.08);
    color: var(--left-side-color);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.side-right {
    background-color: rgba(245, 158, 11, 0.08);
    color: var(--right-side-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.type-badge {
    background-color: rgba(255, 255, 255, 0.03);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-family: var(--font-body);
}

/* Custom Webkit Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}
