/* ============================================================================
   Optimus - Ellipse Cloud Documentation Theme
   Modern docs portal inspired by Aurora Docs (Webflow)
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-0: #0a0e1a;
  --bg-1: #0f1424;
  --bg-2: #161c30;
  --bg-3: #1f2740;
  --bg-card: #141a2e;
  --border: #232b46;
  --border-strong: #303a5c;
  --text-0: #ffffff;
  --text-1: #cdd2e0;
  --text-2: #8a93ad;
  --text-3: #5e667e;
  --accent: #8b7cff;
  --accent-2: #5b8bff;
  --accent-pink: #ff5fa2;
  --gradient: linear-gradient(135deg, #5b8bff 0%, #8b7cff 50%, #ff5fa2 100%);
  --gradient-soft: linear-gradient(135deg, rgba(91, 139, 255, 0.12) 0%, rgba(139, 124, 255, 0.10) 50%, rgba(255, 95, 162, 0.10) 100%);
  --shadow-glow: 0 0 80px rgba(139, 124, 255, 0.25);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w: 280px;
  --toc-w: 240px;
  --header-h: 64px;
}

[data-theme="light"] {
  --bg-0: #ffffff;
  --bg-1: #f7f8fc;
  --bg-2: #eef1f8;
  --bg-3: #e3e7f1;
  --bg-card: #ffffff;
  --border: #e3e7f1;
  --border-strong: #ccd3e3;
  --text-0: #0a0e1a;
  --text-1: #2a3148;
  --text-2: #5e667e;
  --text-3: #8a93ad;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

a { color: var(--accent-2); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }

img { max-width: 100%; height: auto; }

/* ===================== Top bar ===================== */

.optimus-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
}
[data-theme="light"] .optimus-topbar { background: rgba(255, 255, 255, 0.85); }

.optimus-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text-0);
  letter-spacing: -0.01em;
}
.optimus-logo .logo-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--shadow-glow);
}

.optimus-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.optimus-search input {
  width: 100%;
  height: 38px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px 0 38px;
  color: var(--text-1);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.optimus-search input::placeholder { color: var(--text-3); }
.optimus-search input:focus { border-color: var(--accent); background: var(--bg-1); }
.optimus-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}
.optimus-search .kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}

.optimus-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.optimus-top-actions a, .optimus-top-actions button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.optimus-top-actions a:hover, .optimus-top-actions button:hover {
  color: var(--text-0);
  background: var(--bg-2);
}
.optimus-top-actions .lang-switch {
  display: inline-flex;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.optimus-top-actions .lang-switch a {
  padding: 4px 10px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  border-radius: 4px;
}
.optimus-top-actions .lang-switch a.active {
  background: var(--bg-0);
  color: var(--text-0);
}

#theme-toggle {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
}

/* ===================== Layout ===================== */

.optimus-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 0;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px;
}

.optimus-sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 28px 20px 60px 0;
  border-right: 1px solid var(--border);
}
.optimus-sidebar::-webkit-scrollbar { width: 6px; }
.optimus-sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.optimus-sidebar::-webkit-scrollbar-track { background: transparent; }

.optimus-sidebar .sidebar-section {
  margin-bottom: 24px;
}
.optimus-sidebar .sidebar-title {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 8px 12px;
  margin: 0;
}

.optimus-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.optimus-sidebar li { position: relative; }
.optimus-sidebar a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 14px;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  line-height: 1.4;
}
.optimus-sidebar a:hover {
  color: var(--text-0);
  background: var(--bg-2);
}
.optimus-sidebar a.active {
  color: var(--text-0);
  background: var(--gradient-soft);
  font-weight: 600;
  position: relative;
}
.optimus-sidebar a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--gradient);
  border-radius: 0 3px 3px 0;
}

.optimus-sidebar .sub-menu {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  margin-top: 2px;
  margin-bottom: 4px;
}
.optimus-sidebar .sub-menu a {
  font-size: 13.5px;
  padding: 5px 10px;
}
.optimus-sidebar .arrow {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-3);
  transition: transform var(--transition);
}
.optimus-sidebar li.open > a > .arrow,
.optimus-sidebar li.active > a > .arrow { transform: rotate(180deg); }

.optimus-sidebar .sub-menu:not(.show) { display: none; }

/* ===================== Content ===================== */

.optimus-content {
  min-width: 0;
  padding: 40px 48px;
  max-width: 880px;
}

.optimus-breadcrumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  font-size: 13px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.optimus-breadcrumbs li::after {
  content: '/';
  margin-left: 8px;
  color: var(--text-3);
}
.optimus-breadcrumbs li:last-child::after { content: ''; }
.optimus-breadcrumbs a { color: var(--text-2); }
.optimus-breadcrumbs a:hover { color: var(--text-0); }

.optimus-content h1 {
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--text-0);
  margin: 0 0 12px;
}
.optimus-content .lead {
  font-size: 17px;
  color: var(--text-2);
  margin: 0 0 28px;
  line-height: 1.6;
}

.optimus-content h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-0);
  margin: 48px 0 14px;
  padding-top: 8px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.optimus-content h3 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-0);
  margin: 32px 0 10px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.optimus-content h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-0);
  margin: 22px 0 8px;
}

.optimus-content p { margin: 0 0 14px; color: var(--text-1); }
.optimus-content ul, .optimus-content ol { padding-left: 22px; margin: 0 0 16px; }
.optimus-content li { margin: 6px 0; color: var(--text-1); }

.optimus-content pre,
.optimus-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
}
.optimus-content code:not(pre code) {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent);
  font-size: 13px;
}
.optimus-content pre {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 16px 0 22px;
  position: relative;
}
.optimus-content pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text-1);
  line-height: 1.6;
}

.optimus-content blockquote {
  border-left: 3px solid var(--accent);
  background: var(--gradient-soft);
  margin: 18px 0;
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-1);
}

.optimus-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
}
.optimus-content table th,
.optimus-content table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.optimus-content table th { background: var(--bg-2); color: var(--text-0); font-weight: 600; }
.optimus-content table tr:hover td { background: var(--bg-2); }

.optimus-content hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

/* ===================== TOC (right) ===================== */

.optimus-toc {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 40px 0 60px 28px;
  border-left: 1px solid var(--border);
}
.optimus-toc::-webkit-scrollbar { width: 4px; }
.optimus-toc::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.optimus-toc .toc-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin: 0 0 12px;
}
.optimus-toc ul { list-style: none; padding: 0; margin: 0; }
.optimus-toc li { margin: 0; }
.optimus-toc a {
  display: block;
  font-size: 13px;
  line-height: 1.45;
  padding: 5px 0 5px 12px;
  border-left: 2px solid transparent;
  color: var(--text-2);
  transition: all var(--transition);
}
.optimus-toc a:hover { color: var(--text-0); }
.optimus-toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.optimus-toc .toc-h3 { padding-left: 26px; font-size: 12.5px; color: var(--text-3); }

/* ===================== Cards / Homepage ===================== */

.optimus-hero {
  padding: 80px 24px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.optimus-hero::before {
  content: '';
  position: absolute;
  inset: -100px 0 0 0;
  background: radial-gradient(ellipse at center top, rgba(139, 124, 255, 0.18), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.optimus-hero > * { position: relative; z-index: 1; }
.optimus-hero .eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-2);
  margin-bottom: 18px;
}
.optimus-hero h1 {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--text-0);
  margin: 0 0 16px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
.optimus-hero h1 .grad {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.optimus-hero p {
  font-size: 18px;
  color: var(--text-2);
  max-width: 640px;
  margin: 0 auto 32px;
}

.optimus-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin: 32px 0;
}
.optimus-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.optimus-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-soft);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.optimus-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.optimus-card:hover::before { opacity: 1; }
.optimus-card > * { position: relative; z-index: 1; }
.optimus-card .card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--gradient);
  display: grid; place-items: center;
  color: #fff;
  margin-bottom: 14px;
  font-size: 20px;
}
.optimus-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-0);
  margin: 0 0 6px;
}
.optimus-card p {
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
}

/* ===================== Prev/Next ===================== */

.optimus-pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 56px 0 24px;
  list-style: none;
  padding: 0;
}
.optimus-pagination li { margin: 0; }
.optimus-pagination a {
  display: block;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  color: var(--text-1);
}
.optimus-pagination a:hover {
  border-color: var(--accent);
  background: var(--bg-2);
}
.optimus-pagination .label {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.optimus-pagination .next { text-align: right; }
.optimus-pagination .title { font-weight: 600; color: var(--text-0); }

/* ===================== Footer ===================== */

.optimus-footer {
  border-top: 1px solid var(--border);
  margin-top: 80px;
  padding: 40px 24px 60px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.optimus-footer a { color: var(--text-2); margin: 0 8px; }

/* ===================== Chat widget ===================== */

.optimus-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient);
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 32px rgba(139, 124, 255, 0.45);
  z-index: 200;
  transition: transform var(--transition);
}
.optimus-chat-btn:hover { transform: scale(1.06); }
.optimus-chat-btn svg { width: 26px; height: 26px; color: #fff; }

/* ===================== Search results ===================== */

.optimus-search-results {
  list-style: none;
  padding: 0;
  margin: 24px 0;
}
.optimus-search-results li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 12px;
  padding: 0;
  transition: all var(--transition);
}
.optimus-search-results li:hover { border-color: var(--accent); }
.optimus-search-results a { display: block; padding: 16px 20px; color: var(--text-1); }
.optimus-search-results h4 { color: var(--text-0); margin: 0 0 6px; font-size: 16px; }
.optimus-search-results p { font-size: 13.5px; color: var(--text-2); margin: 0; }
.optimus-search-results .highlight { background: rgba(139, 124, 255, 0.30); color: var(--text-0); padding: 0 2px; border-radius: 3px; }

/* ===================== Changelog ===================== */

.optimus-changelog .changelog-entry {
  border-bottom: 1px solid var(--border);
  padding: 28px 0;
}
.optimus-changelog .changelog-entry:last-child { border-bottom: 0; }
.optimus-changelog .changelog-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
}
.optimus-changelog .changelog-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-0);
  margin: 0 0 10px;
}
.optimus-changelog .changelog-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}
.optimus-changelog .changelog-tag {
  font-size: 11px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 500;
}

/* ===================== FAQ ===================== */

.optimus-faq details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin: 0 0 10px;
  transition: all var(--transition);
}
.optimus-faq details[open] { border-color: var(--border-strong); }
.optimus-faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-0);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
}
.optimus-faq summary::-webkit-details-marker { display: none; }
.optimus-faq summary::after {
  content: '+';
  margin-left: auto;
  font-size: 20px;
  color: var(--text-3);
  transition: transform var(--transition);
}
.optimus-faq details[open] summary::after { transform: rotate(45deg); }
.optimus-faq details > div { margin-top: 12px; color: var(--text-1); }

/* ===================== Editable (admin) ===================== */

.editable {
  outline: 2px dashed transparent;
  transition: outline var(--transition);
}
.editable:hover { outline-color: var(--accent); cursor: text; }

/* ===================== Responsive ===================== */

@media (max-width: 1180px) {
  .optimus-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .optimus-toc { display: none; }
}

@media (max-width: 880px) {
  .optimus-shell { grid-template-columns: 1fr; padding: 0; }
  .optimus-sidebar {
    position: fixed;
    top: var(--header-h);
    left: -100%;
    width: 280px;
    background: var(--bg-0);
    transition: left var(--transition);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    z-index: 80;
    height: calc(100vh - var(--header-h));
  }
  .optimus-sidebar.open { left: 0; }
  .optimus-content { padding: 24px 18px; }
  .optimus-hero h1 { font-size: 36px; }
  .optimus-search { display: none; }
  #mobile-menu-toggle { display: grid; }
}

#mobile-menu-toggle { display: none; }

/* highlight.js dark theme override */
.hljs { background: var(--bg-1) !important; color: var(--text-1) !important; }
.hljs-keyword, .hljs-built_in { color: var(--accent); }
.hljs-string { color: #7eebc0; }
.hljs-number { color: #ff9a6c; }
.hljs-comment { color: var(--text-3); font-style: italic; }
.hljs-title, .hljs-name { color: var(--accent-2); }
