/* ==========================================================================
   #ROOT VARIABLES & THEMES
   ========================================================================== */
:root {
  --nav-height: 60px;
  --sidebar-width: 260px;
  --primary: #007bff;
  --text: #333;
  --background: #fff;
  --border: #e0e0e0;
  --hover-bg: #f5f5f5;
  --sidebar-bg: #f8f9fa;
  --code-bg: #f1f1f1;
  --transition: all 0.3s ease;
  --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --primary: #4dabf7;
  --text: #e9ecef;
  --background: #121212;
  --border: #333;
  --hover-bg: #2a2a2a;
  --sidebar-bg: #1a1a1a;
  --code-bg: #252525;
  --shadow: rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   #BASE & TYPOGRAPHY
   ========================================================================== */
body {
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.7;
  margin: 0;
  transition: var(--transition);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text);
  font-weight: 700;
  margin: 1.5em 0 0.8em;
  line-height: 1.3;
}

h1 {
  font-size: 2.2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

h2 {
  font-size: 1.8rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

p {
  margin-bottom: 1.2rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary);
}

/* ==========================================================================
   #MAIN LAYOUT
   ========================================================================== */
.site-nav {
  position: sticky;
  top: 0;
  height: var(--nav-height);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 1000;
  transition: var(--transition);
}

.page-wrapper {
  display: flex;
}

.docs-sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--nav-height));
  position: sticky;
  top: var(--nav-height);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 2rem 1rem;
  overflow-y: auto;
}

.main-content {
  flex-grow: 1;
  padding: 2rem;
  max-width: 900px;
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
}

/* ==========================================================================
   #NAVIGATION
   ========================================================================== */
.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

.nav-brand a {
  font-weight: bold;
  font-size: 1.5rem;
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: var(--text);
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  text-decoration: none;
}

.nav-toggle {
  display: none; /* Hidden on desktop */
}

/* ==========================================================================
   #SIDEBAR
   ========================================================================== */
.docs-sidebar h3 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 1rem;
  color: var(--text);
}

.sidebar-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-toc a {
  display: block;
  padding: 0.4rem 0.8rem;
  color: var(--text);
  border-radius: 4px;
  font-size: 0.95rem;
}

.sidebar-toc a:hover {
  background: var(--hover-bg);
  text-decoration: none;
}

.sidebar-toc a.active {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}

.sidebar-toc .toc-h1 a {
  font-weight: 600;
}
.sidebar-toc .toc-h2 a {
  padding-left: 1.5rem;
}
.sidebar-toc .toc-h3 a {
  padding-left: 2.5rem;
  font-size: 0.9rem;
}

.no-toc {
  font-style: italic;
  color: #888;
}

.docs-sidebar-toggle {
  display: none;
}

/* ==========================================================================
   #CODE BLOCKS & INLINE CODE
   ========================================================================== */
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.5;
  font-size: 0.95em;
}

code {
  background: var(--code-bg);
  color: var(--primary);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.code-block-wrapper {
  position: relative;
}

.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--hover-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.code-block-wrapper:hover .code-copy-btn {
  opacity: 1;
}

/* ==========================================================================
   #THEME TOGGLE
   ========================================================================== */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text);
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  margin-left: 1rem;
  display: flex;
  align-items: center;
}

.theme-toggle:hover {
  background: var(--hover-bg);
}

/* ==========================================================================
   #RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1024px) {
  .page-wrapper {
    display: block;
  }

  .docs-sidebar,
  .docs-sidebar-toggle {
    display: none;
  }

  .main-content {
    max-width: none;
    padding: 1rem;
  }

  /* --- Mobile Navigation --- */
  .nav-toggle {
    display: block;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1100;
    width: 30px;
    height: 30px;
    position: relative;
  }

  .hamburger,
  .hamburger::before,
  .hamburger::after {
    content: '';
    display: block;
    background-color: var(--text);
    position: absolute;
    width: 100%;
    height: 3px;
    transition: all 0.3s ease-in-out;
  }

  .hamburger::before {
    top: -10px;
  }

  .hamburger::after {
    bottom: -10px;
  }

  .nav-toggle.active .hamburger {
    transform: rotate(45deg);
  }

  .nav-toggle.active .hamburger::before {
    top: 0;
    transform: rotate(90deg);
  }

  .nav-toggle.active .hamburger::after {
    bottom: 0;
    transform: rotate(90deg);
  }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    flex-direction: column;
    padding-top: 2rem;
    gap: 0;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 1rem 2rem;
    width: 100%;
    text-align: center;
    font-size: 1.2rem;
  }
}