/* ═══════════════════════════════════════
   CuroAI — CodeMirror 5 Dark Theme
   Matches existing #1a1a2e / #0d0d1a palette
   ═══════════════════════════════════════ */

.editor-container .CodeMirror {
  height: 100%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.55;
  background: #0d0d1a;
  color: #e0e0e0;
  border: none;
}
.CodeMirror-gutters {
  background: #12122a;
  border-right: 1px solid #252550;
}
.CodeMirror-linenumber {
  color: #555580;
  font-size: 11px;
  padding: 0 6px 0 4px;
}
.CodeMirror-activeline-background { background: rgba(255,255,255,0.03) !important; }
.CodeMirror-cursor { border-left: 2px solid #4fc3f7 !important; }
.CodeMirror-selected { background: rgba(79,195,247,0.18) !important; }
.CodeMirror-focused .CodeMirror-selected { background: rgba(79,195,247,0.25) !important; }
.CodeMirror-matchingbracket {
  color: #81c784 !important;
  background: rgba(129,199,132,0.15);
  border-bottom: 1px solid #81c784;
}
.CodeMirror-nonmatchingbracket {
  color: #f06292 !important;
  background: rgba(240,98,146,0.15);
}

/* Scrollbar */
.CodeMirror-vscrollbar::-webkit-scrollbar,
.CodeMirror-hscrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.CodeMirror-vscrollbar::-webkit-scrollbar-thumb,
.CodeMirror-hscrollbar::-webkit-scrollbar-thumb { background: #333366; border-radius: 3px; }
.CodeMirror-vscrollbar::-webkit-scrollbar-track,
.CodeMirror-hscrollbar::-webkit-scrollbar-track { background: transparent; }

/* ═══ Python Syntax ═══ */
.cm-s-curo .cm-keyword { color: #c792ea; font-weight: 500; }
.cm-s-curo .cm-def { color: #82aaff; }
.cm-s-curo .cm-builtin { color: #ffcb6b; }
.cm-s-curo .cm-string { color: #c3e88d; }
.cm-s-curo .cm-string-2 { color: #89ddff; }
.cm-s-curo .cm-number { color: #f78c6c; }
.cm-s-curo .cm-comment { color: #546e7a; font-style: italic; }
.cm-s-curo .cm-operator { color: #89ddff; }
.cm-s-curo .cm-variable { color: #e0e0e0; }
.cm-s-curo .cm-variable-2 { color: #eeffff; }
.cm-s-curo .cm-property { color: #4fc3f7; }
.cm-s-curo .cm-meta { color: #ffcb6b; }
.cm-s-curo .cm-error { color: #ff5370; }

/* ═══ Lint Markers ═══ */
.lint-gutter { width: 14px; }
.lint-error-icon {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 50%; background: #f06292; color: #fff;
  font-size: 9px; line-height: 12px; text-align: center;
  cursor: pointer; font-weight: bold;
  box-shadow: 0 0 4px rgba(240,98,146,0.5);
}
.lint-warn-icon {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 50%; background: #ffb74d; color: #1a1a2e;
  font-size: 9px; line-height: 12px; text-align: center;
  cursor: pointer; font-weight: bold;
}
.cm-lint-error {
  background: rgba(240,98,146,0.12);
  border-bottom: 2px wavy #f06292;
}
.cm-lint-warning {
  border-bottom: 2px wavy #ffb74d;
}
.lint-tooltip {
  position: absolute; z-index: 9999;
  background: #2a2a4a; color: #f06292;
  border: 1px solid #f06292; border-radius: 6px;
  padding: 4px 10px; font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  max-width: 340px; pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  white-space: pre-wrap;
}
.lint-tooltip.warning { color: #ffb74d; border-color: #ffb74d; }

/* ═══ Autocomplete Popup ═══ */
.CodeMirror-hints {
  background: #1e1e3a;
  border: 1px solid #333366;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
  z-index: 9999;
}
.CodeMirror-hint {
  padding: 4px 12px;
  color: #c0c0d0;
  cursor: pointer;
  border-radius: 4px;
  margin: 0 4px;
}
.CodeMirror-hint-active {
  background: #4fc3f7;
  color: #0d0d1a;
}
.ac-desc-inline {
  color: #777;
  font-size: 10px;
  margin-left: 8px;
}

/* ═══ Hide old elements ═══ */
.line-numbers { display: none !important; }

/* ── Report Privacy & Student Info Toggle ── */
.report-privacy {
  padding: 8px 16px;
  margin: 0 16px;
  background: rgba(76, 175, 80, 0.08);
  border: 1px solid rgba(76, 175, 80, 0.25);
  border-radius: 8px;
  color: #81c784;
  font-size: 12px;
  text-align: center;
}
.student-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.student-toggle-row h4 { margin: 0; }
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input { display: none; }
.toggle-slider {
  width: 36px; height: 20px;
  background: #444;
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #aaa;
  top: 2px; left: 2px;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: #2196f3;
}
.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(16px);
  background: #fff;
}
.toggle-label {
  font-size: 12px;
  color: var(--text-muted, #999);
}
.student-fields {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Report warn badge ── */
.report-badge.warn {
  background: rgba(255, 152, 0, 0.15);
  color: #ff9800;
}

/* ── Snippets: Search + Favorites + Insert ── */
.snip-search-wrap {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px;
  background: var(--bg-panel, #1a1a2e);
}
.snip-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--bg-input, #0d0d1a);
  color: var(--text, #e0e0e0);
  font-size: 13px;
  outline: none;
}
.snip-search:focus {
  border-color: #4dd0e1;
  box-shadow: 0 0 0 2px rgba(77, 208, 225, 0.15);
}
.snip-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
}
.snip-item:hover { background: rgba(255,255,255,0.05); }
.snip-body { flex: 1; cursor: pointer; }
.snip-star {
  font-size: 14px;
  color: #555;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.snip-star:hover { color: #ffd54f; }
.snip-star.active { color: #ffd54f; }
.snip-insert {
  font-size: 13px;
  color: #666;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.snip-insert:hover {
  color: #4dd0e1;
  background: rgba(77, 208, 225, 0.1);
}
.snip-fav-group { color: #ffd54f !important; }
.snip-divider {
  height: 1px;
  background: var(--border, #333);
  margin: 4px 8px;
}

/* ═══ LIGHT MODE — CodeMirror Overrides ═══ */
body.light .editor-container .CodeMirror {
  background: #ffffff;
  color: #1a1a2e;
}
body.light .CodeMirror-gutters {
  background: #f0f2f6;
  border-right: 1px solid #d0d4dc;
}
body.light .CodeMirror-linenumber { color: #8892a4; }
body.light .CodeMirror-activeline-background { background: rgba(25,118,210,0.05) !important; }
body.light .CodeMirror-cursor { border-left: 2px solid #1976d2 !important; }
body.light .CodeMirror-selected { background: rgba(25,118,210,0.15) !important; }
body.light .CodeMirror-focused .CodeMirror-selected { background: rgba(25,118,210,0.22) !important; }
body.light .CodeMirror-matchingbracket {
  color: #2e7d32 !important;
  background: rgba(46,125,50,0.12);
  border-bottom: 1px solid #2e7d32;
}
body.light .CodeMirror-nonmatchingbracket {
  color: #c62828 !important;
  background: rgba(198,40,40,0.1);
}
body.light .CodeMirror-vscrollbar::-webkit-scrollbar-thumb,
body.light .CodeMirror-hscrollbar::-webkit-scrollbar-thumb { background: #c0c4cc; }

/* Python syntax — light */
body.light .cm-s-curo .cm-keyword { color: #7b1fa2; }
body.light .cm-s-curo .cm-def { color: #1565c0; }
body.light .cm-s-curo .cm-builtin { color: #e65100; }
body.light .cm-s-curo .cm-string { color: #2e7d32; }
body.light .cm-s-curo .cm-string-2 { color: #00838f; }
body.light .cm-s-curo .cm-number { color: #d84315; }
body.light .cm-s-curo .cm-comment { color: #90a4ae; font-style: italic; }
body.light .cm-s-curo .cm-operator { color: #00838f; }
body.light .cm-s-curo .cm-variable { color: #1a1a2e; }
body.light .cm-s-curo .cm-variable-2 { color: #263238; }
body.light .cm-s-curo .cm-property { color: #1976d2; }
body.light .cm-s-curo .cm-meta { color: #e65100; }
body.light .cm-s-curo .cm-error { color: #c62828; }

/* Lint — light */
body.light .lint-tooltip {
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
body.light .cm-lint-error { background: rgba(198,40,40,0.08); }

/* Autocomplete — light */
body.light .CodeMirror-hints {
  background: #fff;
  border: 1px solid #d0d4dc;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
body.light .CodeMirror-hint { color: #333; }
body.light .CodeMirror-hint-active { background: #1976d2; color: #fff; }

/* Snippets panel — light */
body.light .snip-search-wrap { background: var(--bg-secondary); }
body.light .snip-search { background: #fff; border-color: var(--border); color: var(--text); }
body.light .snip-item:hover { background: rgba(25,118,210,0.08); }
body.light .snip-star { color: #bbb; }
body.light .snip-star.active { color: #f9a825; }
body.light .snip-insert { color: #999; }
body.light .snip-insert:hover { color: #1976d2; background: rgba(25,118,210,0.08); }

/* Report privacy — light */
body.light .report-privacy {
  background: rgba(56,142,60,0.08);
  border-color: rgba(56,142,60,0.25);
  color: #2e7d32;
}
body.light .toggle-slider { background: #ccc; }
body.light .toggle-slider::after { background: #fff; }

/* Autocomplete popup — light */
body.light .ac-popup {
  background: #fff;
  border-color: #d0d4dc;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
body.light .ac-item:hover, body.light .ac-active {
  background: #1976d2; color: #fff;
}
body.light .ac-label { color: #1976d2; }
body.light .ac-active .ac-label { color: #fff; }
body.light .ac-desc { color: #8892a4; }
body.light .ac-active .ac-desc { color: rgba(255,255,255,.7); }

/* ═══ Search Dialog — Dark + Light ═══ */
.CodeMirror-dialog {
  background: #1e1e3a;
  border-bottom: 1px solid #333366;
  color: #e0e0e0;
  padding: 4px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.CodeMirror-dialog input {
  background: #12122a;
  border: 1px solid #333366;
  border-radius: 4px;
  color: #e0e0e0;
  padding: 3px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  outline: none;
  margin: 0 4px;
}
.CodeMirror-dialog input:focus { border-color: #4fc3f7; }
.CodeMirror-dialog button {
  background: #4fc3f7;
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
  margin-left: 4px;
}
body.light .CodeMirror-dialog {
  background: #f0f2f6;
  border-bottom: 1px solid #d0d4dc;
  color: #1a1a2e;
}
body.light .CodeMirror-dialog input {
  background: #fff;
  border-color: #d0d4dc;
  color: #1a1a2e;
}
body.light .CodeMirror-dialog input:focus { border-color: #1976d2; }
body.light .CodeMirror-dialog button { background: #1976d2; color: #fff; }

/* ═══ Fold Gutter ═══ */
.CodeMirror-foldmarker {
  color: #4fc3f7;
  text-shadow: none;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.CodeMirror-foldgutter { width: 14px; }
.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded { cursor: pointer; color: #555580; padding: 0 1px; }
.CodeMirror-foldgutter-open::after { content: '▾'; }
.CodeMirror-foldgutter-folded::after { content: '▸'; }
body.light .CodeMirror-foldmarker { color: #1976d2; }
body.light .CodeMirror-foldgutter-open,
body.light .CodeMirror-foldgutter-folded { color: #8892a4; }

/* ═══ Match Highlighter ═══ */
.cm-matchhighlight { background: rgba(79,195,247,0.15); }
body.light .cm-matchhighlight { background: rgba(25,118,210,0.12); }
