/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-sidebar: #161822;
  --bg-card: #1c1e2e;
  --bg-input: #13141f;
  --border: #2a2d3d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-glow: rgba(88, 166, 255, 0.15);
  --green: #3fb950;
  --green-bg: rgba(63, 185, 80, 0.12);
  --orange: #d2991d;
  --orange-bg: rgba(210, 153, 29, 0.12);
  --red: #f85149;
  --purple: #a371f7;
  --phase-colors: #58a6ff, #3fb950, #d2991d, #f85149, #a371f7, #79c0ff, #56d364;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

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

#app { display: flex; height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#sidebar-header h1 {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}

#overall-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.progress-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

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

#overall-text {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 38px;
  text-align: right;
}

#btn-reset {
  margin-top: 14px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  background: var(--orange-bg);
  border: 1px solid rgba(210, 153, 29, 0.3);
  color: var(--orange);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
#btn-reset:hover {
  background: rgba(210, 153, 29, 0.22);
  border-color: var(--orange);
  box-shadow: 0 0 12px rgba(210, 153, 29, 0.2);
}

/* ── Timeline Nav ─────────────────────────────────────────────── */
#timeline {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

#timeline::-webkit-scrollbar { width: 4px; }
#timeline::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.phase-group {
  margin-bottom: 4px;
}

.phase-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  cursor: default;
  user-select: none;
}

.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.phase-badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-dim);
}

/* Timeline items */
.timeline-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px 9px 28px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  font-size: 14px;
  border-left: 2px solid transparent;
}

.timeline-item:hover { background: rgba(255,255,255,0.03); }
.timeline-item.active {
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.timeline-item.locked {
  opacity: 0.35;
  cursor: not-allowed;
}
.timeline-item.locked:hover { background: transparent; }

.timeline-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.timeline-item.completed .timeline-icon {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.timeline-item.current .timeline-icon {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.timeline-item.locked .timeline-icon {
  border-color: var(--border);
  background: transparent;
}

.timeline-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}

.timeline-title {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 4px;
}

/* ── Main Content ─────────────────────────────────────────────── */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

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

.panel { max-width: 800px; }

/* ── Welcome ─────────────────────────────────────────────────── */
.welcome-icon { font-size: 56px; margin-bottom: 16px; }

#welcome h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

#welcome p {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.7;
}

.welcome-stats {
  display: flex;
  gap: 32px;
  margin-top: 32px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 28px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.stat-num {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-label { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* ── Detail Panel ─────────────────────────────────────────────── */
#command-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

#cmd-title {
  font-size: 24px;
  font-weight: 700;
}

#cmd-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

#cmd-status.completed { background: var(--green-bg); color: var(--green); }
#cmd-status.incomplete { background: var(--orange-bg); color: var(--orange); }

/* Sections */
.cmd-section {
  margin-bottom: 24px;
}

.cmd-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

#cmd-description {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

/* Options table */
#cmd-options {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

#cmd-options th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

#cmd-options td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

#cmd-options td:first-child {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
}

/* Task card */
.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.task-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent);
}

.task-detail {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  background: transparent;
  border: none;
  padding: 0;
}

/* Terminal */
#terminal {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#terminal-output {
  min-height: 60px;
  max-height: 280px;
  overflow-y: auto;
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

#terminal-output:empty::before {
  content: 'Command output will appear here...';
  color: var(--text-dim);
}

#terminal-output .error { color: var(--red); }
#terminal-output .success { color: var(--green); }

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}

.prompt {
  color: var(--green);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  padding: 4px 0;
}

#terminal-input::placeholder { color: var(--text-dim); }

#btn-run {
  padding: 5px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}
#btn-run:hover { background: #4090e0; }

.btn-secondary {
  padding: 5px 12px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Verify section */
#btn-verify {
  padding: 10px 28px;
  background: var(--green);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
#btn-verify:hover { filter: brightness(1.1); }
#btn-verify:disabled { opacity: 0.4; cursor: not-allowed; }

#verify-result {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  display: none;
}

#verify-result.show { display: block; }
#verify-result.success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(63,185,80,0.3); }
#verify-result.fail { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(210,153,29,0.3); }

/* Locked overlay for detail panel */
.locked-overlay {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.locked-overlay .lock-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.locked-overlay p { font-size: 15px; line-height: 1.6; }

/* ── Congratulations Modal ─────────────────────────────────────── */
#congrats-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

#congrats-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#congrats-modal {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 60px rgba(88, 166, 255, 0.1);
}

#congrats-icon {
  font-size: 72px;
  margin-bottom: 16px;
  animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

#congrats-title {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--purple), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

#congrats-subtitle {
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 24px;
}

#congrats-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
}

.congrats-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-width: 90px;
}

.congrats-num {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.congrats-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

#congrats-message {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 28px;
}

#congrats-close {
  padding: 12px 32px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#congrats-close:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(88, 166, 255, 0.3);
}
