@import url('css/base.css');
@import url('css/components.css');

/* ===== Header ===== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-default);
  z-index: 100;
  display: flex;
  align-items: center;
}

.site-header-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.site-title a {
  color: inherit;
}

.site-title a:hover {
  text-decoration: none;
  color: var(--accent-primary);
}

.site-nav {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.site-nav a {
  color: var(--text-secondary);
}

.site-nav a:hover {
  color: var(--text-primary);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-primary);
}

.hamburger svg {
  width: 20px;
  height: 20px;
}

/* ===== Layout Grid ===== */
.doc-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width-left) 1fr var(--sidebar-width-right);
  max-width: 1400px;
  margin: 0 auto;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* ===== Left Sidebar ===== */
.doc-sidebar-left {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  border-right: 1px solid var(--border-light);
  padding: 16px 0;
  font-size: 13px;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.sidebar-section-title:hover {
  background: var(--bg-secondary);
}

.sidebar-toggle-icon {
  display: inline-block;
  width: 12px;
  text-align: center;
  font-size: 10px;
  color: var(--text-tertiary);
  transition: transform 0.15s;
}

.sidebar-section.collapsed .sidebar-toggle-icon {
  transform: rotate(-90deg);
}

.sidebar-section.collapsed .sidebar-pages {
  display: none;
}

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

.sidebar-pages li a {
  display: block;
  padding: 5px 16px 5px 34px;
  color: var(--text-secondary);
  font-size: 13px;
  border-left: 2px solid transparent;
  line-height: 1.5;
}

.sidebar-pages li a:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
  text-decoration: none;
}

.sidebar-pages li a.active {
  color: var(--text-primary);
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
  font-weight: 500;
}

/* ===== Main Content ===== */
.doc-content {
  padding: 24px 32px 48px;
  min-width: 0;
}

/* ===== Right Sidebar (TOC) ===== */
.doc-sidebar-right {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  border-left: 1px solid var(--border-light);
  padding: 20px 16px;
  font-size: 12px;
}

.toc-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin: 0 0 10px;
}

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

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 4px 0;
  color: var(--text-secondary);
  line-height: 1.45;
}

.toc-list a:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

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

.toc-list .toc-h3 {
  padding-left: 12px;
}

/* ===== Back to top ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 90;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

/* ===== Mobile overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ===== Responsive ===== */
@media (max-width: 1023px) {
  .doc-layout {
    grid-template-columns: var(--sidebar-width-left) 1fr;
  }

  .doc-sidebar-right {
    display: none;
  }
}

@media (max-width: 767px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }

  .doc-sidebar-left {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: 260px;
    height: calc(100vh - var(--header-height));
    background: var(--bg-primary);
    border-right: 1px solid var(--border-default);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 101;
  }

  .doc-sidebar-left.open {
    transform: translateX(0);
  }

  .doc-sidebar-right {
    display: none;
  }

  .doc-content {
    padding: 16px;
  }

  .hamburger {
    display: block;
  }

  .info-table th,
  .info-table td {
    display: block;
    width: 100%;
  }

  .info-table th {
    border-bottom: none;
    padding-bottom: 4px;
  }

  .info-table td {
    padding-top: 4px;
  }

  .info-table tr {
    display: block;
    margin-bottom: 10px;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    overflow: hidden;
  }
}
