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

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-glass: rgba(22, 27, 34, 0.7);
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-heading: #ffffff;
  --accent-teal: #00d4aa;
  --accent-purple: #7c3aed;
  --error-red: #f85149;
  --success-green: #3fb950;
  --border-color: #30363d;
  --font-ui: 'Inter', sans-serif;
  --font-code: 'JetBrains Mono', monospace;
  --editor-bg: #000000;
  --editor-text: #c9d1d9;
  --code-bg: rgba(0,0,0,0.3);
}

body.light-theme {
  --bg-primary: #f6f8fa;
  --bg-secondary: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.8);
  --text-primary: #24292f;
  --text-secondary: #57606a;
  --text-heading: #000000;
  --accent-teal: #029478;
  --accent-purple: #6e40c9;
  --error-red: #cf222e;
  --success-green: #1a7f37;
  --border-color: #d0d7de;
  --editor-bg: #f6f8fa;
  --editor-text: #24292f;
  --code-bg: rgba(175, 184, 193, 0.2);
}

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

body {
  font-family: var(--font-ui);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}

/* Header & Nav */
header {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-teal), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease;
}

nav a:hover, nav a.active {
  color: var(--accent-teal);
}

#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-secondary);
  transition: color 0.3s;
}
#theme-toggle:hover { color: var(--accent-teal); }

/* Main Layout */
.container {
  display: flex;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

aside.sidebar {
  width: 250px;
  border-right: 1px solid var(--border-color);
  padding: 2rem 1rem;
  background-color: var(--bg-secondary);
  transition: background-color 0.3s;
}

aside.sidebar h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

aside.sidebar ul {
  list-style: none;
  margin-bottom: 2rem;
}

aside.sidebar li {
  margin-bottom: 0.5rem;
}

aside.sidebar a {
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

aside.sidebar a:hover, aside.sidebar a.active {
  background-color: rgba(0, 212, 170, 0.1);
  color: var(--accent-teal);
}

aside.sidebar .status {
  margin-left: auto;
  font-size: 0.8rem;
}

aside.sidebar .status.done {
  color: var(--success-green);
}

main.content {
  flex: 1;
  padding: 2rem 4rem;
  max-width: 1150px;
}

/* Typography elements */
h2 { font-size: 2rem; margin-bottom: 1rem; color: var(--text-heading); }
h3 { font-size: 1.5rem; margin-top: 1.5rem; margin-bottom: 0.75rem; color: var(--text-heading); }
p { margin-bottom: 1rem; }
ul.list { margin-left: 1.5rem; margin-bottom: 1rem; }
ul.list li { margin-bottom: 0.25rem; }

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: background-color 0.3s, border-color 0.3s;
}

.intro-card {
  background: linear-gradient(145deg, var(--bg-secondary), rgba(124, 58, 237, 0.05));
  border-left: 4px solid var(--accent-purple);
}

/* Code Editor & Interpreter */
.editor-container {
  display: flex;
  flex-direction: column;
  background: var(--editor-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  margin-top: 1rem;
}

.editor-header {
  background: var(--bg-secondary);
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

textarea.erl-editor {
  width: 100%;
  min-height: 150px;
  background: var(--editor-bg);
  color: var(--editor-text);
  font-family: var(--font-code);
  font-size: 14px;
  padding: 1rem;
  border: none;
  resize: vertical;
  outline: none;
}

.output-console {
  background: var(--editor-bg);
  color: var(--success-green);
  font-family: var(--font-code);
  font-size: 14px;
  padding: 1rem;
  min-height: 100px;
  border-top: 1px solid var(--border-color);
  white-space: pre-wrap;
}

.output-error {
  color: var(--error-red);
}

/* Buttons */
.btn {
  background: var(--accent-teal);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-size: 0.9rem;
}
body:not(.light-theme) .btn {
  color: #000;
}

.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--border-color); }
body:not(.light-theme) .btn-secondary {
    color: var(--text-primary);
}

/* Progress / Badges */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent-teal);
  width: 0%;
  transition: width 0.5s ease;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 12px;
  background: rgba(124, 58, 237, 0.2);
  color: var(--accent-purple);
  margin-right: 0.5rem;
}

/* Quiz Specific */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.quiz-option {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.quiz-option:hover {
  border-color: var(--accent-teal);
}

.quiz-option.correct {
  border-color: var(--success-green);
  background: rgba(63, 185, 80, 0.1);
}

.quiz-option.incorrect {
  border-color: var(--error-red);
  background: rgba(248, 81, 73, 0.1);
}

/* Activities layout */
.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.activity-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.activity-card p { flex: 1; }
.activity-card .btn { margin-top: auto; align-self: flex-start; }

/* Dashboard layout */
.dashboard-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.stat-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}
.stat-box .number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-teal);
}

/* Cheat Sheet Table */
table.reference {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}
table.reference th, table.reference td {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  text-align: left;
}
table.reference th {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
table.reference code {
  font-family: var(--font-code);
  color: var(--accent-teal);
  background: var(--code-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

code {
  font-family: var(--font-code);
  color: var(--accent-teal);
  background: var(--code-bg);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.9em;
}

pre {
  background: var(--editor-bg) !important;
  color: var(--editor-text) !important;
  border: 1px solid var(--border-color) !important;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
}
