/* Layout Structure */
.layout-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.site-header {
  height: var(--header-height);
  background: var(--color-bg-main);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-search {
  position: relative;
  width: 300px;
}

.header-search input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-muted);
  font-size: 0.875rem;
  transition: all 0.2s;
}

.header-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-bg-main);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.header-search .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  width: 16px;
  height: 16px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--color-text-main);
}

/* Main Layout */
.main-layout {
  display: flex;
  flex: 1;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Left Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  padding: 2rem 1.5rem;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  background: var(--color-bg-main);
}

.nav-group {
  margin-bottom: 1.5rem;
}

.nav-group-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-main);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.nav-list li {
  margin-bottom: 0.25rem;
}

.nav-link {
  display: block;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--color-bg-muted);
  color: var(--color-text-main);
}

.nav-link.active {
  background: rgba(79, 70, 229, 0.1);
  color: var(--color-primary);
  font-weight: 500;
}

/* Content Area */
.content-area {
  flex: 1;
  padding: 3rem;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.content-inner {
  width: 100%;
  max-width: var(--content-max-width);
}

/* Right TOC */
.toc-sidebar {
  width: var(--toc-width);
  flex-shrink: 0;
  padding: 2rem 1.5rem;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
}

.toc-list li {
  margin-bottom: 0.5rem;
}

.toc-link {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.2s;
  display: block;
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--color-text-main);
}

.toc-link.active {
  color: var(--color-primary);
  font-weight: 500;
}

.toc-h3 {
  padding-left: 1rem;
  font-size: 0.8125rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .toc-sidebar {
    display: none;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 40;
    transition: left 0.3s ease;
    width: 280px;
  }
  
  .sidebar.is-open {
    left: 0;
    box-shadow: var(--shadow-md);
  }

  .mobile-menu-btn {
    display: block;
  }

  .content-area {
    padding: 2rem 1.5rem;
  }

  .header-search {
    display: none; /* Can implement mobile search overlay later */
  }
}
