@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;600;800&family=Playpen+Sans:wght@400;700&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  --bg-dark: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --border-glow: rgba(249, 115, 22, 0.15);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-orange: #f97316;
  --accent-sky: #38bdf8;
  --accent-emerald: #10b981;
  --accent-pink: #f43f5e;
  --blackboard-bg: #1e293b;
  --blackboard-border: #475569;
  --card-radius: 16px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(249, 115, 22, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(56, 189, 248, 0.05) 0px, transparent 50%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.lesson-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex-grow: 1;
}

/* Header */
.lesson-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glow);
  border-radius: var(--card-radius);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.lesson-header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(to right, var(--accent-orange), var(--accent-sky));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links {
  display: flex;
  gap: 12px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* Main Grid Layout */
.lesson-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  flex-grow: 1;
  min-height: 0;
}

/* Sidebar / Teacher Panel */
.teacher-panel {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glow);
  border-radius: var(--card-radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  height: fit-content;
}

.avatar-container {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto;
  border-radius: 50%;
  padding: 6px;
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-sky));
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.3);
  animation: float 6s ease-in-out infinite;
}

.avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #1e293b;
}

.avatar-pulse {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-orange);
  opacity: 0;
  pointer-events: none;
}

.avatar-pulse.speaking {
  animation: pulse-ring 1.5s cubic-bezier(0.215, 0.610, 0.355, 1) infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.2); opacity: 0; }
}

.teacher-info {
  text-align: center;
}

.teacher-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.teacher-title {
  font-size: 0.85rem;
  color: var(--accent-orange);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* Audio Controls */
.audio-box {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audio-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.control-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--accent-orange);
  transform: scale(1.05);
}

.audio-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.setting-row select {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  max-width: 130px;
}

/* Classroom Panel */
.classroom-pane {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Blackboard */
.blackboard {
  background: var(--blackboard-bg);
  border: 8px solid var(--blackboard-border);
  border-radius: 12px;
  box-shadow: 
    inset 0 0 40px rgba(0,0,0,0.8),
    0 10px 25px rgba(0,0,0,0.5);
  padding: 24px;
  min-height: 520px;
  height: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chalkboard-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: 40px 40px;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  pointer-events: none;
}

.slide-content {
  display: none;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  animation: chalk-in 0.5s ease-out forwards;
}

.slide-content.active {
  display: flex;
}

@keyframes chalk-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.chalk-title {
  font-family: 'Playpen Sans', cursive, sans-serif;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  margin-bottom: 6px;
  border-bottom: 2px dashed rgba(255,255,255,0.15);
  padding-bottom: 8px;
}

.chalk-text {
  font-family: 'Playpen Sans', cursive, sans-serif;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: rgba(238, 242, 246, 0.85);
  line-height: 1.5;
  margin-bottom: 6px;
}

.chalk-accent {
  color: #f97316;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(249, 115, 22, 0.3);
}

.chalk-accent-green {
  color: #10b981;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.blackboard-visual {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  position: relative;
}

.chalk-diagram-container {
  width: 100%;
  padding: 16px 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chalk-node {
  border: 3px dashed rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  padding: 12px 20px;
  font-family: 'Playpen Sans', sans-serif;
  text-align: center;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.02);
  color: #fff;
}

.chalk-arrow {
  font-family: 'Playpen Sans', sans-serif;
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.4);
}

/* Maze Grid Interface */
.maze-widget {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  width: 100%;
  min-height: 300px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  border: 2px dashed rgba(255,255,255,0.15);
  padding: 16px;
}

.maze-sidebar {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding-right: 16px;
  border-right: 1px dashed rgba(255,255,255,0.1);
}

.maze-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: 'Playpen Sans', sans-serif;
  font-size: 0.85rem;
}

.run-test-btn {
  font-family: 'Playpen Sans', sans-serif;
  background: transparent;
  border: 3px dashed var(--accent-orange);
  color: var(--accent-orange);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.run-test-btn:hover:not(:disabled) {
  background: rgba(249, 115, 22, 0.15);
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.3);
  transform: scale(1.02);
}

/* 5x5 Grid Board */
.maze-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  background: rgba(0,0,0,0.4);
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 4px;
  margin: 0 auto;
}

.maze-cell {
  background: rgba(255, 255, 255, 0.02);
  border: 1.5px dashed rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: background-color 0.15s;
  position: relative;
}

.maze-cell.start::after {
  content: 'S';
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.55rem;
  color: rgba(255,255,255,0.4);
  font-family: 'Playpen Sans', sans-serif;
}

.maze-cell.goal {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  animation: glow-battery 2s infinite alternate;
}

@keyframes glow-battery {
  0% { box-shadow: inset 0 0 4px rgba(16, 185, 129, 0.2); }
  100% { box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.5); }
}

.maze-cell.fire {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.3);
  animation: glow-fire 1.5s infinite alternate;
}

@keyframes glow-fire {
  0% { box-shadow: inset 0 0 4px rgba(244, 63, 94, 0.2); }
  100% { box-shadow: inset 0 0 10px rgba(244, 63, 94, 0.5); }
}

.maze-cell.robot {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-sky);
  box-shadow: 0 0 8px var(--accent-sky);
}

.maze-cell.crash {
  background: rgba(244, 63, 94, 0.5) !important;
  animation: flash-red 0.2s 2 alternate;
}

@keyframes flash-red {
  from { background: rgba(255, 0, 0, 0.1); }
  to { background: rgba(255, 0, 0, 0.7); }
}

.maze-cell.success {
  background: rgba(16, 185, 129, 0.5) !important;
  animation: flash-green 0.2s 2 alternate;
}

@keyframes flash-green {
  from { background: rgba(0, 255, 0, 0.1); }
  to { background: rgba(0, 255, 0, 0.7); }
}

/* Jupyter Notebook Simulation Layout */
.notebook-container {
  width: 100%;
  max-width: 800px;
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.6);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-orange) rgba(0,0,0,0.3);
}

.notebook-container::-webkit-scrollbar { width: 6px; }
.notebook-container::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
.notebook-container::-webkit-scrollbar-thumb { background: rgba(249, 115, 22, 0.4); border-radius: 3px; }

.nb-cell {
  border-left: 5px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nb-cell.nb-markdown {
  border-left-color: #3182ce;
  background: rgba(49, 130, 206, 0.05);
  font-size: 0.95rem;
  line-height: 1.5;
}

.nb-cell.nb-code {
  border-left-color: #ff9100;
  background: rgba(0, 0, 0, 0.2);
}

.nb-control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.nb-cell-type {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.nb-prompt-msg {
  color: var(--accent-sky);
  font-weight: 600;
  max-width: 65%;
}

.nb-run-btn {
  background: var(--accent-emerald);
  color: var(--bg-dark);
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nb-run-btn:hover {
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.nb-code-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  background: #0b0f19;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
  overflow-x: auto;
  text-align: left;
}

.nb-code-editor-area {
  width: 100%;
}

.nb-code-editor {
  width: 100%;
  background: #0b0f19;
  color: #c9d1d9;
  border: 1px solid rgba(255, 145, 0, 0.3);
  border-radius: 6px;
  padding: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  caret-color: #fff !important;
}

.nb-code-editor:focus {
  outline: none;
  border-color: var(--accent-orange);
  box-shadow: 0 0 8px rgba(255, 145, 0, 0.2);
}

.nb-output-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #a3b3c6;
  min-height: 40px;
  text-align: left;
  white-space: pre-wrap;
}

.tok-keyword { color: #ff7b72; font-weight: bold; }
.tok-string { color: #a5d6ff; }
.tok-comment { color: #8b949e; font-style: italic; }

/* Companion notes panel */
.notes-panel {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 0;
}

.note-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.note-header {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--accent-orange);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.note-content {
  font-family: 'Playpen Sans', sans-serif;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
}

/* Subtitle/Text Console */
.subtitle-console {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glow);
  border-radius: var(--card-radius);
  padding: 16px 24px;
  min-height: 80px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.subtitle-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  color: var(--accent-orange);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.subtitle-text {
  font-size: 1.05rem;
  color: var(--text-main);
  line-height: 1.5;
  transition: opacity 0.2s;
}

/* Navigation footer */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 16px;
}

.progress-dots {
  display: flex;
  gap: 8px;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.progress-dot.active {
  background: var(--accent-orange);
  box-shadow: 0 0 8px var(--accent-orange);
}

.nav-buttons {
  display: flex;
  gap: 16px;
}

.nav-control-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-glow);
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-control-btn:hover:not(:disabled) {
  background: var(--accent-orange);
  color: var(--bg-dark);
  border-color: var(--accent-orange);
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.3);
  transform: translateY(-1px);
}

.nav-control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Responsive Layouts */
@media (max-width: 992px) {
  .lesson-grid {
    grid-template-columns: 1fr;
  }
  .teacher-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
  }
  .avatar-container {
    margin: 0;
  }
  .teacher-info {
    text-align: left;
  }
  .audio-box {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: space-between;
  }
  .audio-settings {
    flex-direction: row;
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .lesson-container {
    padding: 12px;
    gap: 16px;
  }
  .blackboard {
    padding: 16px;
  }
  .maze-widget {
    grid-template-columns: 1fr;
    height: auto;
    padding: 12px;
  }
  .maze-sidebar {
    border-right: none;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
    padding-right: 0;
    padding-bottom: 16px;
  }
  .chalk-diagram-container {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .lesson-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  .teacher-panel {
    flex-direction: column;
    align-items: center;
  }
  .audio-box {
    flex-direction: column;
  }
  .audio-settings {
    flex-direction: column;
    width: 100%;
  }
  .setting-row select {
    max-width: 100%;
    width: 100%;
  }
}
