/* layout.css — topbar, shell grid, sidebar, main column */

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #06111f; font-weight: 800; font-size: 13px; letter-spacing: -.5px;
}
.brand-text { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.brand-text b { color: var(--brand-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100vh - var(--topbar-h));
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.set-toggle { display: flex; gap: 4px; padding: 10px 14px 0; }
.set-btn {
  flex: 1; padding: 8px 10px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.set-btn:hover { color: var(--text); }
.set-btn.active { background: var(--brand); border-color: var(--brand); color: #06111f; }

.progress-box { padding: 10px 16px; border-bottom: 1px solid var(--border-soft); }
.progress-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; gap: 8px; }
.progress-track { height: 6px; background: var(--bg-3); border-radius: 6px; margin: 8px 0 5px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--success), var(--success-2)); border-radius: 6px; box-shadow: 0 0 10px var(--success-glow); transition: width .45s var(--ease); }
.progress-foot { font-size: 11.5px; }

/* search row + filter toggle */
.search-box { display: flex; gap: 6px; padding: 10px 14px 8px; }
.search-box input {
  flex: 1; min-width: 0; padding: 9px 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: 13.5px;
}
.search-box input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.filter-toggle {
  position: relative; flex: 0 0 auto; width: 38px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-2); font-size: 15px; cursor: pointer;
}
.filter-toggle:hover { color: var(--text); border-color: var(--brand); }
.filter-toggle.active { background: var(--brand-glow); border-color: var(--brand); color: var(--text); }
.filter-dot {
  position: absolute; top: 5px; right: 6px; width: 7px; height: 7px;
  border-radius: 999px; background: var(--brand-2); box-shadow: 0 0 0 2px var(--bg-1);
}

/* collapsible filter panel */
.filters {
  display: flex; gap: 6px; padding: 0 14px 10px; flex-wrap: wrap;
  max-height: 260px; overflow: hidden;
  transition: max-height var(--dur) var(--ease), opacity var(--dur) var(--ease), padding var(--dur) var(--ease);
}
.filters.collapsed { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; pointer-events: none; }
.filters select {
  flex: 1 1 auto; min-width: 0;
  padding: 7px 8px; font-size: 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-2); cursor: pointer;
}
.filters select:focus { outline: none; border-color: var(--brand); }
.clear-btn {
  flex: 0 0 auto; width: 32px; padding: 7px 0;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--muted); cursor: pointer;
}
.clear-btn:hover { color: var(--red); border-color: var(--red); }

/* compact category tools */
.nav-tools { display: flex; align-items: center; gap: 4px; padding: 4px 14px 4px; }
.nav-tools-label { flex: 1; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; }
.nav-tool-icon {
  flex: 0 0 auto; width: 26px; padding: 4px 0; font-size: 11px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px;
}
.nav-tool-icon:hover { color: var(--text); border-color: var(--brand); }

.nav { flex: 1; overflow-y: auto; padding: 6px 8px 40px; scroll-behavior: smooth; overscroll-behavior: contain; }
.nav-empty { padding: 24px 16px; color: var(--muted); font-size: 13px; text-align: center; }

.cat-header {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; margin-top: 4px;
  background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 13px; font-weight: 700; text-align: left;
  border-radius: 8px; letter-spacing: .2px;
}
.cat-header:hover { background: var(--bg-2); }
.cat-caret {
  width: 12px; color: var(--muted); font-size: 10px;
  display: inline-block; transform-origin: 50% 50%;
  transition: transform var(--dur-cat) var(--ease-cat);
}
.cat-block.collapsed .cat-caret { transform: rotate(-90deg); }
.cat-icon { width: 18px; text-align: center; color: var(--brand-2); }
.cat-name { flex: 1; }
.cat-count { font-size: 11px; color: var(--muted); font-weight: 600; background: var(--bg-3); padding: 1px 7px; border-radius: 999px; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }

/* Animated category collapse via an explicit pixel height set in JS (see
   setCatOpen). Animating `height` in px is smooth and works in every browser
   (unlike grid `fr` transitions, which Safari snaps). The wrapper clips its
   content; the list fades in tandem for extra polish. */
.cat-block { margin-bottom: 4px; }
.cat-list-outer { overflow: hidden; height: auto; transition: height var(--dur-cat) var(--ease-cat); }
.cat-list { padding: 0 0 0 6px; transition: opacity var(--dur-cat) var(--ease-cat); }
.cat-block.collapsed .cat-list { opacity: 0; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 7px;
  color: var(--text-2); font-size: 13px; cursor: pointer;
}
.nav-item:hover { background: var(--bg-2); text-decoration: none; color: var(--text); transform: translateX(2px); }
.nav-item.active { background: var(--brand-glow); color: var(--text); box-shadow: inset 2px 0 0 var(--brand); }
.ni-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ni-review { color: var(--amber); font-size: 11px; }
.ni-diff { font-size: 10px; font-weight: 800; width: 16px; text-align: center; border-radius: 4px; }
.st { font-size: 13px; width: 14px; text-align: center; }
.st-solved { color: var(--green); }
.st-learning { color: var(--amber); }
.st-not-started { color: var(--muted); }
.d-easy { color: var(--easy); } .d-medium { color: var(--medium); } .d-hard { color: var(--hard); }

/* ---------- main ---------- */
.main { overflow-y: auto; padding: 0 0 80px; }
.empty-state { padding: 80px 40px; text-align: center; color: var(--muted); font-size: 16px; }

/* ---------- collapsible sidebar (desktop) ---------- */
.menu-only { display: inline-flex; }
@media (min-width: 901px) {
  /* Animate the sidebar track width to 0 (the sidebar clips via overflow:hidden)
     instead of display:none, so collapse/expand glides rather than snapping. */
  .shell { transition: grid-template-columns var(--dur-slow) var(--ease-cat); }
  body.sidebar-collapsed .shell { grid-template-columns: 0 1fr; }
  body.sidebar-collapsed .sidebar { border-right-color: transparent; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 86%; max-width: 340px;
    z-index: 40; transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-cat);
    will-change: transform;
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  .menu-only { display: inline-flex; }
  .topbar-right .ghost-btn { padding: 6px 8px; font-size: 11px; }

  /* fading scrim behind the drawer */
  .drawer-scrim { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 39; background: rgba(4,7,13,.5);
    opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
  body.sidebar-open .drawer-scrim { opacity: 1; pointer-events: auto; }
}
