/*
  MOSFET Simulator - Liquid Glass Styling
  Author: Dr. Gerard Joseph Lim
*/

:root {
  --bg-deep: #030712;
  --bg-surface: rgba(15, 23, 42, 0.65);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-highlight: rgba(255, 255, 255, 0.28);
  --glass-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.55);
  --primary-cyan: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.35);
  --accent-gold: #fbbf24;
  --accent-rose: #fb7185;
  --accent-emerald: #34d399;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-math: 'Cambria Math', 'STIX Two Math', 'KaTeX_Math', 'Latin Modern Math', 'Times New Roman', serif;
  --font-math-roman: 'Cambria', 'STIX Two Text', 'KaTeX_Main', 'Latin Modern Roman', 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.glass-simulation-body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* App Container (Sequential Flex Layout, Zero Overlap) */
.mosfet-app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  padding: 10px 18px 6px 18px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 50% 15%, rgba(56, 189, 248, 0.04) 0%, transparent 60%),
              radial-gradient(circle at 80% 80%, rgba(251, 191, 36, 0.03) 0%, transparent 50%);
}

/* Top Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  border-radius: 14px;
  margin-bottom: 8px;
  flex-shrink: 0;
  z-index: 20;
}

.badge-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary-cyan);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.mode-badges {
  display: flex;
  gap: 8px;
}

.status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.status-badge.badge-active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--primary-cyan);
}

.status-badge.badge-regime {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--accent-gold);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--primary-cyan);
  color: var(--primary-cyan);
}

/* Workspace Grid: Side-by-Side Split View */
.workspace-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  overflow: hidden;
}

/* Left Pane: Device Cross-Section & Band Diagram */
.left-pane {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: 20px;
  min-height: 0;
  overflow: hidden;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.pane-title-group {
  display: flex;
  flex-direction: column;
}

.pane-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

.pane-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.toggle-pill-btn {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Canvases */
.canvas-wrapper {
  flex: 1.2;
  min-height: 220px;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#deviceCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.band-diagram-wrapper {
  flex: 1;
  min-height: 165px;
  margin-top: 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.band-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.band-title {
  font-weight: 600;
  color: var(--text-muted);
}

.band-telemetry-text {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.68rem;
}

#bandCanvas {
  width: 100%;
  height: 100%;
  display: block;
  flex: 1;
}

/* Right Pane: Theory HUD & Graph Canvas */
.right-pane {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: 20px;
  min-height: 0;
  gap: 12px;
  overflow: hidden;
}

/* Theory HUD Card */
.theory-hud-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

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

.regime-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.regime-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

.regime-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.hud-condition {
  font-family: var(--font-math);
  font-size: 0.95rem;
  color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.22);
  padding: 3px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
}

.hud-condition .katex {
  font-size: 1.05em;
  color: var(--accent-gold);
}

.math-display-box {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.formula-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.math-label {
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--primary-cyan);
  width: 95px;
  flex-shrink: 0;
}

.math-expr {
  font-family: var(--font-math);
  font-size: 1.02rem;
  color: #f8fafc;
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  align-items: baseline;
  letter-spacing: 0.02em;
}

.math-expr .katex {
  font-size: 1.1em;
  color: #f8fafc;
}

/* Cambria Math / LaTeX-Style Inline Math Symbols */
.math-sym {
  font-family: var(--font-math);
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.math-roman {
  font-family: var(--font-math-roman);
  font-style: normal;
}

/* Fallback HTML Math Styling */
.m-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: -0.55em;
  padding: 0 3px;
  text-align: center;
  font-size: 0.9em;
  line-height: 1.1;
}

.m-num {
  border-bottom: 1.5px solid currentColor;
  padding-bottom: 1px;
}

.m-den {
  padding-top: 1px;
}

.telemetry-compact-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.telemetry-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.cell-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.cell-val.highlight {
  color: var(--primary-cyan);
}

.cell-val.mono {
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

/* Graph Section */
.graph-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
  overflow: hidden;
}

.graph-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

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

.graph-tab.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary-cyan);
}

.graph-legend {
  display: flex;
  gap: 12px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.graph-canvas-container {
  flex: 1;
  min-height: 0;
  position: relative;
}

#graphCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Bottom Controller Bar (Non-overlapping relative flex dock) */
.controls-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  z-index: 30;
  margin-top: 6px;
  margin-bottom: 2px;
}

.controls {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  border-radius: 16px;
  max-width: 98vw;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ctrl-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 2px;
}

.segment-btn {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.segment-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.slider-group {
  min-width: 130px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.slider-badge {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--primary-cyan);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 1px 6px;
  border-radius: 4px;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 8px var(--primary-cyan);
  cursor: pointer;
  transition: transform 0.1s;
}

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

.presets-group {
  display: flex;
  flex-direction: column;
}

.presets-row {
  display: flex;
  gap: 4px;
}

.btn-preset {
  font-size: 0.68rem;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-preset:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.divider {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
}

.btn {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border-color: rgba(56, 189, 248, 0.5);
  color: #ffffff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  width: 440px;
  max-width: 90vw;
  padding: 24px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

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

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

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.param-row input[type="number"],
.param-row input[type="text"] {
  width: 90px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: right;
}

.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-cyan);
}

/* Splash Modal */
.splash-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.splash-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-modal {
  width: 540px;
  max-width: 92vw;
  padding: 32px 36px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.splash-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
}

.splash-body h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary-cyan);
  margin-bottom: 8px;
}

.splash-body ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.splash-body ul li {
  position: relative;
  padding-left: 18px;
}

.splash-body ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--primary-cyan);
}

/* Signature Footer Link (Override global liquid-glass-components.css fixed position) */
.mosfet-app-container .signature-footer,
.mosfet-app-container a.signature-footer,
a.signature-footer {
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  flex-shrink: 0;
  text-align: center;
  margin-top: 5px;
  margin-bottom: 2px;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-decoration: none;
  font-family: var(--font-main);
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
  z-index: 10;
  display: block;
  pointer-events: auto;
}

.signature-footer:hover,
a.signature-footer:hover {
  color: var(--primary-cyan) !important;
}
