/* ==========================================
   GUIDE LAYOUT SYSTEM
   Loaded by all guide + category index pages
   ========================================== */

/* ----- Sidebar Toggle Button (mobile) ----- */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 200;
  background: var(--primary, #1e3a5f);
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: transform 0.2s;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle:hover { transform: scale(1.05); }

/* ----- Page Layout Grid ----- */
.guide-page-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  max-width: 1400px;
  margin: 0 auto;
  gap: 0;
  min-height: calc(100vh - 120px);
}

/* Three-column layout for pages with TOC */
.guide-page-layout.has-toc {
  grid-template-columns: 260px 1fr 200px;
}

/* ----- Left Sidebar ----- */
.guide-sidebar {
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
  overflow-y: auto;
  background: white;
  border-right: 1px solid #eee;
  padding: 1.5rem 0;
  z-index: 50;
  scrollbar-width: thin;
}
.guide-sidebar::-webkit-scrollbar { width: 4px; }
.guide-sidebar::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* Sidebar Category Groups */
.sidebar-category {
  margin-bottom: 0.25rem;
}

.sidebar-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}
.sidebar-category-header:hover { color: var(--primary, #1e3a5f); }
.sidebar-category-header .chevron {
  transition: transform 0.2s;
  font-size: 0.7rem;
}
.sidebar-category.expanded .sidebar-category-header .chevron {
  transform: rotate(90deg);
}
.sidebar-category.expanded .sidebar-category-header {
  color: var(--primary, #1e3a5f);
}

/* Sidebar Guide Links */
.sidebar-guide-list {
  list-style: none;
  display: none;
  padding: 0;
  margin: 0;
}
.sidebar-category.expanded .sidebar-guide-list {
  display: block;
}

.sidebar-guide-list li a {
  display: block;
  padding: 0.35rem 1.25rem 0.35rem 2rem;
  font-size: 0.85rem;
  color: #555;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  line-height: 1.4;
}
.sidebar-guide-list li a:hover {
  background: #f5f7fa;
  color: var(--primary, #1e3a5f);
}
.sidebar-guide-list li a.active {
  color: var(--secondary, #2d8a8a);
  border-left-color: var(--secondary, #2d8a8a);
  background: rgba(45, 138, 138, 0.08);
  font-weight: 500;
}

.sidebar-guide-list li.category-overview a {
  font-weight: 500;
  font-size: 0.8rem;
  color: #888;
}

/* ----- Main Content Area ----- */
.guide-main-content {
  min-width: 0;
}

.guide-main-content .article-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

.guide-main-content .breadcrumb-container {
  max-width: none;
}

/* ----- Right-side TOC (On This Page) ----- */
.guide-toc {
  position: sticky;
  top: 80px;
  height: fit-content;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 1.5rem 1rem 1.5rem 0;
  scrollbar-width: thin;
}

.guide-toc h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 0.75rem;
  padding-left: 1rem;
}

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

.guide-toc ul li a {
  display: block;
  padding: 0.3rem 1rem;
  font-size: 0.8rem;
  color: #666;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.4;
}
.guide-toc ul li a:hover {
  color: var(--primary, #1e3a5f);
}
.guide-toc ul li a.active {
  color: var(--secondary, #2d8a8a);
  border-left-color: var(--secondary, #2d8a8a);
}

/* ----- Prev/Next Navigation ----- */
.prev-next-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #eee;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

.prev-next-link {
  display: block;
  padding: 1rem 1.25rem;
  background: #f8f9fa;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
  border: 1px solid #eee;
}
.prev-next-link:hover {
  background: #eef1f5;
  transform: translateY(-2px);
}

.prev-next-link .pn-direction {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 0.25rem;
}

.prev-next-link .pn-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--primary, #1e3a5f);
}

.prev-next-link.next {
  text-align: right;
}
.prev-next-link.prev .pn-direction::before { content: "\2190 "; }
.prev-next-link.next .pn-direction::after { content: " \2192"; }

.prev-next-placeholder {
  /* empty spacer */
}

/* ----- Related Content Cards ----- */
.related-cards-section {
  margin-top: 2rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 2rem 2rem;
}

.related-cards-section h3 {
  color: var(--primary, #1e3a5f);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.related-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.related-card {
  background: white;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
}
.related-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
}
.related-card .rc-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary, #2d8a8a);
  margin-bottom: 0.25rem;
}
.related-card .rc-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--primary, #1e3a5f);
  margin-bottom: 0.25rem;
}
.related-card .rc-desc {
  font-size: 0.8rem;
  color: #666;
  line-height: 1.4;
}

/* ----- Responsive ----- */
@media (max-width: 1024px) {
  .guide-page-layout.has-toc {
    grid-template-columns: 260px 1fr;
  }
  .guide-toc {
    display: none;
  }
}

@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .guide-page-layout,
  .guide-page-layout.has-toc {
    grid-template-columns: 1fr;
  }

  .guide-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 300;
    transition: left 0.3s ease;
    box-shadow: none;
    border-right: none;
    padding-top: 1rem;
  }
  .guide-sidebar.open {
    left: 0;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 250;
  }
  .sidebar-overlay.active {
    display: block;
  }

  .guide-toc {
    display: none;
  }

  .guide-main-content .article-container {
    padding: 1.5rem 1rem;
  }

  .prev-next-nav {
    grid-template-columns: 1fr;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .related-cards-section {
    padding: 0 1rem 1.5rem;
  }
}
