/* ============================================================
   refraction-sim.css — Refraction Simulator Main App Styles
   ─────────────────────────────────────────────────────────────
   PURPOSE : Grid layout, panels, badges, ray canvas, and responsive design.
   ============================================================ */

:root {
  --ref-bg: #080d12;
  --ref-surface: #0e1720;
  --ref-surface-card: #14202c;
  --ref-surface-elevated: #1b2b3a;
  --ref-border: #203344;
  --ref-border-focus: #38bdf8;
  --ref-accent: #0ea5e9;
  --ref-accent-tint: rgba(14, 165, 233, 0.15);
  --ref-text: #f1f5f9;
  --ref-text-muted: #94a3b8;
  --ref-text-faint: #64748b;
  --ref-gold: #facc15;
  --ref-red: #ef4444;
  --ref-green: #22c55e;
  --ref-orange: #f97316;
}

[hidden] {
  display: none !important;
}

/* ── Main App Shell ── */
.ref-app {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 120px);
  background: var(--ref-bg);
  color: var(--ref-text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  padding: 16px 24px 32px;
  gap: 16px;
}

/* ── Top Bar: Modes & Indicators ── */
.ref-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--ref-surface);
  border: 1px solid var(--ref-border);
  border-radius: 12px;
  padding: 10px 18px;
}

.ref-view-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ref-view-btn {
  background: var(--ref-surface-card);
  color: var(--ref-text-muted);
  border: 1px solid var(--ref-border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.ref-view-btn:hover {
  background: var(--ref-surface-elevated);
  color: var(--ref-text);
  border-color: #334d63;
}

.ref-view-btn.active {
  background: var(--ref-accent);
  color: #ffffff;
  border-color: var(--ref-accent);
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.4);
}

.ref-top-indicators {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ref-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--ref-surface-card);
  border: 1px solid var(--ref-border);
  color: var(--ref-text);
}

.ref-badge--good {
  border-color: #166534;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.ref-badge--warn {
  border-color: #991b1b;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* ── Presets Ribbon ── */
.ref-presets-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px;
  background: var(--ref-surface);
  border: 1px solid var(--ref-border);
  border-radius: 10px;
  scrollbar-width: thin;
}

.ref-preset-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ref-text-faint);
  white-space: nowrap;
  margin-inline-end: 6px;
}

.ref-preset-btn {
  background: var(--ref-surface-card);
  color: var(--ref-text-muted);
  border: 1px solid var(--ref-border);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ref-preset-btn:hover {
  background: var(--ref-surface-elevated);
  color: var(--ref-text);
  border-color: #3b5a75;
}

.ref-preset-btn.active {
  background: var(--ref-accent-tint);
  border-color: var(--ref-accent);
  color: #38bdf8;
  font-weight: 600;
}

/* ── Main Simulator Workspace Grid ── */
.ref-workspace {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 16px;
  align-items: start;
}

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

/* ── Center Stage: Ray Canvas Viewport ── */
.ref-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ref-surface);
  border: 1px solid var(--ref-border);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  min-height: 570px;
}

.ref-canvas-wrapper {
  width: 100%;
  height: 540px;
  position: relative;
  background: #080d12;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #1a2a38;
}

.ref-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Meridian View Floating Selector */
.ref-meridian-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ref-surface-card);
  border: 1px solid var(--ref-border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
}

.ref-meridian-btns {
  display: flex;
  gap: 6px;
}

.ref-meridian-btn {
  background: var(--ref-surface-elevated);
  color: var(--ref-text-muted);
  border: 1px solid var(--ref-border);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.ref-meridian-btn.active {
  background: #facc15;
  color: #0f172a;
  border-color: #eab308;
  font-weight: 700;
}

/* Sturm Conoid Stage View */
.ref-sturm-view {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

.sturm-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Medical Atlas View */
.ref-atlas-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.ref-atlas-img {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--ref-border);
}

/* ── Sidebar Panels ── */
.ref-panel {
  background: var(--ref-surface);
  border: 1px solid var(--ref-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ref-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ref-border);
  padding-bottom: 8px;
  margin: 0;
}

/* Form Controls & Sliders */
.ref-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ref-field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ref-text-muted);
}

.ref-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ref-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #1e293b;
  outline: none;
  cursor: pointer;
  accent-color: var(--ref-accent);
}

.ref-num-input {
  width: 68px;
  background: var(--ref-surface-card);
  border: 1px solid var(--ref-border);
  border-radius: 6px;
  color: #f8fafc;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 4px 6px;
  text-align: center;
}

.ref-num-input:focus {
  border-color: var(--ref-border-focus);
  outline: none;
}

.ref-select {
  background: var(--ref-surface-card);
  border: 1px solid var(--ref-border);
  border-radius: 6px;
  color: var(--ref-text);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}

.ref-select:focus {
  border-color: var(--ref-border-focus);
  outline: none;
}

/* Quick Action Buttons */
.ref-btn-primary {
  background: var(--ref-accent);
  color: #ffffff;
  border: none;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  width: 100%;
}

.ref-btn-primary:hover {
  background: #0284c7;
}

.ref-btn-secondary {
  background: var(--ref-surface-card);
  color: var(--ref-text-muted);
  border: 1px solid var(--ref-border);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.ref-btn-secondary:hover {
  background: var(--ref-surface-elevated);
  color: var(--ref-text);
}

/* ── Live Readouts Section ── */
.ref-readouts-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-readout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--ref-surface-card);
  border-radius: 6px;
  font-size: 12px;
}

.ref-readout-label {
  color: var(--ref-text-muted);
}

.ref-readout-val {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  color: #f8fafc;
}

/* Power Cross Display Container */
.ref-optical-cross-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: #090e13;
  border: 1px solid var(--ref-border);
  border-radius: 8px;
}

/* ── Modal Guide Dialog ── */
.ref-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.ref-modal-backdrop[hidden] {
  display: none !important;
}

.ref-modal {
  background: var(--ref-surface);
  border: 1px solid var(--ref-border);
  border-radius: 14px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

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

.ref-modal-title {
  margin: 0;
  font-size: 18px;
  color: #f8fafc;
  font-family: 'Source Serif 4', serif;
}

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

.ref-modal-close:hover {
  color: #ffffff;
}

.ref-guide-card {
  background: var(--ref-surface-card);
  border: 1px solid var(--ref-border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.ref-guide-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #38bdf8;
}

.ref-guide-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ref-text-muted);
}
