/* ─── Design Tokens (from landing page) ─────────────── */
:root {
  --deep: #050F07;
  --surface: #0A1A0E;
  --card: #0F2415;
  --accent: #4ADE80;
  --accent-dim: #22C55E;
  --accent-glow: rgba(74, 222, 128, 0.15);
  --text: #E8F5E9;
  --muted: #8BA893;
  --border: #1A3A22;
  --danger: #EF4444;
  --warning: #F59E0B;
  --font-sans: 'DM Sans', -apple-system, sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--deep);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    linear-gradient(rgba(74, 222, 128, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 222, 128, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ─── Auth Pages ─────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--accent);
  text-align: center;
  margin-bottom: 8px;
}

.auth-logo span { color: var(--text); }

.auth-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 36px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
  color: rgba(139, 168, 147, 0.5);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--deep);
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-dim);
  transform: translateY(-1px);
}

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

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.auth-switch {
  text-align: center;
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.auth-switch a:hover { text-decoration: underline; }

.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 20px;
  display: none;
}

.auth-error.visible { display: block; }

/* ─── App Layout ─────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--accent);
}

.sidebar-logo span { color: var(--text); }

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--accent-glow);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.nav-item .icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.user-email {
  font-size: 0.75rem;
  color: var(--muted);
}

.logout-btn {
  display: block;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-sans);
  padding: 0;
}

.logout-btn:hover { color: var(--danger); }

.main-content {
  flex: 1;
  margin-left: 280px;
  min-height: 100vh;
}

/* ─── Dashboard ──────────────────────────────────────── */
.dashboard {
  padding: 48px 40px;
  max-width: 900px;
}

.dash-welcome {
  margin-bottom: 40px;
}

.dash-welcome h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.dash-welcome p {
  color: var(--muted);
  font-size: 1.05rem;
}

.progress-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 32px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.progress-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

.progress-pct {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.progress-bar-container {
  background: var(--surface);
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 5px;
  transition: width 0.5s ease;
}

.progress-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.continue-section {
  margin-bottom: 40px;
}

.continue-section h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.continue-card {
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 28px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.continue-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(74, 222, 128, 0.1);
}

.continue-info h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: 4px;
}

.continue-info .module-label {
  font-size: 0.85rem;
  color: var(--accent);
}

/* ─── Lessons List ───────────────────────────────────── */
.lessons-page {
  padding: 48px 40px;
  max-width: 900px;
}

.lessons-page h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.lessons-page > p {
  color: var(--muted);
  margin-bottom: 40px;
  font-size: 1.05rem;
}

.module-section {
  margin-bottom: 36px;
}

.module-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.module-num {
  background: var(--accent-glow);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}

.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lesson-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
}

.lesson-item:hover {
  border-color: var(--accent);
  background: rgba(74, 222, 128, 0.03);
}

.lesson-status {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
}

.lesson-status.completed {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--deep);
}

.lesson-status.in-progress {
  border-color: var(--accent);
  color: var(--accent);
}

.lesson-item-info {
  flex: 1;
}

.lesson-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.lesson-item-desc {
  font-size: 0.83rem;
  color: var(--muted);
}

.lesson-item-arrow {
  color: var(--muted);
  font-size: 1.2rem;
}

/* ─── Lesson View ────────────────────────────────────── */
.lesson-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  min-height: 100vh;
}

.lesson-content-panel {
  padding: 40px;
  overflow-y: auto;
  max-height: 100vh;
}

.lesson-breadcrumb {
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 24px;
}

.lesson-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.lesson-breadcrumb a:hover { text-decoration: underline; }

/* Markdown content styling */
.lesson-body h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.lesson-body h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 16px;
  color: var(--accent);
}

.lesson-body h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 12px;
}

.lesson-body p {
  margin-bottom: 16px;
  color: var(--text);
  line-height: 1.8;
}

.lesson-body ul, .lesson-body ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.lesson-body li {
  margin-bottom: 6px;
  line-height: 1.7;
}

.lesson-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(74, 222, 128, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.lesson-body pre {
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  border: 1px solid var(--border);
}

.lesson-body pre code {
  display: block;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.6;
  border-radius: var(--radius-sm);
}

.lesson-body strong {
  color: var(--text);
  font-weight: 600;
}

.lesson-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* Exercise block */
.exercise-block {
  background: rgba(74, 222, 128, 0.04);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 40px;
}

.exercise-block h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.exercise-block ol, .exercise-block ul {
  padding-left: 20px;
  margin-bottom: 0;
}

.exercise-block li {
  margin-bottom: 8px;
  line-height: 1.7;
}

/* Lesson navigation */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  gap: 16px;
}

.lesson-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.lesson-nav-btn:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.complete-btn {
  background: var(--accent);
  color: var(--deep);
  border-color: var(--accent);
  font-weight: 600;
}

.complete-btn:hover {
  background: var(--accent-dim);
}

.complete-btn.completed {
  background: var(--card);
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── Chat Panel ─────────────────────────────────────── */
.chat-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header .mentor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--muted);
  padding: 40px;
}

.chat-empty .icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.chat-empty h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.chat-empty p {
  font-size: 0.88rem;
  line-height: 1.6;
}

.message {
  max-width: 95%;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.message.user .message-bubble {
  background: var(--accent);
  color: var(--deep);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Markdown in chat */
.message.assistant .message-bubble p {
  margin-bottom: 8px;
}

.message.assistant .message-bubble p:last-child {
  margin-bottom: 0;
}

.message.assistant .message-bubble code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(74, 222, 128, 0.1);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

.message.assistant .message-bubble pre {
  margin: 8px 0;
  border-radius: 8px;
  overflow-x: auto;
}

.message.assistant .message-bubble pre code {
  display: block;
  padding: 12px;
  background: var(--deep);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.5;
  border-radius: 8px;
}

.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message.assistant .message-bubble li {
  margin-bottom: 4px;
}

.message.assistant .message-bubble strong {
  color: var(--accent);
}

.message-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message.user .message-label {
  text-align: right;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-items: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
}

.chat-input:focus {
  border-color: var(--accent);
}

.chat-input::placeholder {
  color: rgba(139, 168, 147, 0.5);
}

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--deep);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send:hover {
  background: var(--accent-dim);
  transform: scale(1.05);
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ─── Mobile Responsive ──────────────────────────────── */
.mobile-header {
  display: none;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.mobile-header .logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
}

.mobile-header .logo span { color: var(--text); }

.menu-toggle {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9;
}

@media (max-width: 1024px) {
  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 280px;
    height: 50vh;
    border-top: 1px solid var(--border);
    border-left: none;
    z-index: 5;
    display: none;
  }

  .chat-panel.visible {
    display: flex;
  }

  .lesson-content-panel {
    max-height: none;
    padding-bottom: 80px;
  }

  .chat-toggle-btn {
    display: flex !important;
  }
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .dashboard, .lessons-page {
    padding: 24px 20px;
  }

  .lesson-content-panel {
    padding: 24px 20px;
  }

  .chat-panel {
    left: 0;
  }

  .auth-card {
    padding: 32px 24px;
  }
}

/* ─── Chat Toggle (mobile/tablet) ────────────────────── */
.chat-toggle-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--deep);
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  box-shadow: 0 4px 20px rgba(74, 222, 128, 0.4);
  z-index: 15;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-toggle-btn:hover {
  transform: scale(1.1);
}

/* ─── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ─── Loading States ─────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
