/* ==========================================================================
   PakARQ CodeQuest - Code Studio & Editor Styling
   Consistent with PakARQ Website Aesthetics (Rafenthic Purple Theme)
   ========================================================================== */

.ide-wrapper {
  display: grid;
  grid-template-columns: 430px 1fr;
  height: calc(100vh - 68px);
  overflow: hidden;
  background: var(--bg-main);
}

/* Left Pane: Mission Briefing */
.mission-sidebar {
  background: #ffffff;
  border-right: 1.5px solid var(--purple-100);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.mission-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1.5px solid var(--purple-100);
  background: var(--purple-50);
}

.mission-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--purple-600);
  margin-bottom: 0.5rem;
  font-weight: 800;
}

.mission-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
  font-family: var(--font-heading);
}

.mission-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
  font-size: 0.82rem;
}

.difficulty-badge {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.75rem;
}
.difficulty-badge.easy { background: rgba(16, 185, 129, 0.12); color: #059669; border: 1px solid rgba(16, 185, 129, 0.3); }
.difficulty-badge.medium { background: rgba(245, 158, 11, 0.12); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.3); }
.difficulty-badge.hard { background: rgba(244, 63, 94, 0.12); color: #e11d48; border: 1px solid rgba(244, 63, 94, 0.3); }

.xp-badge {
  background: var(--purple-100);
  color: var(--purple-700);
  border: 1px solid var(--purple-200);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-weight: 700;
}

.mission-body {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: #ffffff;
}

.mission-section-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mission-task-card {
  background: var(--purple-50);
  border: 1.5px solid var(--purple-200);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.6;
  box-shadow: 0 4px 15px rgba(42, 10, 94, 0.03);
}

.mission-task-card code {
  background: #ffffff;
  color: var(--purple-700);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  border: 1px solid var(--purple-200);
  font-weight: 700;
}

.mission-instructions {
  font-size: 0.92rem;
  color: var(--ink-2);
  line-height: 1.65;
}
.mission-instructions p {
  margin-bottom: 0.75rem;
}

/* Mode Switcher Tabs */
.mode-switch-bar {
  display: flex;
  background: var(--purple-100);
  padding: 4px;
  border-radius: 999px;
  margin: 1rem 1.5rem 0;
  border: 1px solid var(--purple-200);
}

.mode-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.25s ease;
}

.mode-tab-btn:hover {
  color: var(--purple-700);
}

.mode-tab-btn.active.learn {
  background: #ffffff;
  color: var(--purple-700);
  box-shadow: 0 4px 12px rgba(106, 28, 255, 0.15);
}

.mode-tab-btn.active.test {
  background: var(--grad-purple);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(124, 28, 255, 0.35);
}

/* Novice Visual Anatomy Guide Box */
.beginner-anatomy-box {
  background: linear-gradient(135deg, var(--purple-50) 0%, #ffffff 100%);
  border: 1.5px solid var(--purple-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px rgba(106, 28, 255, 0.05);
}

.anatomy-header {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--purple-800);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
}

.anatomy-code-diagram {
  background: #12071b;
  border-radius: 12px;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.5px;
}
.tok-echo { color: #c084fc; }
.tok-str { color: #34d399; }
.tok-semi { color: #fb7185; }

.anatomy-step-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.anatomy-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--ink-2);
}

.step-num-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--purple-100);
  color: var(--purple-700);
  font-weight: 800;
  font-size: 0.72rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1px solid var(--purple-200);
}

.btn-paste-code {
  background: #ffffff;
  border: 1.5px solid var(--purple-300);
  color: var(--purple-700);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(106, 28, 255, 0.08);
}
.btn-paste-code:hover {
  background: var(--purple-50);
  border-color: var(--purple-500);
  transform: translateY(-1px);
}

/* Practice Drills Card (Paste Blocked) */
.drill-tracker-card {
  background: var(--purple-50);
  border: 1.5px solid var(--purple-200);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 6px 20px rgba(106, 28, 255, 0.05);
}

.drill-steps-bar {
  display: flex;
  gap: 8px;
  margin-top: 0.75rem;
}

.drill-step-pill {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  border: 1.5px solid var(--purple-200);
  transition: all 0.2s;
}

.drill-step-pill.active {
  background: var(--purple-100);
  color: var(--purple-700);
  border-color: var(--purple-500);
  box-shadow: 0 0 12px rgba(124, 28, 255, 0.25);
  font-weight: 800;
}

.drill-step-pill.done {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  border-color: #10b981;
  font-weight: 800;
}

/* Anti-Paste Alert Banner */
.anti-paste-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #e11d48 0%, #7c1cff 100%);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  z-index: 500;
  box-shadow: 0 10px 30px rgba(225, 29, 72, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDownFade 0.3s ease-out;
  pointer-events: none;
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes pasteShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.paste-blocked-shake {
  animation: pasteShake 0.4s ease-in-out;
  outline: 2px solid #f43f5e !important;
}

/* Right Pane: Code Editor Workspace (Rafenthic Purple Theme) */
.editor-workspace {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #120727;
  overflow: hidden;
  position: relative;
}

/* Editor Toolbar */
.editor-toolbar {
  background: var(--purple-50);
  border-bottom: 1.5px solid var(--purple-200);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e0b3d;
  border: 1.5px solid var(--purple-400);
  border-bottom: none;
  padding: 6px 16px;
  border-radius: 10px 10px 0 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 -2px 10px rgba(124, 28, 255, 0.15);
}

.btn-ide-theme {
  background: #ffffff;
  border: 1px solid var(--purple-200);
  color: var(--purple-700);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}
.btn-ide-theme:hover {
  background: var(--purple-100);
  border-color: var(--purple-400);
}

.btn-run {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
  padding: 8px 18px;
  font-size: 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  transition: all 0.2s;
}
.btn-run:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-check {
  background: var(--grad-purple);
  color: #ffffff;
  padding: 8px 20px;
  font-size: 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 18px rgba(124, 28, 255, 0.45);
  transition: all 0.2s;
}
.btn-check:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(124, 28, 255, 0.6);
}

/* Code Editor Box */
.editor-container {
  flex: 1;
  display: flex;
  position: relative;
  background: #120727;
  overflow: hidden;
}

.line-numbers {
  width: 48px;
  padding: 16px 8px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: #a78bfa;
  text-align: right;
  user-select: none;
  background: #1a0a38;
  border-right: 1px solid rgba(124, 28, 255, 0.25);
  line-height: 1.6;
}

.code-textarea {
  flex: 1;
  padding: 16px 20px;
  background: #120727;
  color: #f8f7fc;
  font-family: var(--font-mono);
  font-size: 0.98rem;
  line-height: 1.6;
  border: none;
  outline: none;
  resize: none;
  white-space: pre;
  tab-size: 4;
  caret-color: #c084fc;
}

/* Bottom Console Panel */
.console-panel {
  height: 220px;
  background: #0c031a;
  border-top: 1.5px solid rgba(124, 28, 255, 0.25);
  display: flex;
  flex-direction: column;
}

.console-header {
  padding: 8px 18px;
  background: #1a0938;
  border-bottom: 1px solid rgba(124, 28, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #c9a8ff;
}

.console-content {
  flex: 1;
  padding: 14px 20px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: #e6d8ff;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.55;
}

/* LIGHT THEME IDE MODE (Optional Toggle) */
.editor-workspace.theme-light {
  background: #ffffff;
}
.editor-workspace.theme-light .editor-container {
  background: #ffffff;
}
.editor-workspace.theme-light .line-numbers {
  background: var(--purple-50);
  border-right-color: var(--purple-200);
  color: var(--purple-600);
}
.editor-workspace.theme-light .code-textarea {
  background: #ffffff;
  color: var(--ink);
  caret-color: var(--purple-600);
}
.editor-workspace.theme-light .file-tab {
  background: #ffffff;
  color: var(--purple-700);
  border-color: var(--purple-300);
}
.editor-workspace.theme-light .console-panel {
  background: var(--purple-50);
  border-top-color: var(--purple-200);
}
.editor-workspace.theme-light .console-header {
  background: var(--purple-100);
  border-bottom-color: var(--purple-200);
  color: var(--purple-800);
}
.editor-workspace.theme-light .console-content {
  color: var(--ink);
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE WORKSPACE (Under 900px)
   ========================================================================== */
.mobile-studio-switch {
  display: none;
}
.mob-task-btn {
  display: none;
}
.mob-only-cta {
  display: none;
}

@media (max-width: 900px) {
  /* Navbar on Mobile */
  .cq-navbar {
    padding: 8px 12px !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }
  .cq-navbar select {
    max-width: 170px !important;
    font-size: 0.78rem !important;
    padding: 5px 10px !important;
  }
  .guest-save-banner {
    padding: 8px 12px !important;
    font-size: 0.78rem !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }

  /* Show Mobile Studio Switcher Tabs */
  .mobile-studio-switch {
    display: flex;
    background: #ffffff;
    border-bottom: 2px solid var(--purple-200);
    padding: 8px 12px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: 0 4px 15px rgba(42, 10, 94, 0.05);
  }

  .mob-switch-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 800;
    border: 1.5px solid var(--purple-200);
    background: var(--purple-50);
    color: var(--ink-2);
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mob-switch-btn.active {
    background: var(--purple-600);
    color: #ffffff;
    border-color: var(--purple-600);
    box-shadow: 0 4px 12px rgba(106, 28, 255, 0.25);
  }

  .mob-badge-type {
    background: #10b981;
    color: #ffffff;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
  }

  .mob-task-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1.5px solid var(--purple-300);
    background: var(--purple-100);
    color: var(--purple-800);
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
  }

  .mob-only-cta {
    display: block !important;
  }

  /* IDE Studio Layout on Mobile: Fullscreen Toggled Columns */
  .ide-wrapper {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 120px) !important;
    overflow: hidden !important;
    position: relative !important;
  }

  /* When Briefing (Instructions) Tab is Active */
  .ide-wrapper.show-briefing .mission-sidebar {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    overflow-y: auto !important;
  }
  .ide-wrapper.show-briefing .editor-workspace {
    display: none !important;
  }

  /* When Code Editor Tab is Active */
  .ide-wrapper.show-editor .mission-sidebar {
    display: none !important;
  }
  .ide-wrapper.show-editor .editor-workspace {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  /* Editor Toolbar on Mobile */
  .editor-toolbar {
    padding: 8px 12px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .toolbar-left, .toolbar-right {
    gap: 6px !important;
  }
  .toolbar-right {
    width: 100% !important;
    justify-content: space-between !important;
  }
  .toolbar-right .btn-run,
  .toolbar-right .btn-check {
    flex: 1 !important;
    padding: 10px 14px !important;
    font-size: 0.88rem !important;
    justify-content: center !important;
  }

  /* Code Textarea on Mobile - ensure comfortable font and easy tapping */
  .code-textarea {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom */
    padding: 12px 14px !important;
    line-height: 1.5 !important;
  }
  .line-numbers {
    width: 36px !important;
    padding: 12px 4px !important;
    font-size: 14px !important;
  }

  /* Console Panel on Mobile */
  .console-panel {
    height: 170px !important;
    min-height: 140px !important;
  }
}
