/* ==========================================================================
   1. CSS Variables & Theming
   ========================================================================== */
:root {
  /* Brand Colors */
  --jooby-blue: #2196f3;
  --jooby-blue-hover: #1976d2;
  --jooby-accent: #ffa726;

  /* Light Theme (Default) */
  --bg-main: #ffffff;
  --bg-surface: #f8f9fa;
  --bg-callout: #f3f4f6;
  --border-color: #e5e7eb;

  /* Typography Colors (Adapts to Light Theme) */
  --text-main: #334155;     /* Dark Slate */
  --text-muted: #6b7280;
  --text-bold: #0f172a;     /* Near Black */
  --heading-color: #111827;
  --link-color: #2563eb;    /* Bright Blue */

  /* Code Blocks */
  --code-bg: #282c34;
  --code-text: #ffffff;
  --code-inline-bg: #f1f5f9;
  --code-inline-text: #be185d;

  /* Layout */
  --sidebar-width: 300px;
  --content-max-width: 900px;
  --border-radius: 6px;

  /* Typography Stacks */
  --font-code: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

html[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-surface: #1e293b;
  --bg-callout: #1e293b;
  --border-color: #334155;

  /* Typography Colors (Adapts to Dark Theme) */
  --text-main: #e2e8f0;     /* Light Slate */
  --text-muted: #94a3b8;
  --text-bold: #f8fafc;     /* Near White */
  --heading-color: #f8fafc;
  --link-color: #60a5fa;    /* Light Blue */

  --code-inline-bg: #1e293b;
  --code-inline-text: #f472b6;
}

/* ==========================================================================
   2. Base & Typography
   ========================================================================== */
html { scroll-padding-top: 80px; }
*, ::before, ::after { box-sizing: border-box; }

body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.65;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Tighter Headings */
h1, h2, h3, h4, h5, h6 {
  color: var(--heading-color);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.5rem;
}

h1 { font-size: 2.5rem; margin-top: 1em; letter-spacing: -0.02em; }
h2 { font-size: 1.875rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; margin-top: 2em; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }

h6 {
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ASCIIDOCTOR FIX: Pull subheadings closer */
.sectionbody > .sect2:first-child > h3,
.sect2 > .sect3:first-child > h4,
.sect3 > .sect4:first-child > h5 {
  margin-top: 0.75em;
}

p, table, blockquote { margin-top: 0; margin-bottom: 1.25rem; }

strong, b { font-weight: 600; color: var(--text-bold); }

a {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}
a:hover { text-decoration: underline; color: var(--jooby-blue-hover); }

hr { border: none; border-bottom: 1px solid var(--border-color); margin: 2rem 0; }

/* ASCIIDOCTOR FIX: Fix bloated lists */
ul, ol, dl { margin-top: 0; margin-bottom: 1rem; }
li { margin-bottom: 0.35rem; }
.ulist li p, .olist li p, .dlist li p { margin-bottom: 0; }

/* ==========================================================================
   3. Main Content Layout
   ========================================================================== */
#header { padding: 0; margin: 0; }

@media screen and (min-width: 768px) {
  body.toc2 { padding-left: var(--sidebar-width); }
  #content, #footer {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 2.5rem 3rem;
  }
}

@media screen and (max-width: 767px) {
  #content, #footer { padding: 1.5rem; }
}

#content > *:first-child,
#content > #preamble:first-child .sectionbody > *:first-child {
  margin-top: 0 !important;
}

/* ==========================================================================
   4. Table of Contents (Left Sidebar)
   ========================================================================== */
@media screen and (min-width: 768px) {
  #toc.toc2 {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 2.5rem 1.5rem;
    z-index: 1000;
  }
}

@media (max-width: 767px) { #toc.toc2 { display: none; } }

#toctitle {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--heading-color);
  margin-top: 0;
  margin-bottom: 1.2rem;
  padding-left: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#toc ul { list-style: none; margin: 0; padding: 0; font-family: inherit; }
#toc ul ul { display: none; padding-left: 1.1rem; border-left: 1px solid var(--border-color); margin: 0.2rem 0; }
#toc li.expanded > ul { display: block !important; }

#toc a {
  display: block;
  padding: 0.35rem 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.4;
  border-left: 3px solid transparent;
  transition: all 0.15s ease-in-out;
  word-break: break-word;
}

#toc a:hover { color: var(--jooby-blue); text-decoration: none; }
#toc a.active {
  color: var(--jooby-blue) !important;
  font-weight: 600;
  border-left-color: var(--jooby-blue);
  padding-left: 0.8rem;
  background-color: rgba(33, 150, 243, 0.04);
}

#toc::-webkit-scrollbar { width: 5px; }
#toc::-webkit-scrollbar-track { background: transparent; }
#toc::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 10px; }
#toc::-webkit-scrollbar-thumb:hover { background: #cccccc; }
html[data-theme="dark"] #toc::-webkit-scrollbar-thumb { background: #475569; }
html[data-theme="dark"] #toc::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ==========================================================================
   5. Admonitions (Callouts)
   ========================================================================== */
.admonitionblock { margin-bottom: 1.5rem; }

.admonitionblock > table,
.admonitionblock > table > tbody,
.admonitionblock > table > tbody > tr {
  display: flex;
  width: 100%;
}

.admonitionblock > table {
  background: var(--admonition-bg, var(--bg-callout));
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  border-left: 4px solid var(--admonition-color, var(--jooby-blue));
  padding: 1.25rem;
}

.admonitionblock td.icon {
  border: none;
  padding: 0;
  padding-right: 1.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
}

.admonitionblock td.icon .title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  color: var(--admonition-color, var(--jooby-blue));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admonitionblock td.content {
  border: none;
  padding: 0;
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.6;
}

.admonitionblock td.content p:last-child { margin-bottom: 0; }

/* Variants */
.admonitionblock.note { --admonition-color: var(--jooby-blue); --admonition-bg: rgba(33, 150, 243, 0.05); }
.admonitionblock.note td.icon .title::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%232196f3" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>'); display: block; width: 16px; height: 16px; }

.admonitionblock.tip { --admonition-color: #10b981; --admonition-bg: rgba(16, 185, 129, 0.05); }
.admonitionblock.tip td.icon .title::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2310b981" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>'); display: block; width: 16px; height: 16px; }

.admonitionblock.warning { --admonition-color: #f59e0b; --admonition-bg: rgba(245, 158, 11, 0.05); }
.admonitionblock.warning td.icon .title::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23f59e0b" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>'); display: block; width: 16px; height: 16px; }

.admonitionblock.important { --admonition-color: #ef4444; --admonition-bg: rgba(239, 68, 68, 0.05); }
.admonitionblock.important td.icon .title::before { content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23ef4444" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>'); display: block; width: 16px; height: 16px; }

/* ==========================================================================
   6. Code Blocks & Inline Code
   ========================================================================== */
pre.highlightjs, .highlightjs code {
  background: var(--code-bg) !important;
}

pre {
  position: relative;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1rem 1.25rem;
  border-radius: var(--border-radius);
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: -0.01em;
  margin-top: 0;
  margin-bottom: 1rem;
}

:not(pre) > code {
  font-family: var(--font-code);
}

pre code, pre .hljs {
  color: var(--code-text);
  background: transparent !important;
  padding: 0 !important;
  font-size: inherit;
}

/* Style the Title as a Mac/IDE File Tab */
.listingblock .title {
  background-color: #21252b;
  color: #abb2bf;
  font-family: var(--font-code);
  font-size: 0.78rem;
  padding: 0.5rem 1.25rem;
  margin-bottom: 0;
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  border-bottom: 1px solid rgba(0, 0, 0, 0.4);
  display: block;
}

.listingblock .title + .content pre {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: 0;
}

/* ==========================================================================
   7. Custom UI: Tabs (Switch) & Clipboard
   ========================================================================== */
.hidden { display: none !important; }
.primary > .title { display: none; }

.switch {
  display: flex;
  background-color: var(--code-bg);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 0;
}

.switch--item {
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  background-color: var(--code-bg);
  transition: all 0.2s ease;
  user-select: none;
}

.switch--item:hover { color: #fff; background-color: #444; }
.switch--item.selected {
  color: var(--jooby-accent);
  background-color: #222;
  box-shadow: inset 0 -2px 0 var(--jooby-accent);
}

.primary .content pre {
  margin-top: 0 !important;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.clipboard {
  position: absolute;
  top: 0.5rem !important;
  right: 0.5rem !important;
  bottom: auto !important;
  height: 32px;
  width: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  opacity: 0;
}

pre:hover .clipboard { opacity: 1; }
.clipboard:hover { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.4); }
.clipboard:active { background: rgba(255, 255, 255, 0.3); }
.clipboard img { filter: invert(1); opacity: 0.8; height: 16px; width: 16px; }

/* ==========================================================================
   8. Theme Toggle Button Styles
   ========================================================================== */
.theme-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 1001;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
  border-color: var(--jooby-blue);
  color: var(--jooby-blue);
}

.theme-toggle svg { width: 22px; height: 22px; fill: currentColor; }
.theme-toggle .moon-icon { display: none; }
html[data-theme="dark"] .theme-toggle .moon-icon { display: block; }
html[data-theme="dark"] .theme-toggle .sun-icon { display: none; }

/* ==========================================================================
   9. Header Anchor Links (Deep Linking)
   ========================================================================== */
h2, h3, h4, h5, h6 { position: relative; }

h2 > a.anchor, h3 > a.anchor, h4 > a.anchor, h5 > a.anchor, h6 > a.anchor {
  position: absolute;
  left: -1.5rem;
  top: 0;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: var(--text-muted);
  font-weight: 400;
}

h2 > a.anchor::before, h3 > a.anchor::before, h4 > a.anchor::before, h5 > a.anchor::before, h6 > a.anchor::before {
  content: "#";
}

h2:hover > a.anchor, h3:hover > a.anchor, h4:hover > a.anchor, h5:hover > a.anchor, h6:hover > a.anchor { opacity: 1; }
h2 > a.anchor:hover, h3 > a.anchor:hover, h4 > a.anchor:hover, h5 > a.anchor:hover, h6 > a.anchor:hover { color: var(--jooby-blue); }

h2 > a.anchor.copied::before, h3 > a.anchor.copied::before, h4 > a.anchor.copied::before,
h5 > a.anchor.copied::before, h6 > a.anchor.copied::before {
  content: "✓"; color: #10b981;
}

/* ==========================================================================
   10. Hero Section (Preamble)
   ========================================================================== */
#preamble .sectionbody > h2.discrete {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 0;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--jooby-blue) 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#preamble .sectionbody > .paragraph:first-of-type p {
  font-size: 1.25rem;
  color: var(--text-muted);
  max-width: 800px;
  line-height: 1.7;
}

/* ==========================================================================
   11. Miscellaneous Badges
   ========================================================================== */
.badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  font-size: 0.75em;
  font-weight: 700;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 0.5em;
}

.badge.experimental { background: #f59e0b; color: #fff; }
.badge.deprecated { background: #ef4444; color: #fff; }
.badge.new { background: #10b981; color: #fff; }

/* ==========================================================================
   12. Callouts (Code Pointers & Lists)
   ========================================================================== */
pre.highlightjs code { opacity: 0; transition: opacity 0.05s ease-out; }
pre.highlightjs.badges-loaded code { opacity: 1; }

.conum-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background-color: var(--code-inline-text);
  color: #ffffff !important;
  font-size: 0.85rem;
  font-weight: 700;
  font-style: normal;
  flex-shrink: 0;
}

.colist.arabic ol {
  list-style: none !important;
  padding-left: 0;
  margin-top: 1.5rem;
  counter-reset: colist-counter;
}

.colist.arabic li {
  margin-bottom: 1.25rem;
  counter-increment: colist-counter;
  position: relative;
  padding-left: 2.5rem;
  min-height: 1.5rem;
}

.colist.arabic li::before {
  content: counter(colist-counter);
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background-color: var(--text-main);
  color: var(--bg-main);
  font-size: 0.85rem;
  font-weight: 700;
}

.colist.arabic li > *:first-child { display: block; margin-top: 0; }
.colist.arabic li p { margin-bottom: 0.5rem; line-height: 1.5rem; }

.colist.arabic li .ulist { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.colist.arabic li .ulist ul { list-style: disc; padding-left: 1.25rem; margin: 0; }
.colist.arabic li .ulist li { padding-left: 0; margin-bottom: 0.25rem; counter-increment: none; }
.colist.arabic li .ulist li::before { content: none; }

.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}

/* ==========================================================================
   13. Tables
   ========================================================================== */
table.tableblock {
  width: 100%;
  table-layout: fixed !important;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}

table.tableblock td, table.tableblock th {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  line-height: 1.6;
  text-align: left;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

table.tableblock thead th {
  background-color: var(--bg-surface);
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
  color: var(--heading-color);
  white-space: nowrap;
}

table.tableblock:not(:has(colgroup col[style*="width"])) td:first-child {
  white-space: nowrap;
  width: 1%;
}

table.tableblock td:first-child { font-weight: 500; color: var(--heading-color); }
table.tableblock td p { margin: 0; }
table.tableblock td p + p { margin-top: 0.5rem; }
table.tableblock tbody tr:hover { background-color: var(--bg-callout); }
table.tableblock tbody tr:last-child td { border-bottom: none; }

/* ==========================================================================
   14. Keyboard Shortcuts (kbd)
   ========================================================================== */
kbd {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-family: var(--font-code);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 0 0 2px var(--bg-main);
  margin: 0 0.15rem;
  vertical-align: middle;
  line-height: 1.2;
}

/* ==========================================================================
   15. Responsive / Mobile Adjustments
   ========================================================================== */

/* Hidden elements on Desktop */
.mobile-nav-bar { display: none; }

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1001;
}

.hamburger span {
  width: 2rem;
  height: 0.25rem;
  background: var(--text-main);
  border-radius: 10px;
  transition: all 0.3s linear;
}

/* Animate Hamburger to X */
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(7px, -6px); }

@media screen and (max-width: 768px) {
  /* Mobile Header Top Bar */
  #header { padding-top: 4rem !important; }

  .mobile-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3.5rem;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    z-index: 10001;
  }

  .hamburger { display: flex; }
  #menu-toggle { position: static !important; margin-left: auto; }

  /* Slide-out Sidebar Menu */
  #toc, .nav-container, #sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -100% !important;
    width: 80% !important;
    max-width: 300px !important;
    height: 100vh !important;
    background-color: var(--bg-main) !important;
    z-index: 9999 !important;
    transition: left 0.3s ease-in-out !important;
    display: block !important;
    box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    padding: 4rem 1rem 2rem 1rem !important; /* Spaced to clear nav bar */
    overflow-y: auto !important;
  }

  #toc.active, .nav-container.active, #sidebar.active { left: 0 !important; }

  /* Mobile Tables */
  .tableblock {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table.tableblock td:first-child { white-space: normal !important; min-width: 120px; }
  table.tableblock th, table.tableblock td { padding: 0.5rem 0.75rem !important; font-size: 0.85rem; }
}

/* ==========================================================================
   16. Print Styles (Ink-Friendly PDF)
   ========================================================================== */
@media print {
  body { background: white !important; color: black !important; font-size: 11pt; }
  #header, #footer, #sidebar, .nav-container, .edit-link, .mobile-nav-bar, .theme-toggle, .clipboard, .switch { display: none !important; }
  #content { width: 100% !important; margin: 0 !important; padding: 0 !important; }
  body.toc2, #header, #footer { padding: 0 !important; max-width: 100% !important; }

  pre {
    background: #f5f5f5 !important;
    color: #333 !important;
    border: 1px solid #ddd !important;
    page-break-inside: avoid;
  }
  pre code { color: #333 !important; }

  table.tableblock { border: 1px solid #999 !important; page-break-inside: auto; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  h2, h3, h4, h5 { page-break-after: avoid; }
  pre, blockquote, img { page-break-inside: avoid; }

  a[href^="http"]:after { content: " (" attr(href) ")"; font-size: 90%; color: #666; }
  #content a[href^="#"]::after { content: ""; }
}

/* ==========================================================================
   18. Algolia DocSearch Overrides
   ========================================================================== */

/* Light Theme (Default) */
:root {
  --docsearch-primary-color: var(--jooby-blue);
  --docsearch-highlight-color: var(--jooby-blue);
  --docsearch-text-color: var(--text-main);
  --docsearch-muted-color: var(--text-muted);
  --docsearch-searchbox-shadow: inset 0 0 0 2px var(--jooby-blue);
  --docsearch-searchbox-focus-background: var(--bg-main);
}

/* Dark Theme Overrides */
html[data-theme="dark"] {
  --docsearch-text-color: var(--text-main);
  --docsearch-container-background: rgba(15, 23, 42, 0.85); /* Slightly darker backdrop */
  --docsearch-modal-background: var(--bg-surface);
  --docsearch-modal-shadow: inset 1px 1px 0 0 #334155, 0 8px 24px 0 rgba(0,0,0,0.5);
  --docsearch-searchbox-background: var(--bg-main);
  --docsearch-searchbox-focus-background: var(--bg-main);
  --docsearch-hit-color: var(--text-muted);
  --docsearch-hit-active-color: var(--bg-main);
  --docsearch-hit-background: var(--bg-main);
}

/* --- Seamless Button Integration --- */

/* Force the button to fit your sidebar perfectly */
.DocSearch-Button {
  border-radius: var(--border-radius) !important;
  background: var(--bg-main) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: none !important;
  color: var(--text-muted) !important;
  transition: all 0.2s ease;
  width: 100% !important; /* Stretch to fill sidebar */
  margin: 0 0 1.5rem 0 !important; /* Space below the button */
  padding: 0 10px !important;
  justify-content: flex-start !important; /* Align "Search" to the left */
}

/* Push the keyboard shortcut to the right edge */
.DocSearch-Button-Keys {
  margin-left: auto !important;
  min-width: auto !important;
}

.DocSearch-Button:hover {
  border-color: var(--jooby-blue) !important;
  color: var(--jooby-blue) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

/* --- Keyboard Shortcut Keys (kbd) --- */
.DocSearch-Button-Keys kbd {
  font-family: var(--font-code);
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-muted) !important;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 0 0 2px var(--bg-main) !important;
  border-radius: 4px !important;
  padding: 0.1rem 0.3rem !important;
  width: auto !important;
  height: auto !important;
}

/* Brighten the keys explicitly in Dark Mode */
html[data-theme="dark"] .DocSearch-Button-Keys kbd {
  color: #e2e8f0 !important;
  background: #334155 !important;
}

