/* ═══════════════════════════════════════════════════════════════
   DEVDOCS — Custom Stylesheet
   Stack: Bootstrap 5.3.8 + jsTree + jQuery 4.0.0
   Aesthetic: Dark sidebar / clean content — editorial-technical
═══════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --font-display : 'Fraunces', Georgia, serif;
  --font-body    : 'Source Sans 3', system-ui, sans-serif;
  --font-mono    : 'IBM Plex Mono', 'Fira Code', monospace;

  /* Sidebar palette */
  --sb-bg        : #0d1117;
  --sb-surface   : #161b22;
  --sb-border    : #21262d;
  --sb-text      : #8b949e;
  --sb-text-hi   : #e6edf3;
  --sb-accent    : #58a6ff;
  --sb-accent-glow: rgba(88, 166, 255, 0.15);

  /* Content palette */
  --ct-bg        : #ffffff;
  --ct-surface   : #f6f8fa;
  --ct-border    : #d0d7de;
  --ct-text      : #1f2328;
  --ct-text-muted: #656d76;
  --ct-accent    : #0969da;

  /* Navbar */
  --nb-bg        : #0d1117;
  --nb-border    : #21262d;
  --nb-height    : 56px;

  /* Sizing */
  --sidebar-w    : 272px;
  --radius       : 8px;
  --radius-sm    : 5px;

  /* Transitions */
  --ease         : cubic-bezier(0.4, 0, 0.2, 1);
  --dur          : 200ms;
}

/* Light theme override */
[data-theme="light"] {
  --sb-bg        : #f6f8fa;
  --sb-surface   : #eaeef2;
  --sb-border    : #d0d7de;
  --sb-text      : #57606a;
  --sb-text-hi   : #24292f;
  --sb-accent    : #0969da;
  --sb-accent-glow: rgba(9, 105, 218, 0.1);
  --nb-bg        : #24292f;
  --nb-border    : #30363d;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--ct-bg);
  color: var(--ct-text);
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════════════════════════
   NAVBAR
══════════════════════════════════════════════════════════════ */
.docs-navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nb-height);
  background: var(--nb-bg);
  border-bottom: 1px solid var(--nb-border);
  z-index: 1030;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.navbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  padding: 0 20px;
}

/* Brand */
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: -0.3px;
  transition: opacity var(--dur);
}
.brand-logo:hover { opacity: 0.8; color: #e6edf3; }

.brand-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #58a6ff 0%, #3fb950 100%);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  color: #0d1117;
}

.brand-name { font-weight: 400; }
.brand-name strong { font-weight: 600; }

.brand-version {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(88, 166, 255, 0.15);
  color: var(--sb-accent);
  border: 1px solid rgba(88, 166, 255, 0.3);
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

/* Search */
.navbar-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  height: 34px;
  background: rgba(255,255,255,0.07);
  border: 1px solid #30363d;
  border-radius: var(--radius-sm);
  color: #e6edf3;
  font-family: var(--font-body);
  font-size: 13.5px;
  padding: 0 36px 0 34px;
  outline: none;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}
.search-box input::placeholder { color: #6e7681; }
.search-box input:focus {
  border-color: var(--sb-accent);
  background: rgba(88, 166, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.search-icon {
  position: absolute; left: 10px;
  color: #6e7681; font-size: 13px;
  pointer-events: none;
}
.search-kbd {
  position: absolute; right: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #6e7681;
  background: rgba(255,255,255,0.07);
  border: 1px solid #30363d;
  padding: 1px 6px;
  border-radius: 4px;
}

/* Actions */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Buttons */
.icon-btn {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: var(--radius-sm);
  color: #8b949e;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
  text-decoration: none;
}
.icon-btn:hover {
  background: rgba(255,255,255,0.07);
  color: #e6edf3;
  border-color: #8b949e;
}

.icon-btn-sm {
  width: 26px; height: 26px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--sb-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
}
.icon-btn-sm:hover {
  background: rgba(255,255,255,0.07);
  color: var(--sb-text-hi);
}

.docs-btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--sb-accent);
  color: #0d1117;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: filter var(--dur), transform var(--dur);
}
.docs-btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); color: #0d1117; }

.docs-btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  color: var(--ct-accent);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border: 1.5px solid var(--ct-accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
}
.docs-btn-ghost:hover {
  background: var(--ct-accent);
  color: #fff;
}

/* Sidebar toggle */
.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: #8b949e;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--dur);
  display: flex; align-items: center;
}
.sidebar-toggle-btn:hover { color: #e6edf3; }

/* ══════════════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════════════ */
.docs-layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--nb-height);
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════ */
.docs-sidebar {
  position: fixed;
  top: var(--nb-height);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--nb-height));
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--dur) var(--ease), width var(--dur) var(--ease);
  z-index: 900;
}

.docs-sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--sb-text);
}

/* Tree search */
.tree-search-wrap {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.tree-search-wrap i {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  color: var(--sb-text); font-size: 12px;
}
.tree-search-wrap input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--sb-border);
  border-radius: var(--radius-sm);
  color: var(--sb-text-hi);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 6px 10px 6px 30px;
  outline: none;
  transition: border-color var(--dur), background var(--dur);
}
.tree-search-wrap input::placeholder { color: var(--sb-text); }
.tree-search-wrap input:focus {
  border-color: var(--sb-accent);
  background: rgba(88, 166, 255, 0.06);
}

/* Tree container */
.page-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
  scrollbar-width: thin;
  scrollbar-color: #30363d transparent;
}
.page-tree::-webkit-scrollbar { width: 4px; }
.page-tree::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }

/* jsTree custom overrides */
.jstree-default .jstree-anchor {
  color: var(--sb-text) !important;
  font-family: var(--font-body);
  font-size: 13.5px;
  height: auto;
  padding: 5px 8px 5px 4px;
  border-radius: var(--radius-sm);
  white-space: normal;
  transition: background var(--dur), color var(--dur);
  line-height: 1.4;
}
.jstree-default .jstree-anchor:hover {
  background: rgba(88, 166, 255, 0.1) !important;
  color: var(--sb-text-hi) !important;
}
.jstree-default .jstree-clicked {
  background: rgba(88, 166, 255, 0.18) !important;
  color: var(--sb-accent) !important;
  font-weight: 600;
}
.jstree-default .jstree-hovered {
  background: rgba(88, 166, 255, 0.08) !important;
  border: none !important;
  box-shadow: none !important;
}

/* Fix jsTree background */
.jstree-default {
  background: transparent !important;
}
.jstree-container-ul .jstree-node {
  margin-left: 0;
}

/* Node icons */
.jstree-default .jstree-icon.jstree-ocl {
  color: var(--sb-text) !important;
}

.jstree-leaf > .jstree-anchor::before {
  content: "\F4A2";
  font-family: "bootstrap-icons";
  margin-right: 6px;
  font-size: 12px;
  opacity: 0.6;
  color: var(--sb-accent);
}

/* jstree loaded icons transparency override */
#pageTree .jstree-default .jstree-themeicon { display: none; }

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.page-count-badge {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--sb-text);
}

.sidebar-version {
  font-size: 11px;
  color: var(--sb-text);
  display: flex; align-items: center; gap: 4px;
}

/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════════════ */
.docs-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: margin-left var(--dur) var(--ease);
}

.docs-content.full-width {
  margin-left: 0;
}

/* Breadcrumb */
.docs-breadcrumb {
  padding: 10px 28px;
  background: var(--ct-surface);
  border-bottom: 1px solid var(--ct-border);
  flex-shrink: 0;
}

.breadcrumb-item a {
  color: var(--ct-accent);
  text-decoration: none;
  font-size: 13px;
  display: flex; align-items: center; gap: 5px;
}
.breadcrumb-item.active { font-size: 13px; color: var(--ct-text-muted); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--ct-text-muted); }

/* ── Content Area ──────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ══════════════════════════════════════════════════════════════
   WELCOME SCREEN
══════════════════════════════════════════════════════════════ */
.welcome-screen {
  padding: 40px 48px 60px;
  max-width: 900px;
  overflow-y: auto;
  height: 100%;
}

.welcome-hero {
  position: relative;
  margin-bottom: 40px;
  padding: 48px 0 16px;
}

.welcome-orb {
  position: absolute;
  top: -20px; right: -20px;
  width: 260px; height: 260px;
  background: radial-gradient(circle at 50% 50%,
    rgba(88, 166, 255, 0.12) 0%,
    rgba(63, 185, 80, 0.06) 50%,
    transparent 70%
  );
  border-radius: 50%;
  pointer-events: none;
  animation: orbPulse 6s ease-in-out infinite alternate;
}

@keyframes orbPulse {
  from { transform: scale(1) rotate(0deg); opacity: 0.7; }
  to   { transform: scale(1.15) rotate(15deg); opacity: 1; }
}

.welcome-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 300;
  color: var(--ct-text);
  line-height: 1.15;
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}
.welcome-title em {
  font-style: italic;
  color: var(--ct-accent);
}

.welcome-sub {
  font-size: 16px;
  color: var(--ct-text-muted);
  max-width: 520px;
  line-height: 1.6;
  margin-bottom: 28px;
}

.welcome-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Stats */
.welcome-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 44px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 120px;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.stat-card:hover {
  border-color: var(--ct-accent);
  box-shadow: 0 2px 12px rgba(9, 105, 218, 0.08);
}

.stat-card i {
  font-size: 20px;
  color: var(--ct-accent);
  margin-bottom: 6px;
}
.stat-card span {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--ct-text);
  line-height: 1;
}
.stat-card label {
  font-size: 12px;
  color: var(--ct-text-muted);
  font-weight: 400;
  letter-spacing: 0.3px;
}

/* Quick page grid */
.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ct-text-muted);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 7px;
}

.quick-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.quick-page-card {
  background: var(--ct-bg);
  border: 1px solid var(--ct-border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur);
  animation: cardIn var(--dur) var(--ease) both;
}
.quick-page-card:hover {
  border-color: var(--ct-accent);
  box-shadow: 0 4px 16px rgba(9, 105, 218, 0.1);
  transform: translateY(-2px);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.quick-page-card .qp-icon {
  width: 36px; height: 36px;
  background: rgba(9, 105, 218, 0.08);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--ct-accent);
  font-size: 16px;
  margin-bottom: 12px;
}
.quick-page-card .qp-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ct-text);
  margin-bottom: 4px;
}
.quick-page-card .qp-url {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ct-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Quick grid — source section headers */
.qp-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ct-border);
  margin-bottom: 4px;
}
.qp-section-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.qp-section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--ct-text-muted);
  font-weight: 600;
}
.qp-section-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  color: var(--ct-text-muted);
  padding: 1px 7px;
  border-radius: 20px;
}

/* ══════════════════════════════════════════════════════════════
   IFRAME WRAPPER
══════════════════════════════════════════════════════════════ */
.iframe-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  animation: fadeIn 200ms var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.iframe-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: var(--ct-surface);
  border-bottom: 1px solid var(--ct-border);
  flex-shrink: 0;
}

.page-meta {
  display: flex; align-items: center; gap: 10px;
}

.page-badge {
  width: 28px; height: 28px;
  background: rgba(9, 105, 218, 0.1);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ct-accent);
  font-size: 13px;
}

.iframe-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ct-text);
  font-weight: 500;
}

.iframe-actions {
  display: flex; gap: 4px;
}

.iframe-actions .icon-btn-sm {
  color: var(--ct-text-muted);
}
.iframe-actions .icon-btn-sm:hover {
  background: var(--ct-border);
  color: var(--ct-text);
}

/* Load progress bar */
.iframe-load-bar {
  height: 2px;
  background: var(--ct-border);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.iframe-load-bar::after {
  content: '';
  position: absolute;
  left: -100%; top: 0;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--ct-accent), transparent);
  animation: loadSlide 1.2s ease infinite;
}
.iframe-load-bar.done::after { display: none; }

@keyframes loadSlide {
  from { left: -60%; }
  to   { left: 160%; }
}

.content-iframe {
  flex: 1;
  border: none;
  background: var(--ct-bg);
}

/* ══════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════ */
.docs-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: #1f2328;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px;
  font-family: var(--font-body);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  max-width: 320px;
}
.docs-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.docs-toast i { color: var(--sb-accent); flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .docs-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .docs-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,0.5);
  }
  .docs-content { margin-left: 0; }
  .navbar-search { display: none; }
  .welcome-screen { padding: 24px 20px 40px; }
  .brand-version { display: none; }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 850;
    display: none;
  }
  .sidebar-overlay.show { display: block; }
}

/* ══════════════════════════════════════════════════════════════
   SCROLLBAR (content area)
══════════════════════════════════════════════════════════════ */
.welcome-screen {
  scrollbar-width: thin;
  scrollbar-color: var(--ct-border) transparent;
}
.welcome-screen::-webkit-scrollbar { width: 5px; }
.welcome-screen::-webkit-scrollbar-thumb {
  background: var(--ct-border);
  border-radius: 4px;
}

/* ══════════════════════════════════════════════════════════════
   JSTREE ROOT FOLDER STYLING
══════════════════════════════════════════════════════════════ */
.jstree-default > .jstree-container-ul > .jstree-node > .jstree-anchor {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--sb-text) !important;
  font-weight: 600;
  cursor: default;
}
