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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f4f8;
  color: #2d3748;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
}

/* View container */
.view {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}

/* Wider views for level select, problems and editor */
#view-level-select,
#view-problems,
#view-editor,
#view-tutorial-topics,
#view-tutorial {
  max-width: 1100px;
}
.hidden { display: none !important; }

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

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
}

/* Buttons */
.btn-primary, .btn-secondary {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1rem;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary { background: #4299e1; color: white; }
.btn-primary:hover:not(:disabled) { background: #3182ce; transform: translateY(-1px); }
.btn-primary:disabled { background: #a0aec0; cursor: not-allowed; }
.btn-secondary { background: #edf2f7; color: #4a5568; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger {
  background: none;
  border: none;
  color: #a0aec0;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0;
  margin-top: 0;
  font-weight: 500;
}
.btn-danger:hover { color: #e53e3e; }

/* Site header */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}
.site-header h1 { font-size: 2.5rem; color: #2b6cb0; margin-bottom: 0.25rem; }
.subtitle { font-size: 1rem; color: #718096; margin-bottom: 1rem; }
.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.feedback-link { font-size: 0.8rem; color: #718096; text-decoration: none; }
.feedback-link:hover { color: #2b6cb0; text-decoration: underline; }

/* Level select cards */
.level-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}
.level-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 2px solid transparent;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
}
.level-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-2px); }
.level-card.beginner { border-color: #9ae6b4; }
.level-card.intermediate { border-color: #90cdf4; }
.level-card.advanced { border-color: #d6bcfa; }
.level-card-left h3 { font-size: 1.3rem; margin-bottom: 0.25rem; }
.level-card-left p { color: #718096; font-size: 0.9rem; }
.level-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.level-card-count { font-size: 0.85rem; color: #a0aec0; }

/* Problems list */
#view-problems h2 { margin-bottom: 0.25rem; margin-top: 1rem; }
.suggested-tag {
  font-size: 0.7rem;
  background: #fefcbf;
  color: #744210;
  border-radius: 99px;
  padding: 0.15rem 0.6rem;
  font-weight: 600;
}
.problems-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.problem-item {
  background: white;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  border: 2px solid transparent;
}
.problem-item:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.1); transform: translateY(-1px); }
.problem-item.solved { border-color: #68d391; }
.problem-title { font-weight: 600; }
.problem-num { color: #a0aec0; font-weight: 500; margin-right: 0.35rem; }
.problem-status { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.problem-status.solved { color: #276749; }
.problem-status.unsolved { color: #a0aec0; }
.problem-status.in-progress { color: #d69e2e; }

/* Editor */
.editor-card { }
#editor-title { font-size: 1.3rem; margin-bottom: 0.75rem; }
.editor-description { color: #4a5568; margin-bottom: 0.5rem; line-height: 1.6; }
.editor-hint { color: #d69e2e; font-style: italic; margin-bottom: 0.5rem; font-size: 0.9rem; }
.code-editor-cm { margin: 0.75rem 0; border-radius: 8px; overflow: hidden; border: 2px solid #e2e8f0; }
.code-editor-cm:focus-within { border-color: #4299e1; }
.code-editor-cm .CodeMirror {
  height: auto;
  min-height: 320px;
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}
.code-editor-cm .CodeMirror-scroll { min-height: 320px; }
.code-editor-cm .cm-error { background: none !important; color: inherit !important; }
.output-panel { margin-top: 1rem; }
.output-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: #718096; margin-bottom: 0.25rem; }
#output-text {
  background: #2d3748;
  color: #e2e8f0;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 2rem;
}
.feedback-banner {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
}
.feedback-banner.correct { background: #c6f6d5; color: #276749; animation: banner-bounce 0.45s cubic-bezier(0.36,0.07,0.19,0.97); }
.feedback-banner.incorrect { background: #fed7d7; color: #9b2c2c; }

@keyframes banner-bounce {
  0%   { transform: scale(0.7); opacity: 0; }
  55%  { transform: scale(1.08); opacity: 1; }
  75%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* ── Emoji pop celebration ───────────────────────────────────────────────── */
.emoji-container { pointer-events: none; position: fixed; inset: 0; overflow: hidden; z-index: 9999; }
.emoji-pop {
  position: absolute;
  animation: emoji-float ease-out forwards;
}
@keyframes emoji-float {
  0%   { opacity: 0; transform: translateY(0) scale(0); }
  15%  { opacity: 1; transform: translateY(-12px) scale(1.3); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-150px) scale(0.8); }
}

/* ── Tutorial level card ─────────────────────────────────────────────────── */
.level-card.tutorial { border-color: #fbd38d; }

/* ── Tutorial topic navigation dots ─────────────────────────────────────── */
.tutorial-topic-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}
.topic-nav-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  background: white;
  font-size: 0.75rem;
  font-weight: 600;
  color: #718096;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
}
.topic-nav-dot:hover { background: #edf2f7; border-color: #cbd5e0; }
.topic-nav-dot.active { background: #4299e1; border-color: #4299e1; color: white; }
.topic-nav-dot.done { background: #c6f6d5; border-color: #68d391; color: #276749; }
.topic-nav-dot.active.done { background: #48bb78; border-color: #48bb78; color: white; }

/* ── Tutorial learn card ─────────────────────────────────────────────────── */
.tutorial-learn-card { background: #fffdf7; border-left: 4px solid #fbd38d; }
.tutorial-learn-card h3 { font-size: 1.3rem; margin-bottom: 1rem; }
.learn-block { margin-bottom: 1.25rem; }
.learn-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #d69e2e;
  margin-bottom: 0.35rem;
}
.learn-text {
  color: #4a5568;
  line-height: 1.7;
  white-space: pre-line;
}
.code-example {
  background: #1a202c;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre;
  overflow-x: auto;
}

/* ── Tutorial practice section ───────────────────────────────────────────── */
.tutorial-question-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a0aec0;
  margin-bottom: 0.5rem;
}
#tutorial-output-text {
  background: #2d3748;
  color: #e2e8f0;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 2rem;
}

/* ── Interview wide views ────────────────────────────────────────────────── */
#view-interview-topics,
#view-interview-topic {
  max-width: 1100px;
}

/* ── Interview level card ────────────────────────────────────────────────── */
.level-card.interview { border-color: #90cdf4; }

/* ── Interview topic nav dots ────────────────────────────────────────────── */
.interview-topic-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

/* ── Interview learn card ────────────────────────────────────────────────── */
.interview-learn-card { background: #f7faff; border-left: 4px solid #4299e1; }
.interview-learn-card h3 { font-size: 1.3rem; margin-bottom: 1rem; }

/* ── Operations table ────────────────────────────────────────────────────── */
.ops-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.ops-table td { padding: 0.3rem 0.5rem; border-bottom: 1px solid #e2e8f0; }
.ops-table td:first-child { color: #2d3748; font-family: "Fira Code", "Courier New", monospace; }
.ops-table td:last-child { color: #4299e1; font-weight: 600; text-align: right; }
.op-tooltip { position: relative; border-bottom: 1px dotted #a0aec0; cursor: help; }
.op-tip-box {
  display: none;
  position: absolute;
  left: 0; top: 100%;
  z-index: 10;
  background: #2d3748;
  color: #fff;
  font-size: 0.78rem;
  font-family: sans-serif;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}
.op-tooltip:hover .op-tip-box { display: block; }

/* ── Python tools inline list ────────────────────────────────────────────── */
.interview-tools-text {
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 0.88rem;
  color: #553c9a;
  white-space: pre-line;
}

/* ── Problem tabs ────────────────────────────────────────────────────────── */
.interview-problem-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.problem-tab {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  border: 2px solid #e2e8f0;
  background: white;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: #4a5568;
  transition: border-color 0.15s, background 0.15s;
}
.problem-tab:hover { border-color: #4299e1; }
.problem-tab.active { border-color: #4299e1; background: #ebf8ff; color: #2b6cb0; }
.problem-tab.solved { border-color: #68d391; background: #f0fff4; color: #276749; }
.problem-tab.active.solved { border-color: #48bb78; background: #c6f6d5; }
.diff-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.diff-badge.easy   { background: #c6f6d5; color: #276749; }
.diff-badge.medium { background: #feebc8; color: #7b341e; }

/* ── Problem header (title + leetcode link) ──────────────────────────────── */
.interview-problem-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.interview-problem-header h4 { font-size: 1.1rem; margin: 0; }
.leetcode-link {
  font-size: 0.8rem;
  color: #4299e1;
  text-decoration: none;
  font-weight: 600;
}
.leetcode-link:hover { text-decoration: underline; }

/* ── Problem example block ───────────────────────────────────────────────── */
.problem-example {
  background: #edf2f7;
  color: #2d3748;
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 0.88rem;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  border-left: 3px solid #4299e1;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
  margin-bottom: 0.5rem;
}

/* ── Test results panel ──────────────────────────────────────────────────── */
.interview-test-results {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.test-result-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.88rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-family: "Fira Code", "Courier New", monospace;
}
.test-result-row.pass { background: #f0fff4; color: #276749; }
.test-result-row.fail { background: #fff5f5; color: #9b2c2c; }
.test-icon { font-weight: 700; flex-shrink: 0; }
.traceback-block {
  margin-top: 0.4rem;
  background: #2d3748;
  color: #feb2b2;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  width: 100%;
}
