/* ==========================================================================
   Virtual Instrumentation Labs | C-Type Bourdon Tube Virtual Laboratory CSS
   Engineering Grade Design System & Layout Utilities
   ========================================================================== */

:root {
  /* Color Palette - University Lab Theme */
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-panel-header: #f8fafc;
  
  --primary-navy: #0f172a;
  --primary-blue: #0284c7;
  --primary-blue-hover: #0369a1;
  --accent-cyan: #06b6d4;
  
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-dark: #334155;
  
  --status-idle: #94a3b8;
  --status-active: #10b981;
  --status-alert: #ef4444;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.15);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   1. HEADER BAR
   ========================================================================== */
.lab-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--primary-blue);
  box-shadow: var(--shadow-md);
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  background: rgba(2, 132, 199, 0.2);
  border: 2px solid var(--primary-blue);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #38bdf8;
}

.brand-title h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-vlab {
  font-size: 10px;
  font-weight: 700;
  background: var(--primary-blue);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.subtitle {
  font-size: 12px;
  color: var(--text-light);
}

.experiment-meta {
  display: flex;
  align-items: center;
  gap: 24px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.meta-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.8px;
}

.meta-val {
  font-size: 13px;
  font-weight: 600;
  color: #f8fafc;
}

.status-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 30px;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

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

.status-dot.active {
  background-color: var(--status-active);
  box-shadow: 0 0 10px var(--status-active);
}

/* ==========================================================================
   2. MAIN 3-PANEL LABORATORY CONTAINER
   ========================================================================== */
.lab-container {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  padding: 16px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Panel Layout Reset */
.lab-panel {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  background-color: var(--bg-panel-header);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header h2 i {
  color: var(--primary-blue);
}

/* ==========================================================================
   3. LEFT PANEL: VIRTUAL EXPERIMENT SETUP (SVG CANVAS)
   ========================================================================== */
.panel-setup {
  grid-column: 1;
  grid-row: 1;
  min-height: 520px;
}

.view-controls {
  display: flex;
  gap: 8px;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 480px;
  background-color: #fafafa;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.svg-grid-bg {
  display: none !important;
  background-image: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

#labSvg {
  width: 100%;
  height: 100%;
  max-height: 550px;
  user-select: none;
}

/* SVG Interactive Callouts & Elements */
.callout-item {
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.callout-item:hover {
  transform: scale(1.05);
}

.callout-item rect {
  transition: fill 0.2s ease;
}

.callout-item:hover rect {
  fill: var(--primary-blue);
}

/* Dial Glass Cutaway Mode Styling */
#dialFaceGroup {
  transition: opacity 0.4s ease;
}

#dialFaceGroup.cutaway-active {
  opacity: 0.25;
}

.legend-bar {
  background-color: var(--bg-panel-header);
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-icon {
  color: var(--primary-blue);
}

/* ==========================================================================
   4. RIGHT PANEL: CONTROLS & LIVE TELEMETRY
   ========================================================================== */
.panel-controls {
  grid-column: 2;
  grid-row: 1;
}

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

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.readout-pill {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  background-color: #e0f2fe;
  color: var(--primary-blue-hover);
  padding: 2px 10px;
  border-radius: 12px;
  border: 1px solid #bae6fd;
}

/* Toggle Buttons */
.toggle-switch-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background-color: var(--bg-main);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.btn-toggle {
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle.active {
  background-color: var(--bg-card);
  color: var(--primary-blue);
  box-shadow: var(--shadow-sm);
}

.divider {
  border: 0;
  height: 1px;
  background-color: var(--border-light);
}

/* Regulator Box (Knob + Slider) */
.regulator-box {
  background-color: var(--bg-panel-header);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.knob-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.rotary-knob {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #475569, #0f172a);
  border: 4px solid var(--border-medium);
  box-shadow: var(--shadow-md);
  position: relative;
  cursor: grab;
  transform: rotate(-135deg);
  transition: border-color 0.2s ease;
}

.rotary-knob:active {
  cursor: grabbing;
  border-color: var(--primary-blue);
}

.knob-indicator {
  width: 4px;
  height: 20px;
  background-color: #38bdf8;
  border-radius: 2px;
  position: absolute;
  top: 6px;
  left: calc(50% - 2px);
}

.knob-hint {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.5px;
}

.slider-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border-medium);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-blue);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease;
}

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

.range-marks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px;
}

/* Preset Buttons */
.preset-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-preset {
  background-color: var(--bg-main);
  border: 1px solid var(--border-light);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-preset:hover {
  background-color: #e0f2fe;
  border-color: #7dd3fc;
  color: var(--primary-blue-hover);
}

/* Telemetry Cards Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.telemetry-card {
  background-color: var(--bg-panel-header);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: #e0f2fe;
  color: var(--primary-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.card-data {
  display: flex;
  flex-direction: column;
}

.card-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.5px;
}

.card-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.card-value small {
  font-size: 11px;
  color: var(--text-muted);
}

.card-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================================================
   5. BOTTOM PANEL: OBSERVATION TABLE & THEORY
   ========================================================================== */
.panel-observation {
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 320px;
}

.tab-navigation {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--primary-blue);
  background-color: rgba(2, 132, 199, 0.05);
}

.tab-btn.active {
  background-color: var(--bg-card);
  color: var(--primary-blue);
  box-shadow: var(--shadow-sm);
}

.tab-actions {
  display: flex;
  gap: 8px;
}

.tab-content-container {
  padding: 16px;
  flex: 1;
}

.tab-pane {
  display: none;
}

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

/* Observation Table Styling */
.table-wrapper {
  overflow-x: auto;
  max-height: 240px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.lab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.lab-table th {
  background-color: var(--bg-panel-header);
  color: var(--text-dark);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-medium);
  position: sticky;
  top: 0;
  z-index: 10;
}

.lab-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 12px;
}

.lab-table tbody tr:hover {
  background-color: #f8fafc;
}

.empty-row td {
  text-anchor: middle;
  text-align: center;
  font-family: var(--font-sans);
  color: var(--text-muted);
  padding: 30px;
}

/* Graph Styling */
.graph-container {
  width: 100%;
  height: 220px;
  position: relative;
}

/* Theory & Specs Layouts */
.theory-grid, .specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.theory-card, .spec-card {
  background-color: var(--bg-panel-header);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px;
}

.theory-card h3, .spec-card h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-navy);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theory-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.step-list {
  padding-left: 20px;
  font-size: 12px;
  color: var(--text-dark);
}

.step-list li {
  margin-bottom: 6px;
}

.formula-box {
  background-color: #ffffff;
  border-left: 3px solid var(--primary-blue);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.formula-sub {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
}

.spec-list {
  list-style: none;
  font-size: 12px;
}

.spec-list li {
  padding: 4px 0;
  border-bottom: 1px stroke var(--border-light);
}

/* ==========================================================================
   6. BUTTONS & UI COMPONENTS
   ========================================================================== */
.btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-blue-hover);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.btn-secondary {
  background-color: #334155;
  color: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #1e293b;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-dark);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--bg-panel-header);
  border-color: var(--border-dark);
}

.btn-accent {
  background-color: #0d9488;
  color: #ffffff;
}

.btn-accent:hover:not(:disabled) {
  background-color: #0f766e;
}

.btn-lg {
  padding: 10px 18px;
  font-size: 14px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

.btn-icon.active {
  color: var(--primary-blue);
  border-color: var(--primary-blue);
}

.btn-block {
  width: 100%;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.modal-header {
  background-color: var(--bg-panel-header);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-navy);
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  font-size: 13px;
  color: var(--text-dark);
  line-height: 1.6;
}

/* Responsive Adjustments */
@media (max-width: 1100px) {
  .lab-container {
    grid-template-columns: 1fr;
  }
  
  .panel-setup, .panel-controls {
    grid-column: 1;
  }
  
  .panel-controls {
    grid-row: 2;
  }
  
  .panel-observation {
    grid-row: 3;
  }
}

/* Mobile Portrait */
@media screen and (max-width: 767px) and (orientation: portrait) {
  .lab-container {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 10px;
  }
  .panel-setup {
    order: 1;
  }
  .panel-controls {
    order: 2;
  }
  .panel-observation {
    order: 3;
  }
  .gauge-svg-container svg {
    width: 100%;
    height: auto;
    max-height: 50vh;
  }
  .action-buttons, .button-row {
    grid-template-columns: 1fr;
  }
  .reading-grid, .metric-grid {
    grid-template-columns: 1fr;
  }
  /* Touch-friendly targets */
  .btn, button, select, input[type="range"], .tab-btn {
    min-height: 44px;
    font-size: 16px !important;
  }
  .lab-header {
    padding: 8px 12px;
    flex-direction: column;
    gap: 8px;
  }
  .header-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

/* Mobile Landscape */
@media screen and (max-width: 950px) and (orientation: landscape) {
  .lab-container {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    grid-template-rows: auto auto;
    padding: 8px;
    gap: 10px;
  }
  .panel-observation {
    grid-column: 1 / -1;
  }
}
