/* ─── Studyflow Sidebar Blocks — topic tree + block items (S1.5) ────
   Split from courses.css / studyflow-blocks.css to keep both <500 LOC.
   Dark-theme adapted to v3 tokens (variables.css). Loaded after both. */

/* ─── Course progress bar ──────────────────────────────────────── */
.ci-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 6px 0 0 18px;
  overflow: hidden;
}
.ci-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .2s ease;
}

/* ─── V3-DND / Issue #12: drag-to-reorder via a grip handle ───────
   Only .drag-handle is draggable; the rows stay clickable so you can
   still open a course, a topic or a block. The grip stays nearly
   invisible until the row is hovered, so the sidebar keeps its
   original metrics. */
.drag-handle {
  flex: 0 0 auto;
  width: 12px;
  margin-left: -2px;
  cursor: grab;
  color: var(--text-muted, #6b7280);
  opacity: .25;
  font-size: 10px;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity .12s;
}
.course-item:hover > .drag-handle,
.topic-item:hover > .topic-header > .drag-handle,
.block-item:hover > .drag-handle { opacity: .85; }
/* .course-item is align-items: flex-start (see courses.css) while its
   topic/block siblings centre their grip in a one-line flex row. Without
   this nudge the 10px grip sits flush with the top of the ~19.5px title
   line and reads as slightly too high. Scoped to the course card on
   purpose: a global margin-top would push the already-centred grips in
   .topic-header and .block-item out of alignment. */
.course-item > .drag-handle { margin-top: 4px; }
.drag-handle:hover { opacity: 1 !important; }
.drag-handle:active { cursor: grabbing; }
.dragging > .drag-handle,
.topic-header > .drag-handle.dragging { opacity: 1 !important; }
.topic-item.dragging,
.block-item.dragging {
  opacity: .45;
  outline: 1px dashed var(--primary);
  outline-offset: -1px;
}
.topic-item.drag-over,
.block-item.drag-over {
  opacity: 1;
  outline: 1px solid var(--primary);
  outline-offset: -1px;
  background: rgba(79,140,255,.10);
  border-radius: 6px;
}

/* ─── Course drag&drop + favorites group (Issue #12) ──────────── */
.course-item.dragging {
  opacity: .45;
  outline: 1px dashed var(--primary);
  outline-offset: -1px;
}
.course-item.drag-over {
  opacity: 1;
  outline: 1px solid var(--primary);
  outline-offset: -1px;
  background: rgba(79,140,255,.10);
  border-radius: 6px;
}
/* An empty group (e.g. all courses starred) still needs a drop target. */
.course-drop-group {
  min-height: 8px;
  border-radius: 6px;
  transition: background .12s, outline-color .12s;
}
.course-drop-group.drag-over {
  outline: 1px dashed var(--primary);
  outline-offset: 2px;
  background: rgba(79,140,255,.06);
}
.course-group-title {
  color: var(--primary);
  font-weight: 600;
}

/* ─── Topic tree (course-children → course-topics) ─────────────── */
/* V3-L: topics flush left — title starts at the nav edge (was 12px
   margin + 8px padding + a grab handle before the title). */
.course-topics {
  margin: 6px 0 4px 2px;
  padding-left: 4px;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topic-item {
  display: flex;
  flex-direction: column;
  align-items: stretch; /* overrides courses.css align-items:center —
                           this was centering the .topic-header inside
                           the column, pushing titles to the middle */
  gap: 2px;
}

.topic-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px 5px 2px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.topic-header:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.topic-header.active {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: var(--text);
}

.topic-arrow {
  display: inline-block;
  width: 10px;
  color: var(--text-muted);
  font-size: 9px;
  flex-shrink: 0;
}

.topic-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-count {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* ─── Topic blocks container (shown when topic expanded) ───────── */
.topic-blocks {
  margin: 2px 0 2px 18px;
  padding-left: 8px;
  border-left: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* ─── Block item (inside topic-blocks) ─────────────────────────── */
.block-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid transparent;
  background: var(--surface);
  transition: background .12s, border-color .12s, color .12s;
}
.block-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.block-item.active {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: var(--text);
}
/* Scroll-driven highlight (scroll-spy sync) — deliberately softer
   than .active (click selection) so the two read as different. */
.block-item.active-scroll {
  background: var(--surface-hover);
  border-color: var(--primary);
  border-style: dashed;
  color: var(--text);
}
.block-item.separator {
  padding-top: 2px;
  padding-bottom: 2px;
}
.block-item.separator.no-label .bi-title {
  display: none;
}
.block-item.separator.has-label .bi-title {
  font-style: italic;
  color: var(--text-muted);
}
.block-item.is-done .bi-title,
.block-item.is-done .bi-icon {
  opacity: 0.6;
  text-decoration: line-through;
}

.bi-check {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 2px;
}
.bi-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--primary);
}

.bi-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.bi-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ─── Empty states ─────────────────────────────────────────────── */
.empty-blocks {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
  font-style: italic;
}