/* ============================================
   Belajar Rust — Dark Theme
   ============================================ */

:root {
  --bg:          #0d1117;
  --bg-sidebar:  #161b22;
  --bg-card:     #1c2128;
  --bg-editor:   #0d1117;
  --bg-output:   #161b22;
  --border:      #30363d;
  --accent:      #f97316;
  --accent-dim:  #c2590f;
  --green:       #3fb950;
  --red:         #f85149;
  --yellow:      #d29922;
  --blue:        #58a6ff;
  --purple:      #bc8cff;
  --text:        #c9d1d9;
  --text-muted:  #8b949e;
  --text-bright: #f0f6fc;
  --sidebar-w:   280px;
  --header-h:    52px;
  --output-h:    220px;
  --radius:      8px;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-ui:     -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============ HEADER ============ */
header {
  height: var(--header-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 100;
}

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

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 99px;
}

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

.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.progress-bar {
  width: 120px;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}

.btn-reset {
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-reset:hover { color: var(--red); border-color: var(--red); }

/* ============ LAYOUT ============ */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============ SIDEBAR ============ */
sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-search {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.sidebar-search input:focus { border-color: var(--accent); }
.sidebar-search input::placeholder { color: var(--text-muted); }

.sidebar-nav {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  border-radius: 6px;
  margin: 2px 6px;
}
.module-header:hover { background: var(--bg-card); }

.module-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}

.module-icon { font-size: 15px; }

.module-chevron {
  color: var(--text-muted);
  font-size: 11px;
  transition: transform 0.2s;
}
.module-header.open .module-chevron { transform: rotate(90deg); }

.module-lessons {
  display: none;
  padding: 2px 0;
}
.module-lessons.open { display: block; }

.lesson-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 36px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 6px;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.lesson-item:hover { background: var(--bg-card); color: var(--text); }
.lesson-item.active {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.lesson-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.2s;
}
.lesson-item.done .lesson-dot { background: var(--green); }
.lesson-item.active .lesson-dot { background: var(--accent); }

/* ============ MAIN CONTENT ============ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Tabs */
.content-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  height: 44px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.tab {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  border: none;
  background: none;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active {
  color: var(--accent);
  background: rgba(249, 115, 22, 0.1);
}

.content-title {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============ MATERI PANEL ============ */
.panel-materi {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  display: none;
}
.panel-materi.active { display: block; }
.panel-materi::-webkit-scrollbar { width: 6px; }
.panel-materi::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.materi-content h1 { font-size: 24px; color: var(--text-bright); margin-bottom: 8px; }
.materi-content h2 { font-size: 18px; color: var(--text-bright); margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.materi-content h3 { font-size: 15px; color: var(--accent); margin: 20px 0 8px; }
.materi-content p  { line-height: 1.7; color: var(--text); margin-bottom: 12px; font-size: 14px; }
.materi-content ul { margin: 8px 0 12px 20px; }
.materi-content li { line-height: 1.7; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.materi-content strong { color: var(--text-bright); font-weight: 600; }
.materi-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}
.materi-content pre {
  background: #1a1f2e !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 12px 0 20px;
  position: relative;
}
.materi-content pre code,
.materi-content pre code.hljs {
  background: none !important;
  border: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
}

.btn-copy-code {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--border);
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-copy-code:hover { background: var(--accent); color: white; }

.try-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 14px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.try-btn:hover { background: var(--accent); color: white; }

.concept-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
}
.concept-box.info  { border-left-color: var(--blue); }
.concept-box.warn  { border-left-color: var(--yellow); }
.concept-box.tip   { border-left-color: var(--green); }

.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 13px;
}
.compare-table th, .compare-table td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.compare-table th {
  background: var(--bg-card);
  color: var(--text-bright);
  font-weight: 600;
}
.compare-table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.compare-table td code { font-family: var(--font-mono); color: var(--accent); }

.nav-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn.disabled { opacity: 0.3; pointer-events: none; }
.nav-btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.nav-btn.primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

/* ============ EXERCISE PANEL ============ */
.panel-exercise {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.panel-exercise.active { display: flex; }

.exercise-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.exercise-desc {
  width: 300px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
}
.exercise-desc::-webkit-scrollbar { width: 4px; }
.exercise-desc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.exercise-desc h3 { font-size: 14px; color: var(--accent); margin-bottom: 12px; }
.exercise-desc p  { font-size: 13px; line-height: 1.6; color: var(--text); margin-bottom: 10px; }
.exercise-desc ul { margin-left: 16px; }
.exercise-desc li { font-size: 13px; line-height: 1.6; color: var(--text); margin-bottom: 4px; }
.exercise-desc code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-card);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

.hint-toggle {
  margin-top: 16px;
  padding: 8px 14px;
  background: rgba(188, 140, 255, 0.1);
  border: 1px solid rgba(188, 140, 255, 0.3);
  color: var(--purple);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}
.hint-toggle:hover { background: rgba(188, 140, 255, 0.2); }

.hints-box {
  display: none;
  margin-top: 12px;
  padding: 12px;
  background: rgba(188, 140, 255, 0.05);
  border: 1px solid rgba(188, 140, 255, 0.2);
  border-radius: var(--radius);
}
.hints-box.show { display: block; }
.hints-box p { font-size: 12px; color: var(--purple); margin-bottom: 6px; font-style: italic; }

.exercise-editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.editor-filename {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 10px;
  background: var(--bg);
  border-radius: 4px;
}

.editor-toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-run {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-run:hover { background: var(--accent-dim); }
.btn-run:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-run.running { background: var(--text-muted); }

.btn-reset-code {
  padding: 7px 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-reset-code:hover { border-color: var(--text-muted); color: var(--text); }

.btn-mark-done {
  padding: 7px 14px;
  background: transparent;
  color: var(--green);
  font-size: 12px;
  border: 1px solid var(--green);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-mark-done:hover { background: var(--green); color: white; }

#editor-container {
  flex: 1;
  overflow: hidden;
}

/* Output Panel */
.output-panel {
  height: var(--output-h);
  background: var(--bg-output);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.output-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.output-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.output-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  display: none;
}
.output-status.success { display: inline; background: rgba(63, 185, 80, 0.15); color: var(--green); }
.output-status.error   { display: inline; background: rgba(248, 81, 73, 0.15); color: var(--red); }

.output-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

.output-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}
.output-content::-webkit-scrollbar { width: 4px; }
.output-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.output-placeholder { color: var(--text-muted); font-style: italic; }
.output-stdout { color: var(--text); }
.output-stderr { color: var(--red); }

/* ============ LOADING ============ */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ EMPTY STATE ============ */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
}
.empty-state .big-icon { font-size: 56px; }
.empty-state h2 { font-size: 20px; color: var(--text); }
.empty-state p  { font-size: 14px; text-align: center; max-width: 360px; line-height: 1.6; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  animation: slideUp 0.3s ease;
  display: none;
}
.toast.show { display: block; }
.toast.success { background: var(--green); color: white; }
.toast.error   { background: var(--red);   color: white; }
.toast.info    { background: var(--blue);  color: white; }

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

/* ============ SCROLLBAR GLOBAL ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
