/* ==========================================================================
   PASCAL'S PRINCIPLE VIRTUAL PHYSICS LABORATORY
   Design System & Styling Rules
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-base: #0b0f19;
    --bg-card: #111827;
    --bg-card-hover: #1f2937;
    --bg-input: #1a2234;
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(6, 182, 212, 0.3);
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Accents & Status */
    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-coral: #ef4444;
    --accent-purple: #8b5cf6;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --font-display: 'Outfit', sans-serif;
    
    /* Radii & Shadows */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.2);
}

/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding: 16px;
    min-height: 100vh;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.header-brand .lab-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

.header-brand h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-brand h1 span {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 12px;
}

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

.mode-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.mode-selector select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.mode-selector select:focus {
    border-color: var(--accent-cyan);
}

/* Card Component Base */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 12px;
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.card-header h2 svg {
    color: var(--accent-cyan);
}

.badge-tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.badge-tag.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
    border-color: rgba(16, 185, 129, 0.2);
}

/* Main Layout Grid */
.lab-main-layout {
    display: grid;
    grid-template-columns: 1fr 480px;
    gap: 20px;
}

@media (max-width: 1200px) {
    .lab-main-layout {
        grid-template-columns: 1fr;
    }
}

/* Viewport / Simulation Section */
.viewport-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.canvas-controls-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 480px;
    background: radial-gradient(circle at center, #151d2a 0%, #0b0f19 100%);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

#hydraulic-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Canvas Status Overlay */
.status-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

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

.status-badge.ready .status-dot { background: var(--accent-cyan); box-shadow: 0 0 8px var(--accent-cyan); }
.status-badge.pressurizing .status-dot { background: var(--accent-amber); box-shadow: 0 0 8px var(--accent-amber); }
.status-badge.lifting .status-dot { background: var(--accent-emerald); box-shadow: 0 0 8px var(--accent-emerald); }
.status-badge.insufficient .status-dot { background: var(--accent-coral); box-shadow: 0 0 8px var(--accent-coral); }

/* Small Piston Push Target Handle */
.piston-handle-touch {
    position: absolute;
    width: 80px;
    height: 36px;
    background: rgba(239, 68, 68, 0.2);
    border: 2px stroke var(--accent-coral);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    transition: transform 0.1s ease;
    opacity: 0.85;
}

.piston-handle-touch:active {
    cursor: grabbing;
    background: rgba(239, 68, 68, 0.4);
}

.handle-arrow {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-coral);
}

/* Pressure Gauge Bar Component */
.pressure-gauge-card {
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gauge-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
}

.gauge-title {
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.gauge-val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent-cyan);
}

.gauge-bar-track {
    position: relative;
    height: 14px;
    background: var(--bg-input);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.gauge-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue) 0%, var(--accent-cyan) 50%, var(--accent-coral) 100%);
    border-radius: 7px;
    transition: width 0.15s ease-out;
}

.gauge-marker-peak {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #fff;
    box-shadow: 0 0 6px #fff;
    opacity: 0.7;
    left: 0;
}

.gauge-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Control Panel Section */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.control-group {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group.full-width {
    grid-column: 1 / -1;
}

.control-group.highlight {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

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

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

.input-with-unit {
    display: flex;
    align-items: center;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
}

.input-with-unit input {
    width: 60px;
    background: transparent;
    border: none;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 700;
    text-align: right;
    outline: none;
}

.input-with-unit .unit {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Custom Sliders */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-base);
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-cyan);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider.accent-primary::-webkit-slider-thumb {
    background: var(--accent-coral);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.range-bounds {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Preset Buttons */
.preset-button-group {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.btn-preset {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-preset:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.btn-preset.active {
    background: rgba(6, 182, 212, 0.12);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    font-weight: 600;
}

.fluid-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.fluid-dot.water { background: #3b82f6; }
.fluid-dot.oil { background: #f59e0b; }
.fluid-dot.custom { background: #8b5cf6; }

/* Force Amplification & Area Comparison Card */
.amp-badge-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.amp-factor-val {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 2px 10px;
    border-radius: var(--radius-sm);
}

/* Force Flow Diagram */
.force-flow-diagram {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    gap: 4px;
    overflow-x: auto;
}

.flow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
}

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

.flow-step .step-val {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.flow-step.highlight-fluid .step-val { color: var(--accent-cyan); }
.flow-step.highlight-output .step-val { color: var(--accent-emerald); }

.flow-arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: bold;
}

/* Area Comparison Bars */
.area-bars-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.area-bar-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.area-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.bar-track {
    height: 10px;
    background: var(--bg-base);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.bar-fill {
    height: 100%;
    transition: width 0.2s ease-out;
}

.bar-fill.small-area { background: var(--accent-coral); }
.bar-fill.large-area { background: var(--accent-cyan); }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.dash-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dash-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.dash-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dash-value.accent-cyan { color: var(--accent-cyan); }
.dash-value.accent-green { color: var(--accent-emerald); }

.dash-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Buttons System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent-blue);
    color: #fff;
}

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 0 14px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-input);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.btn-icon {
    padding: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.btn-icon:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--accent-coral);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Secondary Grid Layout */
.secondary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

/* Verification Card Styling */
.verification-card {
    grid-column: 1 / -1;
}

.verification-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.verif-metrics {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.verif-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.verif-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
}

.verif-val {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.verif-equals {
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--text-muted);
}

.verif-formula {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.verification-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.verification-banner.verified {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-emerald);
}

.verification-banner.unverified {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-coral);
}

/* Observation Table Component */
.observation-card {
    grid-column: 1 / -1;
}

.table-actions {
    display: flex;
    gap: 10px;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 280px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

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

th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 10px 14px;
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-mono);
    white-space: nowrap;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.table-empty-msg {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* Guided Procedure Component */
.procedure-card {
    grid-column: span 1;
}

.procedure-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.procedure-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    transition: border-color 0.2s;
}

.procedure-step.active {
    border-color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.05);
}

.step-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.procedure-step.active .step-badge {
    background: var(--accent-cyan);
    color: var(--bg-base);
}

.step-content {
    font-size: 0.84rem;
    color: var(--text-secondary);
}

.procedure-step.active .step-content {
    color: var(--text-primary);
}

/* Theory & Reference Component */
.theory-card {
    grid-column: span 1;
}

.theory-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.theory-intro {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.formula-box-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formula-card {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.formula-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 0.5px;
}

.formula-eq {
    font-size: 1.05rem;
    padding: 4px 0;
}

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

/* Footer Component */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-subtle);
    padding-top: 16px;
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
