/* ==========================================================================
   OBDViz Analyzer Design System & Layout
   ========================================================================== */

/* 1. CSS Custom Properties & Variables */
:root {
    --bg-primary: #07080a;
    --bg-secondary: #0f111a;
    --card-bg: rgba(18, 20, 29, 0.65);
    --card-bg-hover: rgba(24, 27, 40, 0.85);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(0, 242, 254, 0.15);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-cyan: #00f2fe;
    --accent-blue: #0070f3;
    --accent-lime: #39ff14;
    --accent-orange: #f5a623;
    --accent-red: #ff3b30;
    --accent-magenta: #f012be;
    --accent-purple: #b10dc9;
    
    --font-sans: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Consolas', 'SFMono-Regular', monospace;
    
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.8);
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    
    --header-height: 64px;
}

/* 2. Base Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 242, 254, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(57, 255, 20, 0.01) 0px, transparent 50%);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 242, 254, 0.3);
}

/* Glassmorphism Panel Helper */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

/* Common Buttons */
.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.15);
}
.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-small {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: var(--transition-fast);
}
.btn-small:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}
.btn-small.active {
    background: var(--accent-cyan);
    color: #000;
    font-weight: 600;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}
.btn-small:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 3. App Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas: 
        "header header"
        "sidebar main";
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Header */
.app-header {
    grid-area: header;
    background: rgba(10, 12, 18, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

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

.logo-back-link {
    display: flex;
    align-items: center;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.35);
    transition: var(--transition-fast);
}
.logo-icon:hover {
    transform: scale(1.05);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-accent {
    color: var(--accent-cyan);
}

.logo-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.25);
    color: var(--accent-cyan);
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.8px;
}

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

.btn-sidebar-toggle {
    display: none; /* Desktop only */
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: var(--transition-fast);
}
.btn-sidebar-toggle:hover {
    background: rgba(0, 242, 254, 0.05);
    color: #fff;
    border-color: var(--accent-cyan);
}

.btn-help {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: var(--transition-fast);
}
.btn-help:hover {
    background: rgba(0, 242, 254, 0.06);
    border-color: var(--accent-cyan);
    color: #fff;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.25);
}
.btn-help svg {
    color: var(--accent-cyan);
}

.file-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
    flex-shrink: 0;
}
.file-status-dot.loaded {
    background-color: var(--accent-lime);
    box-shadow: 0 0 8px var(--accent-lime);
    animation: pulseStatus 2s infinite;
}

@keyframes pulseStatus {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* 4. Sidebar Drawer */
.app-sidebar {
    grid-area: sidebar;
    background: rgba(10, 12, 18, 0.4);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    z-index: 90;
}

.sidebar-header-mobile {
    display: none; /* Mobile only */
}

/* Drag & Drop Upload Zone */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent-cyan);
    background: rgba(0, 242, 254, 0.02);
    box-shadow: inset 0 0 15px rgba(0, 242, 254, 0.05);
}
.upload-icon {
    color: var(--text-secondary);
    transition: var(--transition-fast);
}
.upload-zone:hover .upload-icon {
    color: var(--accent-cyan);
    transform: translateY(-2px);
}
.upload-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.upload-subtext {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Shift Tracing Card */
.tool-options-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-header {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.panel-actions {
    display: flex;
    gap: 6px;
}

.panel-btn {
    background: transparent;
    border: none;
    color: var(--accent-cyan);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
}
.panel-btn:hover:not(:disabled) {
    text-decoration: underline;
}
.panel-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Search input */
.search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: #fff;
    padding: 8px 12px;
    font-size: 0.8rem;
    outline: none;
    font-family: var(--font-sans);
    margin: 10px 0 12px 0;
    transition: var(--transition-fast);
}
.search-input:focus:not(:disabled) {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.15);
}
.search-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Active Sensors Selection Container */
.sensor-selection-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px;
}

.sensor-list-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sensor-list-placeholder {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    margin-top: 40px;
}

/* Group container strings */
.sensor-group {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
}

.sensor-group-header {
    background: rgba(0, 0, 0, 0.15);
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-fast);
}
.sensor-group-header:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}
.sensor-group-header::after {
    content: "▼";
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.sensor-group.collapsed .sensor-group-header::after {
    transform: rotate(-90deg);
}

.group-count {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text-muted);
    margin-right: 6px;
}

.sensor-group-items {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sensor-group.collapsed .sensor-group-items {
    display: none;
}

/* Custom Checkboxes */
.sensor-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: var(--transition-fast);
    user-select: none;
}
.sensor-checkbox-label:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}
.sensor-checkbox-label.highlighted {
    background: rgba(0, 242, 254, 0.05);
    border-left: 2.5px solid var(--accent-cyan);
    color: #fff;
}

.sensor-checkbox {
    cursor: pointer;
    accent-color: var(--accent-cyan);
}

.sensor-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.sensor-checkbox-label span[title] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* 5. Main Dashboard Content */
.app-main {
    grid-area: main;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

/* Playback Control Bar */
.playback-control-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 242, 254, 0.2);
    transition: var(--transition-fast);
    flex-shrink: 0;
}
.btn-icon:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.35);
}
.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    box-shadow: none;
}

.timeline-scrubber-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
}

.time-scrubber {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    accent-color: var(--accent-cyan);
    -webkit-appearance: none;
}
.time-scrubber:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.time-display {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 140px;
    text-align: right;
}

.speed-select-container {
    display: flex;
    align-items: center;
    gap: 8px;
}
.speed-select-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}
.speed-select {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    font-family: var(--font-sans);
}
.speed-select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Animated Gauge Cluster Grid */
.gauge-cluster {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.gauge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    text-align: center;
    position: relative;
    overflow: visible; /* Required for config dropdown overlay */
}

.gauge-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gauge-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gauge-pid-tag {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
}

.gauge-config-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition-fast);
}
.gauge-config-btn:hover:not(:disabled) {
    color: var(--accent-cyan);
    transform: rotate(30deg);
}

.gauge-svg-container {
    position: relative;
    width: 130px;
    height: 130px;
}

.gauge-radial {
    transform: rotate(-220deg);
    transform-origin: 50% 50%;
}

.gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.03);
    stroke-width: 8;
    stroke-dasharray: 280;
    stroke-dashoffset: 80;
}

.gauge-fill {
    fill: none;
    stroke: url(#gaugeGradientCyan);
    stroke-width: 8;
    stroke-dasharray: 280;
    stroke-dashoffset: 280; /* Controlled dynamically: 280 - (val * 2) */
    stroke-linecap: round;
    transition: stroke-dashoffset 0.08s ease-out;
}

/* Radial colors */
.gauge-card.rpm .gauge-fill {
    stroke: url(#gaugeGradientOrange);
}
.gauge-card.speed .gauge-fill {
    stroke: url(#gaugeGradientBlue);
}
.gauge-card.aux-1 .gauge-fill {
    stroke: url(#gaugeGradientMagenta);
}
.gauge-card.aux-2 .gauge-fill {
    stroke: url(#gaugeGradientPurple);
}

.gauge-needle {
    width: 2px;
    height: 52px;
    background: var(--accent-red);
    position: absolute;
    bottom: 50%;
    left: calc(50% - 1px);
    transform-origin: bottom center;
    transform: rotate(-130deg); /* Range: -130deg to 130deg */
    transition: transform 0.08s ease-out;
    box-shadow: 0 0 6px var(--accent-red);
    border-radius: 2px;
    z-index: 2;
}

.gauge-center-cap {
    width: 10px;
    height: 10px;
    background: #141724;
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    position: absolute;
    top: calc(50% - 5px);
    left: calc(50% - 5px);
    box-shadow: var(--shadow-sm);
    z-index: 3;
}

.gauge-value-display {
    position: absolute;
    bottom: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.gauge-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.1;
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

.gauge-unit {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

/* Config Dropdown Overlay */
.gauge-dropdown {
    position: absolute;
    top: 36px;
    right: 12px;
    background: #0f121d;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 120;
    display: none;
    max-height: 180px;
    overflow-y: auto;
    width: 180px;
}
.gauge-dropdown.show {
    display: block;
    animation: dropdownFade 0.15s ease-out;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.gauge-dropdown-item {
    padding: 8px 12px;
    font-size: 0.75rem;
    text-align: left;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gauge-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-cyan);
}

/* Timeline Chart */
.chart-card {
    position: relative;
    min-height: 380px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

.chart-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-primary);
}

.chart-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
}

.chart-wrapper {
    position: relative;
    flex: 1;
    height: 300px;
    width: 100%;
}

/* Statistics Grid Section */
.metrics-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-label-header {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    border-left: 3px solid var(--accent-cyan);
    padding-left: 8px;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.metrics-placeholder {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 12px 0;
}

.metric-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-left: 3.5px solid var(--accent-blue);
    background: rgba(255, 255, 255, 0.01);
    position: relative;
}

.metric-panel::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(0, 242, 254, 0.015), transparent);
    pointer-events: none;
}

.metric-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.metric-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.metric-sparkline {
    width: 80px;
    height: 24px;
    opacity: 0.7;
}

.metric-values {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.metric-subval {
    display: flex;
    flex-direction: column;
}

.metric-subval-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.metric-subval-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
}

.metric-avg-container {
    grid-column: span 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding-top: 6px;
    margin-top: 2px;
}

.metric-avg-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.metric-avg-value {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

/* Raw Data Deep-Dive Table Card */
.data-table-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.table-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.table-search-input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    outline: none;
    width: 200px;
    font-family: var(--font-sans);
    transition: var(--transition-fast);
}
.table-search-input:focus:not(:disabled) {
    border-color: var(--accent-cyan);
}
.table-search-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15);
    max-height: 250px;
}

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

.data-table th, .data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.data-table th {
    background: rgba(18, 20, 29, 0.95);
    color: var(--text-secondary);
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 1;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.data-table tbody tr {
    cursor: pointer;
    transition: var(--transition-fast);
}
.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}
.data-table tbody tr.active-row {
    background: rgba(0, 242, 254, 0.08) !important;
}

.data-table td {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.data-table td.null-value {
    color: var(--text-muted);
}

.table-placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 24px !important;
}

.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

/* Shift active segment table row highlighting */
.data-table tbody tr.clutch-active {
    background: rgba(255, 59, 48, 0.05);
}
.data-table tbody tr.clutch-active td {
    color: hsl(0, 100%, 75%);
}
.data-table tbody tr.clutch-active.active-row {
    background: rgba(255, 59, 48, 0.15) !important;
}

/* Fullscreen Maximized Chart Layout overrides */
.app-main.chart-maximized > *:not(.playback-control-bar):not(.chart-card) {
    display: none !important;
}

.app-main.chart-maximized .chart-card {
    flex: 1;
    min-height: 0;
    height: auto;
}

.app-main.chart-maximized .chart-wrapper {
    height: 100%;
    flex: 1;
}

/* 6. Help Modal Styling */
.help-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 7, 10, 0.8);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.help-modal {
    width: 840px;
    max-width: 95%;
    height: 520px;
    max-height: 85vh;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 242, 254, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.15);
}

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

.help-modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.help-icon-badge {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-cyan);
}

.help-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-fast);
}
.help-close-btn:hover {
    color: var(--accent-red);
    transform: scale(1.1);
}

.help-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.help-modal-tabs {
    width: 200px;
    background: rgba(0, 0, 0, 0.25);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex-shrink: 0;
}

.help-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 14px;
    border-radius: 8px;
    text-align: left;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    border-left: 3px solid transparent;
}
.help-tab-btn:hover {
    background: rgba(255, 255, 255, 0.02);
    color: #fff;
}
.help-tab-btn.active {
    background: rgba(0, 242, 254, 0.05);
    color: var(--accent-cyan);
    font-weight: 600;
    border-left-color: var(--accent-cyan);
}

.help-modal-content-pane {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.05);
}

.help-tab-content {
    display: none;
}
.help-tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: modalContentFade 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.help-tab-content h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-left: 3px solid var(--accent-cyan);
    padding-left: 8px;
    line-height: 1.2;
}

.help-tab-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.help-tab-content ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-tab-content li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    position: relative;
    padding-left: 18px;
    line-height: 1.4;
}
.help-tab-content li::before {
    content: "•";
    color: var(--accent-cyan);
    position: absolute;
    left: 4px;
    font-weight: bold;
}

.help-tab-content code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 2px 5px;
    border-radius: 4px;
    color: #fff;
    font-size: 0.78rem;
}

.help-step-box {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 12px 16px;
    align-items: center;
}

.step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-cyan);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.3);
}

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

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

/* ==========================================================================
   7. Responsive Design / Mobile Layout Breakpoints
   ========================================================================== */

/* Tablet Layout (max-width: 1024px) */
@media (max-width: 1024px) {
    .gauge-cluster {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile Screen Layout (max-width: 768px) */
@media (max-width: 768px) {
    /* Header adaptations */
    .btn-sidebar-toggle {
        display: inline-flex;
    }
    
    .file-status-badge {
        max-width: 130px;
        padding: 6px 10px;
    }
    
    /* Layout grid reset to single column vertical scrolling flow */
    .app-container {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "header"
            "main";
        overflow: auto; /* Allow entire screen body scroll on mobile */
        height: auto;
    }
    
    .app-main {
        overflow-y: visible; /* Rely on container scroll */
        height: auto;
        padding: 12px;
        gap: 12px;
    }
    
    /* Collapsible sliding Parameter selection drawer */
    .app-sidebar {
        position: fixed;
        top: 0;
        left: -320px;
        width: 300px;
        height: 100vh;
        background: #0b0d15;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
        z-index: 1100;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        border-right: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
    }
    
    /* Reveal state toggled by active class */
    .app-sidebar.open-drawer {
        transform: translateX(320px);
    }
    
    .sidebar-header-mobile {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        margin-bottom: 8px;
    }
    .sidebar-header-mobile h2 {
        font-size: 0.95rem;
        text-transform: uppercase;
        font-weight: 700;
        color: #fff;
    }
    
    .close-btn-mobile {
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 1.6rem;
        cursor: pointer;
    }
    
    /* Playback bar stacking */
    .playback-control-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }
    
    .timeline-scrubber-container {
        width: 100%;
        order: 2;
    }
    
    .speed-select-container {
        justify-content: space-between;
        order: 3;
    }
    
    .btn-icon {
        align-self: center;
        order: 1;
    }
    
    /* Gauges */
    .gauge-cluster {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .gauge-card {
        padding: 12px;
    }
    
    .gauge-svg-container {
        width: 110px;
        height: 110px;
    }
    
    .gauge-value {
        font-size: 1.2rem;
    }
    
    /* Charts */
    .chart-card {
        min-height: 280px;
    }
    .chart-wrapper {
        height: 220px;
    }
    .chart-controls {
        width: 100%;
        justify-content: space-between;
        margin-top: 6px;
    }
    
    /* Table Search Stacking */
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .table-search-input {
        width: 100%;
    }
    
    /* Help modal overlays */
    .help-modal {
        height: 90vh;
        width: 95%;
    }
    
    .help-modal-body {
        flex-direction: column;
    }
    
    .help-modal-tabs {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        padding: 6px;
        height: auto;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .help-tab-btn {
        border-left: none;
        border-bottom: 3.5px solid transparent;
        padding: 6px 12px;
    }
    
    .help-tab-btn.active {
        border-bottom-color: var(--accent-cyan);
        background: rgba(0, 242, 254, 0.03);
    }
}

/* Small mobile devices (max-width: 380px) */
@media (max-width: 380px) {
    .gauge-cluster {
        grid-template-columns: 1fr; /* Single column stack for gauges on super small screens */
    }
}
/* Multi-Chart Studio Styles */
.workspace-controls-card {
    padding: 12px 16px;
    margin-bottom: -4px;
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

/* Instrument Panel Theme Accent Overrides */
body.theme-red {
    --bg-primary: #0a0505;
    --bg-secondary: #140b0b;
    --accent-cyan: #ff3b30;
    --border-glow: rgba(255, 59, 48, 0.15);
}

body.theme-amber {
    --bg-primary: #080603;
    --bg-secondary: #120e0a;
    --accent-cyan: #f5a623;
    --border-glow: rgba(245, 166, 35, 0.15);
}

body.theme-mint {
    --bg-primary: #040805;
    --bg-secondary: #0a120c;
    --accent-cyan: #39ff14;
    --border-glow: rgba(57, 255, 20, 0.15);
}

body.theme-slate {
    --bg-primary: #0a0b0d;
    --bg-secondary: #12141c;
    --accent-cyan: #9ca3af;
    --border-glow: rgba(156, 163, 175, 0.15);
}

.multi-chart-workspace {
    width: 100%;
}

.multi-chart-workspace.layout-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.multi-chart-workspace.layout-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.multi-chart-workspace.layout-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Tab/Mobile layout grid collapse override */
@media (max-width: 1024px) {
    .multi-chart-workspace.layout-grid-2,
    .multi-chart-workspace.layout-grid-3 {
        grid-template-columns: 1fr !important;
    }
}

.chart-card {
    min-height: 320px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    cursor: pointer;
}

.chart-card.active-target {
    border: 1px solid var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.12);
}

.chart-card-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.chart-active-indicator {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent-cyan);
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.chart-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.chart-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.chart-pill:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.chart-pill-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.chart-pill-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.chart-pill-remove:hover {
    color: var(--accent-red);
}

.btn-delete-chart {
    background: rgba(255, 59, 48, 0.05);
    border: 1px solid rgba(255, 59, 48, 0.15);
    color: hsl(0, 100%, 75%);
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-delete-chart:hover {
    background: rgba(255, 59, 48, 0.12);
    border-color: rgba(255, 59, 48, 0.35);
    color: #fff;
}

/* Mobile responsive adjustments for Multi-Chart Studio */
@media (max-width: 768px) {
    .workspace-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .workspace-header .chart-controls {
        justify-content: space-between;
        width: 100%;
    }
    .chart-card {
        min-height: 250px;
    }
    .chart-wrapper {
        height: 190px;
    }
    .chart-card-header-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 4px;
    }
}
