/* ─── Quantlens dark theme over sphinx_rtd_theme ──────────────────────────
   Palette mirrors Hyper admin (dark+dark mode).
   Many overrides need !important because RTD bakes in its own !important.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --ql-primary:   #727cf5;
  --ql-primary-d: #5f6be0;
  --ql-ok:        #0acf97;
  --ql-warn:      #f5a623;
  --ql-danger:    #fa5c7c;

  --ql-bg:        #262e38;
  --ql-bg-alt:    #2d3748;
  --ql-sidebar:   #313a46;
  --ql-sidebar-d: #3a444e;
  --ql-border:    #3d4a5a;

  --ql-text:      #aab8c5;
  --ql-heading:   #e2e8f0;
  --ql-muted:     #8391a2;
  --ql-link:      #727cf5;
  --ql-link-h:    #bccee4;
}

/* ── Base & body backgrounds ─────────────────────────────────────────────── */
body,
.wy-body-for-nav              { background: var(--ql-bg) !important; color: var(--ql-text); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.wy-grid-for-nav              { background: var(--ql-bg) !important; }
.wy-nav-content-wrap          { background: var(--ql-bg) !important; }
.wy-nav-content               { background: var(--ql-bg) !important; max-width: 900px; }

/* ── Typography ───────────────────────────────────────────────────────────── */
.rst-content,
.rst-content p,
.rst-content li,
.rst-content dd               { color: var(--ql-text); }

.rst-content h1,
.rst-content h2,
.rst-content h3,
.rst-content h4,
.rst-content h5,
.rst-content h6               { color: var(--ql-heading) !important; font-weight: 700; }

.rst-content h1 { border-bottom: 3px solid var(--ql-primary); padding-bottom: .4rem; }
.rst-content h2 { border-bottom: 1px solid var(--ql-border);  padding-bottom: .3rem; }
.rst-content h3 { color: var(--ql-primary) !important; }

a,
.rst-content a          { color: var(--ql-link); }
a:hover,
.rst-content a:hover    { color: var(--ql-link-h); text-decoration: underline; }

hr { border-color: var(--ql-border); }

/* ── Navigation sidebar ───────────────────────────────────────────────────── */
.wy-nav-side        { background: var(--ql-sidebar) !important; }

/* Project / version header */
.wy-side-nav-search {
  background: var(--ql-sidebar-d) !important;
  border-bottom: 1px solid var(--ql-border);
}
.wy-side-nav-search > a,
.wy-side-nav-search .wy-dropdown > a {
  color: var(--ql-heading) !important;
  font-weight: 700;
}
.wy-side-nav-search .version    { color: var(--ql-muted) !important; }
.wy-side-nav-search input[type="text"] {
  background: var(--ql-bg) !important;
  color: var(--ql-heading) !important;
  border: 1px solid var(--ql-border) !important;
  border-radius: 6px;
}
.wy-side-nav-search input[type="text"]:focus {
  border-color: var(--ql-primary) !important;
  box-shadow: 0 0 0 2px rgba(114,124,245,.25);
  outline: none;
}

/* Menu background */
.wy-menu-vertical               { background: var(--ql-sidebar) !important; }

/* All nav links — readable light text */
.wy-menu-vertical a             { color: #c5d0de !important; }
.wy-menu-vertical a:hover       { background: var(--ql-sidebar-d) !important; color: var(--ql-link-h) !important; }

/* Section captions */
.wy-menu-vertical p.caption     { color: #c5d0de !important; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.wy-menu-vertical p.caption span { color: inherit !important; }

/* Active / current page — RTD forces #fcfcfc, must override */
.wy-menu-vertical li.current > a,
.wy-menu-vertical li.on > a    {
  background: rgba(114,124,245,.18) !important;
  color: #fff !important;
  border-right: 3px solid var(--ql-primary) !important;
}
.wy-menu-vertical li.current   { background: transparent !important; }

/* Nested levels */
.wy-menu-vertical li.toctree-l1.current > a { background: rgba(114,124,245,.18) !important; }
.wy-menu-vertical li.toctree-l2 > a         { padding-left: 2rem; font-size: .9rem; }
.wy-menu-vertical li.toctree-l3 > a         { padding-left: 3rem; font-size: .87rem; }

/* Expand toggles */
.wy-menu-vertical .toctree-expand                     { color: var(--ql-muted) !important; }
.wy-menu-vertical li.current > a .toctree-expand,
.wy-menu-vertical li.on > a .toctree-expand           { color: var(--ql-primary) !important; }

/* ── Top mobile header ────────────────────────────────────────────────────── */
.wy-nav-top {
  background: var(--ql-sidebar-d) !important;
  border-bottom: 1px solid var(--ql-border);
  color: var(--ql-heading);
}
.wy-nav-top a { color: var(--ql-heading) !important; }
.wy-nav-top i { color: var(--ql-heading) !important; }

/* ── Breadcrumbs ──────────────────────────────────────────────────────────── */
.wy-breadcrumbs li,
.wy-breadcrumbs a                    { color: var(--ql-muted); }
.wy-breadcrumbs li.wy-breadcrumbs-aside a { color: var(--ql-link); }
div[role="navigation"] .wy-breadcrumbs-aside a { color: var(--ql-link); }

/* ── Admonitions ──────────────────────────────────────────────────────────── */
.rst-content .note,
.rst-content .seealso {
  background: rgba(114,124,245,.1) !important;
  border-left: 4px solid var(--ql-primary);
  border-radius: 0 8px 8px 0;
}
.rst-content .warning,
.rst-content .caution,
.rst-content .attention {
  background: rgba(245,166,35,.1) !important;
  border-left: 4px solid var(--ql-warn);
  border-radius: 0 8px 8px 0;
}
.rst-content .tip,
.rst-content .hint,
.rst-content .important {
  background: rgba(10,207,151,.1) !important;
  border-left: 4px solid var(--ql-ok);
  border-radius: 0 8px 8px 0;
}
.rst-content .danger,
.rst-content .error {
  background: rgba(250,92,124,.1) !important;
  border-left: 4px solid var(--ql-danger);
  border-radius: 0 8px 8px 0;
}

.rst-content .admonition-title {
  background: transparent !important;
  color: var(--ql-primary) !important;
  font-weight: 700;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--ql-border);
}
.rst-content .warning .admonition-title,
.rst-content .caution .admonition-title { color: var(--ql-warn) !important; }
.rst-content .tip .admonition-title,
.rst-content .hint .admonition-title    { color: var(--ql-ok) !important; }
.rst-content .danger .admonition-title  { color: var(--ql-danger) !important; }

.rst-content .note p,
.rst-content .warning p,
.rst-content .tip p,
.rst-content .danger p { color: var(--ql-text); margin-bottom: 0; }

/* ── Code & inline code ───────────────────────────────────────────────────── */
.rst-content pre.literal-block,
.rst-content div[class^="highlight"],
.highlight pre {
  background: var(--ql-bg-alt) !important;
  border: 1px solid var(--ql-border) !important;
  border-radius: 8px;
  color: #e2e8f0;
}

/* RTD sets code/tt to #fff — override */
.rst-content code,
.rst-content tt,
code, tt, kbd {
  background: var(--ql-bg-alt) !important;
  color: #bccee4 !important;
  border: 1px solid var(--ql-border) !important;
  border-radius: 4px;
  font-size: .88em;
  padding: .1em .35em;
}

/* Syntax tokens */
.highlight .n,  .highlight .p  { color: #aab8c5; }
.highlight .s,  .highlight .s1,
.highlight .s2                  { color: #0acf97; }
.highlight .k,  .highlight .kn { color: #727cf5; }
.highlight .mi, .highlight .mf { color: #f5a623; }
.highlight .c,  .highlight .c1 { color: #8391a2; font-style: italic; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.rst-content table.docutils {
  border: 1px solid var(--ql-border) !important;
  border-radius: 8px;
  overflow: hidden;
  font-size: .9rem;
}

/* Header row */
.rst-content table.docutils thead {
  color: #fff !important;
}
.rst-content table.docutils thead th {
  background: linear-gradient(135deg, #5f6be0, #727cf5) !important;
  color: #fff !important;
  font-weight: 700;
  padding: .55rem .85rem;
  border-color: var(--ql-border) !important;
}

/* Body cells — RTD uses #f3f6f6 for odd rows, must force dark */
.rst-content table.docutils td,
.rst-content table.docutils tbody td {
  background: var(--ql-bg) !important;
  color: var(--ql-text) !important;
  border-color: var(--ql-border) !important;
  padding: .5rem .85rem;
}
.rst-content table.docutils:not(.field-list) tr:nth-child(2n-1) td,
.wy-table-odd td,
.wy-table-striped tr:nth-child(2n-1) td {
  background: var(--ql-bg-alt) !important;
}

/* ── Buttons (Prev / Next) ────────────────────────────────────────────────── */
/* RTD uses .btn-neutral with !important — need to outrank it */
.btn-neutral,
.btn-neutral:visited {
  background: var(--ql-sidebar) !important;
  color: var(--ql-link) !important;
  border: 1px solid var(--ql-border) !important;
  border-radius: 8px !important;
}
.btn-neutral:hover {
  background: var(--ql-sidebar-d) !important;
  color: var(--ql-link-h) !important;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
footer {
  background: var(--ql-bg) !important;
  border-top: 1px solid var(--ql-border);
  color: var(--ql-muted);
}
footer a { color: var(--ql-link); }

/* ── Scrollbar (webkit) ───────────────────────────────────────────────────── */
::-webkit-scrollbar              { width: 7px; height: 7px; }
::-webkit-scrollbar-track        { background: var(--ql-sidebar); }
::-webkit-scrollbar-thumb        { background: var(--ql-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover  { background: var(--ql-primary); }
