/* ==========================================================================
   PILLOW PYTHON - DOCUMENTATION STYLES
   Adds sidebar layout, scrollspy, and doc-specific overrides to base styles
   ========================================================================== */

/* Layout */
.doc-layout {
  display: flex;
  margin-top: 60px; /* Offset for fixed navbar */
  min-height: calc(100vh - 60px);
}

/* Sidebar (Left) */
.doc-sidebar {
  width: 260px;
  background: var(--bg-color);
  border-right: 1px solid var(--surface-border);
  padding: 2rem 1.25rem;
  position: fixed;
  left: 0;
  height: calc(100vh - 60px);
  overflow-y: auto;
  z-index: 90;
}

.doc-sidebar-category {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem;
}

.doc-sidebar-category:first-child {
  margin-top: 0;
}

.doc-sidebar-link, .doc-toc-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  color: var(--text-secondary);
  border-radius: 6px;
  font-size: 0.85rem;
  transition: var(--transition);
  text-decoration: none;
  font-weight: 500;
}

/* Visual indentation for sub-modules */
.doc-sidebar .reference-link {
    margin-left: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.85;
}

.doc-sidebar-link:hover, .doc-toc-link:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.doc-sidebar-link.active, .doc-toc-link.active {
  background: white;
  color: var(--neon-blue);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

/* TOC Panel (Right) */
.doc-toc {
  width: 240px;
  padding: 2.5rem 1.5rem;
  position: fixed;
  right: 0;
  height: calc(100vh - 60px);
  overflow-y: auto;
  z-index: 80;
  border-left: 1px solid var(--surface-border);
}

.doc-toc-container {
  position: sticky;
  top: 0;
}

/* Main Content Area */
.doc-content {
  flex: 1;
  margin-left: 260px; /* offset for left sidebar */
  margin-right: 240px; /* offset for right toc */
  padding: 3rem 2.5rem;
  min-width: 0; /* prevent flex overflow */
  overflow-x: hidden;
  width: 100%;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.breadcrumbs span {
  color: var(--text-secondary);
}

/* Document Sections */
.doc-section {
  scroll-margin-top: 100px;
  margin-bottom: 4rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--surface-border);
  word-wrap: break-word;
}

.doc-section:last-of-type {
  border-bottom: none;
}

.doc-section h1 { font-size: clamp(2rem, 5vw, 2.75rem); margin-bottom: 1.5rem; letter-spacing: -0.02em; line-height: 1.1; }
.doc-section h2 { font-size: clamp(1.5rem, 4vw, 2rem); color: var(--text-primary); margin-bottom: 1.25rem; font-weight: 700; }
.doc-section h3 { font-size: 1.25rem; color: var(--text-primary); margin-top: 2rem; margin-bottom: 1rem; }

.doc-section p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.7;
  font-size: 1.05rem;
}

.doc-tldr {
  background: rgba(99, 102, 241, 0.03);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 3rem;
}

.doc-tldr h4 {
  color: var(--text-primary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.doc-tldr ul { list-style: none; padding: 0; }
.doc-tldr li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.doc-tldr li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--neon-blue);
  font-weight: bold;
}

/* Mobile Sidebar Toggle */
.mobile-sidebar-toggle {
  display: none;
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--bg-color);
  border-bottom: 1px solid var(--surface-border);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  position: sticky;
  top: 60px;
  z-index: 99;
  cursor: pointer;
}

.mobile-sidebar-toggle::after {
  content: "▾";
  float: right;
}

/* Documentation Tables */
.doc-table-wrapper {
  overflow-x: auto;
  margin: 2.5rem 0;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background: var(--surface);
  font-size: 0.9rem;
  min-width: 500px;
}

.doc-table th, .doc-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--surface-border);
}

.doc-table th {
  background: var(--surface-hover);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.doc-table td { color: var(--text-secondary); }
.doc-table td code {
  background: var(--bg-color);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  color: var(--neon-purple);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
}

/* Responsive */
@media (max-width: 1200px) {
  .doc-toc { display: none; }
  .doc-content { margin-right: 0; }
}

@media (max-width: 900px) {
  .doc-layout { flex-direction: column; margin-top: 60px; }
  .mobile-sidebar-toggle { display: block; border-top: 1px solid var(--surface-border); }

  .doc-sidebar {
    position: fixed; top: 110px; left: 0; width: 100%; height: auto;
    max-height: 0; overflow: hidden; padding: 0 1.5rem;
    border-right: none; border-bottom: 1px solid var(--surface-border);
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-color);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  }
  
  .doc-sidebar.active {
    max-height: 85vh; padding: 2rem 1.5rem; overflow-y: auto;
  }

  .doc-content {
    margin-left: 0; padding: 2rem 1.25rem;
  }
  
  .doc-section { margin-bottom: 3rem; }
  .doc-table-wrapper { margin: 1.5rem 0; }
}

@media (max-width: 600px) {
    .doc-content { padding: 1.5rem 1rem; }
    .doc-section h1 { margin-bottom: 0.75rem; }
    .doc-section p { font-size: 1rem; }
    .doc-tldr { padding: 1rem; }
    .breadcrumbs { margin-bottom: 1.5rem; }
}
