/* ==========================================================================
   Virtual Instrumentation Labs - Newton's First Law Virtual Physics Laboratory
   Theme: High-Tech Dark Laboratory / Glassmorphism Design System
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-dark: #090d16;
    --bg-panel: rgba(15, 23, 42, 0.75);
    --bg-card: rgba(30, 41, 59, 0.65);
    --bg-card-hover: rgba(51, 65, 85, 0.8);
    
    --border-glow: rgba(56, 189, 248, 0.2);
    --border-subtle: rgba(255, 255, 255, 0.08);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    /* Vectors & Accents */
    --cyan-glow: #00f2fe;
    --cyan-solid: #38bdf8;
    --red-friction: #ff4b4b;
    --emerald-velocity: #10b981;
    --amber-gravity: #f59e0b;
    --blue-normal: #3b82f6;
    
    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --shadow-glow: 0 0 25px rgba(0, 242, 254, 0.15);
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 10%, rgba(0, 242, 254, 0.08) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(59, 130, 246, 0.06) 0px, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Container Layout */
.lab-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.25rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Header Component */
.lab-header {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 242, 254, 0.1);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(0, 242, 254, 0.3);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--cyan-solid);
}

.header-experiment {
    text-align: center;
}

.exp-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--cyan-solid);
    background: rgba(56, 189, 248, 0.1);
    padding: 2px 10px;
    border-radius: 12px;
    border: 1px solid rgba(56, 189, 248, 0.25);
    margin-bottom: 2px;
}

.exp-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Status Indicator Pill */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--emerald-velocity);
}

.pulse-green {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-text {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--emerald-velocity);
}

/* Workspace Main Layout Grid */
.lab-workspace {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.25rem;
}

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

/* Viewport Section */
.viewport-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.canvas-wrapper {
    position: relative;
    background: #070a12;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    min-height: 480px;
}

/* HUD Overlay Badges */
.hud-overlay {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.75rem;
    z-index: 10;
    pointer-events: none;
    flex-wrap: wrap;
}

.hud-card {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    min-width: 110px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.hud-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.hud-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--cyan-glow);
}

.hud-value small {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.hud-value-badge {
    display: inline-block;
    margin-top: 2px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffffff;
    background: rgba(56, 189, 248, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.4);
    text-align: center;
}

/* Motion state variants */
.hud-value-badge.state-rest {
    background: rgba(100, 116, 139, 0.25);
    border-color: #64748b;
    color: #cbd5e1;
}

.hud-value-badge.state-uniform {
    background: rgba(16, 185, 129, 0.25);
    border-color: #10b981;
    color: #34d399;
}

.hud-value-badge.state-accel {
    background: rgba(0, 242, 254, 0.25);
    border-color: #00f2fe;
    color: #38bdf8;
}

.hud-value-badge.state-decel {
    background: rgba(255, 75, 75, 0.25);
    border-color: #ff4b4b;
    color: #f87171;
}

/* Viewport Canvas Control Overlay */
.viewport-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.view-btn {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.view-btn:hover {
    background: rgba(30, 41, 59, 0.9);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.25);
}

.view-btn.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--cyan-solid);
}

/* Main SVG Styling */
#physicsSvg {
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
}

/* Simulation Playback & Command Bar */
.sim-command-bar {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
    flex-wrap: wrap;
    gap: 1rem;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Button UI Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.65rem 1.25rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    color: #070a12;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 242, 254, 0.45);
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-accent {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
}

.btn-accent:hover {
    background: rgba(16, 185, 129, 0.25);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.hidden {
    display: none !important;
}

.simulation-time-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.6);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.time-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

.time-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cyan-solid);
}

/* Sidebar & Controls Panel */
.controls-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.panel-card {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-title svg {
    color: var(--cyan-solid);
}

/* Presets Grid */
.presets-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preset-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.85rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: var(--transition-fast);
}

.preset-btn:hover {
    background: var(--bg-card-hover);
    border-color: rgba(56, 189, 248, 0.3);
}

.preset-btn.active {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.1);
}

.preset-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.preset-btn.active .preset-name {
    color: var(--cyan-solid);
}

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

/* Input Controls & Sliders */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.15rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

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

.control-header label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
}

.control-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--cyan-solid);
    background: rgba(56, 189, 248, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Custom Range Slider Input */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #1e293b;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--cyan-glow);
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.6);
    cursor: pointer;
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-marks {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-dim);
}

/* Force Direction Controls */
.force-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.direction-toggle {
    display: flex;
    gap: 2px;
    background: #0f172a;
    padding: 2px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.dir-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.dir-btn.active {
    background: var(--cyan-solid);
    color: #070a12;
}

.surface-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.5);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #38bdf8;
}

/* Bottom Panel: Analytics & Flowchart */
.lab-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 900px) {
    .lab-bottom-grid {
        grid-template-columns: 1fr;
    }
}

.analytics-card, .principle-card {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 svg {
    color: var(--cyan-solid);
}

.chart-legend {
    display: flex;
    gap: 12px;
}

.legend-item {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.color-velocity { background: var(--emerald-velocity); }
.color-force { background: var(--cyan-glow); }

/* SVG Telemetry Chart Container */
.chart-container {
    position: relative;
    background: #070a12;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    height: 180px;
}

#telemetryChartSvg {
    width: 100%;
    height: 100%;
}

.chart-axis-label-y {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.chart-axis-label-zero {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.chart-axis-label-neg {
    position: absolute;
    bottom: 6px;
    left: 8px;
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.chart-axis-label-x {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

/* Working Principle Flowchart */
.flowchart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.flow-step {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition-fast);
}

.flow-step.active {
    background: rgba(0, 242, 254, 0.12);
    border-color: rgba(0, 242, 254, 0.5);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.15);
}

.flow-icon {
    font-size: 1.25rem;
    background: rgba(15, 23, 42, 0.6);
    padding: 6px 10px;
    border-radius: 8px;
}

.flow-content {
    display: flex;
    flex-direction: column;
}

.flow-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.flow-step.active .flow-title {
    color: var(--cyan-solid);
}

.flow-sub {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.flow-arrow {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dim);
    transition: var(--transition-fast);
}

.flow-arrow.active {
    color: var(--cyan-solid);
    transform: scale(1.2);
}

/* Footer Section */
.lab-footer {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-card);
}

.theory-box h4 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--cyan-solid);
    margin-bottom: 0.35rem;
}

.theory-box p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ================= RESPONSIVE MEDIA QUERIES ================= */

/* Tablet */
@media screen and (max-width: 1024px) {
    .lab-workspace {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .lab-bottom-grid {
        grid-template-columns: 1fr;
    }
    .lab-container {
        padding: 0 1rem;
        margin: 1rem auto;
        gap: 1rem;
    }
    .header-container, .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Mobile Portrait */
@media screen and (max-width: 767px) and (orientation: portrait) {
    .lab-workspace {
        display: flex;
        flex-direction: column;
    }
    .lab-bottom-grid {
        display: flex;
        flex-direction: column;
    }
    .canvas-wrapper svg, .canvas-wrapper canvas {
        width: 100% !important;
        height: auto !important;
        max-height: 50vh;
    }
    /* Touch-friendly targets */
    .btn, button, select, input[type="range"] {
        min-height: 44px;
        font-size: 16px !important;
    }
    .lab-container {
        padding: 0 0.5rem;
        margin: 0.5rem auto;
        gap: 0.75rem;
    }
    .app-header, .lab-header {
        padding: 0.6rem 0.75rem;
    }
}

/* Mobile Landscape */
@media screen and (max-width: 950px) and (orientation: landscape) {
    .lab-workspace {
        display: grid;
        grid-template-columns: 1.2fr 0.8fr;
        gap: 0.75rem;
    }
    .lab-bottom-grid {
        grid-template-columns: 1fr 1fr;
    }
    .lab-container {
        padding: 0 0.5rem;
        margin: 0.5rem auto;
    }
}

/* Viewport Controls Responsive Behavior */
@media screen and (max-width: 768px) {
    .viewport-controls .view-btn span {
        display: none;
    }
    .viewport-controls .view-btn {
        padding: 8px 10px;
    }
}
