.docs-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 80px);
  margin-top: 80px; /* Header height */
  background: var(--bg);
}

/* Sidebar */
.docs-sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 0; /* Changed to handle search container padding */
  height: calc(100vh - 80px);
  position: sticky;
  top: 80px;
  overflow-y: auto;
}

.docs-search-container {
  padding: 24px 24px 16px;
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
}

#docsSearch {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}

#docsSearch:focus {
  outline: none;
  border-color: var(--accent1);
}

.search-icon {
  position: absolute;
  right: 36px;
  color: var(--muted);
  font-size: 0.8rem;
  pointer-events: none;
}

#docs-nav {
  padding: 0 24px 24px;
}

.docs-no-results {
  color: var(--muted);
  padding: 20px;
  text-align: center;
  font-size: 0.9rem;
}

.docs-sidebar::-webkit-scrollbar {
  width: 4px;
}

.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.docs-nav-group {
  margin-bottom: 24px;
}

.docs-nav-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 700;
}

.docs-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.docs-nav-item {
  margin-bottom: 4px;
}

.docs-nav-link {
  display: block;
  padding: 8px 12px;
  color: var(--muted-strong);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  cursor: pointer;
}

.docs-nav-link:hover {
  background: var(--surface);
  color: var(--accent1);
}

.docs-nav-link.active {
  background: var(--surface-strong);
  color: var(--accent1);
  font-weight: 600;
  border-left: 2px solid var(--accent1);
}

/* Content Area */
.docs-content {
  padding: 48px;
  max-width: 900px;
  margin: 0 auto;
}

.docs-content-inner {
  animation: fadeIn 0.3s ease-out;
}

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

/* Markdown Styling */
.markdown-body {
  color: var(--text);
  line-height: 1.7;
}

.markdown-body h1 {
  font-size: 2.5rem;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
  font-size: 1.8rem;
  margin-top: 48px;
  margin-bottom: 20px;
  color: var(--accent2);
}

.markdown-body h3 {
  font-size: 1.3rem;
  margin-top: 32px;
  margin-bottom: 16px;
}

.markdown-body p {
  margin-bottom: 18px;
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 18px;
  padding-left: 24px;
}

.markdown-body li {
  margin-bottom: 8px;
}

.markdown-body code {
  background: var(--surface-strong);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--accent3);
}

.markdown-body pre {
  background: var(--bg-soft);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow-x: auto;
  margin-bottom: 24px;
  position: relative;
}

.docs-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
}

.markdown-body pre:hover .docs-copy-btn {
  opacity: 1;
}

.docs-copy-btn:hover {
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--accent1);
}

.docs-copy-btn.copied {
  color: var(--accent1);
  border-color: var(--accent1);
}

.markdown-body blockquote {
  border-left: 4px solid var(--accent1);
  padding: 12px 24px;
  background: rgba(0, 255, 204, 0.05);
  margin: 24px 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 12px;
  text-align: left;
}

.markdown-body th {
  background: var(--surface);
}

.docs-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--muted);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}

.error {
  color: #ff4d4d;
  padding: 20px;
  background: rgba(255, 77, 77, 0.1);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 77, 77, 0.2);
}

/* Responsive */
@media (max-width: 900px) {
  .docs-container {
    grid-template-columns: 1fr;
    margin-top: 60px; /* Reduced for mobile */
  }

  .docs-sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    z-index: 2000;
    width: 280px;
    height: 100vh;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    display: block; /* Overriding previous display: none */
  }

  .docs-sidebar.active {
    transform: translateX(280px);
  }

  .docs-content {
    padding: 80px 20px 40px;
  }

  /* Mobile Toggle Button */
  .docs-mobile-toggle {
    display: flex;
    position: fixed;
    bottom: 24px;
    left: 24px; /* Moved to left side to avoid AI chat bubble */
    z-index: 2100;
    width: 56px;
    height: 56px;
    background: var(--accent1);
    border: none;
    border-radius: 50%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(0, 255, 204, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .docs-mobile-toggle:active {
    transform: scale(0.9);
  }

  .docs-mobile-toggle span {
    width: 24px;
    height: 2px;
    background: #041018;
    border-radius: 2px;
    transition: all 0.3s ease;
  }

  .docs-mobile-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .docs-mobile-toggle.active span:nth-child(2) { opacity: 0; }
  .docs-mobile-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* Backdrop */
  .docs-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1900;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .docs-backdrop.active {
    display: block;
    opacity: 1;
  }
}

@media (min-width: 901px) {
  .docs-mobile-toggle, .docs-backdrop {
    display: none !important;
  }
}
