/* ================================================================
   sidebar.css v2.0 — Left Navigation Sidebar
   Desktop: sticky 260px column
   <= 1200px: fixed overlay drawer (slides in from left)
   ================================================================ */

/* ── Desktop sidebar column ────────────────────────────────────── */
#sidebar-wrapper {
  width: 18%;
  max-width: 260px;
  min-width: 220px;
  background: #f8fafc;
  border-right: 1px solid #e5e9f2;
  overflow: hidden;            /* children handle their own scroll */
  flex-shrink: 0;
  height: calc(100vh - var(--header-height));
}

.sidebar {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 12px 40px;
  -webkit-overflow-scrolling: touch;
}

.sidebar::-webkit-scrollbar        { width: 4px; }
.sidebar::-webkit-scrollbar-track  { background: transparent; }
.sidebar::-webkit-scrollbar-thumb  { background: #d1d9e6; border-radius: 4px; }

/* ── Sidebar titles ─────────────────────────────────────────────── */
.sidebar-title {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin: 0 0 10px;
  padding: 0 10px;
}

/* ── Category group headers (for nested courses) ────────────────── */
.sidebar-category {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px 10px 4px;
  margin-top: 8px;
  pointer-events: none;
  user-select: none;
}

/* ── Sidebar list ───────────────────────────────────────────────── */
.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-list li {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1.4;
}
.sidebar-list li:hover {
  background: #e8edf5;
  color: #FA541C;
}
.sidebar-list li.active-item {
  background: #FA541C;
  color: #fff;
  font-weight: 700;
}
.sidebar-list li.sidebar-category {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  background: none;
  text-transform: uppercase;
  cursor: default;
  padding-left: 10px;
}
.sidebar-list li.sidebar-category:hover { background: none; color: #94a3b8; }

/* ── Collapsible Subtopics ──────────────────────────────────────── */
.sidebar-list li.sidebar-parent-item {
  padding: 0;
  background: transparent !important;
}
.sidebar-list li.sidebar-parent-item:hover {
  background: transparent !important;
}

.sidebar-details > summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1.4;
}
.sidebar-details > summary::-webkit-details-marker {
  display: none;
}
.sidebar-details > summary:hover {
  background: #e8edf5;
  color: #FA541C;
}
.sidebar-details > summary.active-item {
  background: #FA541C;
  color: #fff;
  font-weight: 700;
}
.sidebar-details:has(.active-item) > summary:not(.active-item) {
  color: #FA541C;
  font-weight: 600;
  background: #fff5f0;
}
.sidebar-details > summary::after {
  content: "▼";
  font-size: 10px;
  opacity: 0.5;
  transition: transform 0.2s;
  margin-left: 8px;
}
.sidebar-details[open] > summary::after {
  transform: rotate(180deg);
}
.sidebar-details[open] > summary:not(.active-item) {
  color: #FA541C;
}

.sidebar-details > summary > span {
  flex: 0 1 auto;
}

.sidebar-sublist {
  list-style: none;
  margin: 2px 0 0 16px;
  padding: 4px 0;
  border-left: 1px solid #cbd5e1;
}
.sidebar-details[open] > .sidebar-sublist {
  animation: sublistSlideDown 0.2s ease-out;
}
@keyframes sublistSlideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.sidebar-list li.sidebar-subtopic {
  position: relative;
  font-size: 12.5px;
  padding: 6px 12px;
  margin: 1px 0 1px 8px;
  border-radius: 6px;
  color: #475569;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-list li.sidebar-subtopic::before {
  content: '';
  position: absolute;
  top: 15px;
  left: -9px;
  width: 8px;
  height: 1px;
  background: #cbd5e1;
}

.sidebar-list li.sidebar-subtopic:hover {
  background: #e8edf5;
  color: #FA541C;
}
.sidebar-list li.sidebar-subtopic.active-item {
  color: #FA541C;
  background: #fff0eb;
  font-weight: 600;
  border-left: 2px solid #FA541C;
}

/* ── Dark overlay (behind drawer on mobile) ─────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  z-index: 1200;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── 1200px breakpoint: sidebar becomes fixed slide-out drawer ───── */
@media (max-width: 1200px) {

  #sidebar-wrapper {
    position: fixed !important;
    top: 0 !important;
    left: -290px !important;   /* fully off-screen when closed */
    width: 280px !important;
    min-width: 280px !important;
    height: 100vh !important;
    z-index: 1300;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.28s ease;
    box-shadow: none;
    background: #f8fafc;
    border-right: 1px solid #e5e9f2;
    overflow: hidden;
  }

  #sidebar-wrapper.sidebar-open {
    left: 0 !important;
    box-shadow: 6px 0 30px rgba(0, 0, 0, 0.22);
  }

  .sidebar {
    height: 100vh !important;
    padding-top: 20px;
    padding-bottom: 80px; /* room for thumb at bottom of list */
  }

  /* Ensure sidebar-wrapper is always renderable (not display:none) */
  #sidebar-wrapper.hidden {
    display: block !important;
    left: -290px !important;
  }
}

/* ── 480px: slightly narrower drawer ────────────────────────────── */
@media (max-width: 480px) {
  #sidebar-wrapper,
  #sidebar-wrapper.sidebar-open {
    width: 260px !important;
    min-width: 260px !important;
  }
}