/* ==============================================================
   Neural Network Visualizer — Flat / Academic / White Background
   Matching lecture slide style: blue nodes, gray connections,
   clean sans-serif, minimal decoration
   ============================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

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

:root {
  /* Flat academic palette */
  --white: #ffffff;
  --bg: #f7f8fa;
  --bg-panel: #ffffff;
  --bg-card: #f0f2f5;
  --bg-code: #f5f6f8;
  --border: #e0e3e8;
  --border-light: #ebedf0;

  --text: #2c3e50;
  --text-light: #7f8c9a;
  --text-muted: #a0aab4;

  /* Node colors (flat, lecture-style) */
  --blue: #4a90d9;        /* primary blue for input nodes */
  --blue-light: #d4e4f7;
  --green: #5cb85c;       /* hidden layer */
  --green-light: #d4edda;
  --red: #e74c3c;         /* output layer */
  --red-light: #f8d7da;
  --orange: #f0ad4e;      /* RNN / accent */
  --orange-light: #ffeeba;
  --purple: #8e6bb0;
  --purple-light: #e8ddf0;

  /* Flat — no glow, no shadow */
  --shadow: none;
}

body {
  font-family: 'Inter', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
}

/* ==================== HEADER ==================== */
.header {
  text-align: center;
  padding: 10px 20px;
  background: var(--white);
  border-bottom: 2px solid var(--blue);
}
.header h1 {
  font-size: 1.2em;
  font-weight: 700;
  color: var(--blue);
}
.header p {
  font-size: .75em;
  color: var(--text-light);
  margin-top: 2px;
}

/* ==================== LAYOUT ==================== */
.main-container {
  display: flex;
  height: calc(100vh - 56px);
}

/* ==================== LEFT PANEL ==================== */
.left-panel {
  width: 270px;
  min-width: 250px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}
.panel-section {
  margin-bottom: 14px;
}
.panel-section h3 {
  color: var(--blue);
  font-size: .75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

/* ==================== CONTROLS ==================== */
select, input[type=number] {
  width: 100%;
  padding: 6px 8px;
  margin-bottom: 5px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  border-radius: 4px;
  font-size: .8em;
  font-family: inherit;
  outline: none;
}
select:focus, input:focus { border-color: var(--blue); }

button {
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 4px;
  font-size: .78em;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  outline: none;
}
button:hover { background: var(--border-light); }
button:active { background: var(--border); }

button.primary {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}
button.primary:hover { background: #3a7bc8; }

button.success {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}

button.danger {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
button.danger:hover { background: #d43c2c; }

button.gold {
  background: var(--orange);
  color: var(--white);
  border-color: var(--orange);
}
button.gold:hover { background: #e09d3e; }

.speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.speed-control label { font-size: .75em; color: var(--text-light); white-space: nowrap; }
.speed-control input[type=range] {
  flex: 1;
  accent-color: var(--blue);
}
.speed-label { font-size: .75em; color: var(--blue); font-weight: 600; min-width: 22px; }

/* ==================== IMAGE GRID ==================== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.image-thumb {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color .15s;
  image-rendering: pixelated;
  background: #fff;
}
.image-thumb:hover { border-color: var(--blue); }
.image-thumb.selected {
  border-color: var(--blue);
  outline: 2px solid var(--blue-light);
}

/* ==================== CENTER ==================== */
.center-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--white);
}
#networkCanvas { width: 100%; height: 100%; display: block; }

/* ==================== RIGHT PANEL ==================== */
.right-panel {
  width: 340px;
  min-width: 300px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==================== NARRATION BOX ==================== */
.narration-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: 4px;
  padding: 14px;
}
.narration-box h4 {
  font-size: .75em;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}
.narration-text {
  font-size: .84em;
  line-height: 1.7;
  color: var(--text);
}
.narration-text .step-num {
  display: inline-block;
  background: var(--blue);
  color: white;
  font-weight: 700;
  width: 22px; height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  margin-right: 6px;
  font-size: .75em;
}
.narration-text .highlight {
  color: var(--blue);
  font-weight: 600;
}
.narration-text .formula-inline {
  font-family: 'JetBrains Mono', monospace;
  color: var(--purple);
  background: var(--bg-code);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: .88em;
  border: 1px solid var(--border-light);
}
.narration-text .bam {
  display: inline-block;
  color: var(--red);
  font-weight: 700;
  font-size: 1.05em;
}

/* ==================== INFO BOX ==================== */
.info-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
}
.info-box h4 {
  color: var(--blue);
  margin-bottom: 6px;
  font-size: .75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.info-box .formula {
  background: var(--bg-code);
  padding: 10px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .78em;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border-light);
}
.info-box .value { color: var(--red); font-weight: 600; }
.info-box .label-blue { color: var(--blue); font-weight: 600; }
.info-box .label-red { color: var(--red); font-weight: 600; }

/* Math notation:
   vector  = bold upright lowercase    → <b>x</b>
   scalar  = non-bold italic lowercase → <i>z</i>
   matrix  = bold upright UPPERCASE    → <b>W</b>
*/

/* ==================== MATRIX DISPLAY ==================== */
.matrix-display {
  background: var(--bg-code);
  border-radius: 4px;
  padding: 6px;
  overflow: auto;
  max-height: 250px;
  margin-top: 6px;
  border: 1px solid var(--border-light);
}
.matrix-display table {
  border-collapse: collapse;
  font-size: .65em;
  font-family: 'JetBrains Mono', monospace;
}
.matrix-display td {
  padding: 2px 5px;
  text-align: right;
  color: var(--text);
  border: 1px solid var(--border-light);
  min-width: 30px;
}

/* ==================== ANIMATION BUBBLES ==================== */
.anim-value-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

/* ==================== STATUS BAR ==================== */
.status-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 28px;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: .7em;
  color: var(--text-light);
  z-index: 100;
}
.status-bar .si { margin-right: 18px; }
.status-bar .si span { color: var(--blue); font-weight: 600; }

/* ==================== PROGRESS BAR ==================== */
.progress-bar {
  height: 3px;
  background: var(--border-light);
  position: absolute;
  bottom: 28px;
  left: 0; right: 0;
}
.progress-bar .fill {
  height: 100%;
  background: var(--blue);
  transition: width .25s ease;
  width: 0%;
}

/* ==================== LEGEND ==================== */
.legend { display: flex; flex-wrap: wrap; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: .72em; color: var(--text-light); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--border); }

/* ==================== MATRIX MODAL ==================== */
.matrix-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.3);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}
.matrix-modal.active { display: flex; }
.matrix-modal-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  max-width: 700px;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.matrix-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.matrix-modal-header h3 { color: var(--blue); font-size: 1em; }
.matrix-modal-image {
  text-align: center;
  margin-bottom: 15px;
}
.matrix-modal-image canvas {
  image-rendering: pixelated;
  border: 2px solid var(--border);
  border-radius: 4px;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ==================== RESPONSIVE ==================== */
@media(max-width:1200px) {
  .main-container { flex-direction: column; height: auto; }
  .left-panel, .right-panel { width: 100%; min-width: auto; max-height: 280px; }
  .center-panel { height: 450px; }
}
