/* Documentation Layout Styles
 * Building on design-system.css for consistent design
 * ============================================================================ */

/* Ensure all required CSS variables are available */
:root {
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.16), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
}

/* ============================================================================
 * Reset and Base Styles for Documentation Pages
 * ============================================================================ */

/* Override global link styles for documentation pages */
.docs-layout a:not(.btn):not(.nav-link):not(.link-card),
.docs-content a:not(.btn):not(.nav-link):not(.link-card),
.docs-body a:not(.btn):not(.nav-link):not(.link-card) {
  color: var(--color-primary) !important;
  text-decoration: none !important;
  border-bottom: 1px solid transparent;
  transition: all var(--transition-fast);
}

.docs-layout a:not(.btn):not(.nav-link):not(.link-card):hover,
.docs-content a:not(.btn):not(.nav-link):not(.link-card):hover,
.docs-body a:not(.btn):not(.nav-link):not(.link-card):hover {
  color: var(--color-lavender) !important;
  border-bottom-color: var(--color-lavender) !important;
  text-decoration: none !important;
}

/* ============================================================================
 * Documentation Layout
 * ============================================================================ */
.docs-layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) 1fr;
  gap: var(--space-8);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  min-height: calc(100vh - 200px);
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

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

/* ============================================================================
 * Documentation Sidebar
 * ============================================================================ */
.docs-sidebar {
  height: fit-content;
  overflow: visible;
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(69, 71, 90, 0.5) 100%);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  border: 2px solid var(--color-surface1);
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 320px;
}

@media (max-width: 1024px) {
  .docs-sidebar {
    width: 100%;
    margin-bottom: var(--space-8);
  }
}

.docs-sidebar-header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-surface1);
}

.docs-sidebar-header h3 {
  font-size: var(--font-size-xl);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

/* Documentation Search */
.docs-search {
  position: relative;
}

.docs-search input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  padding-right: var(--space-10);
  background: var(--bg-tertiary);
  border: 2px solid var(--color-surface1);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
}

.docs-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.1);
}

.docs-search input::placeholder {
  color: var(--text-muted);
}

.docs-search::after {
  content: '🔍';
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.5;
}

/* Documentation Navigation */
.docs-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.docs-nav-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.docs-nav-section h4 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}

.docs-nav-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.docs-nav-section a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
  position: relative;
  border: 1px solid transparent;
}

.docs-nav-section a:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transform: translateX(4px);
}

.docs-nav-section a.current {
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(137, 180, 250, 0.1) 100%);
  color: var(--color-primary);
  font-weight: var(--font-medium);
  border-color: var(--color-primary);
}

.docs-nav-section a.current::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
}

.docs-nav-section a.adr-link {
  background: var(--bg-tertiary);
  border: 1px solid var(--color-surface1);
  font-weight: var(--font-medium);
  color: var(--color-primary);
}

.docs-nav-section a.adr-link:hover {
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(137, 180, 250, 0.1) 100%);
  border-color: var(--color-primary);
}

.external-link {
  font-size: var(--font-size-xs);
  opacity: 0.7;
  margin-left: var(--space-1);
}

/* ============================================================================
 * Documentation Main Content
 * ============================================================================ */
.docs-main {
  min-width: 0;
}

.docs-content {
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(69, 71, 90, 0.2) 100%);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  border: 2px solid var(--color-surface1);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.docs-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    var(--color-blue) 0%,
    var(--color-lavender) 50%,
    var(--color-mauve) 100%);
}

.docs-header {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-8);
  border-bottom: 2px solid var(--color-surface1);
}

.docs-header h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  line-height: var(--line-height-tight);
}

.docs-description {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
}

/* Documentation Body Content */
.docs-body {
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  line-height: var(--line-height-relaxed);
  color: var(--text-primary);
  max-width: 100%;
  word-wrap: break-word;
}

/* Ensure base text styles apply to all documentation content */
.docs-content {
  font-family: var(--font-sans);
  color: var(--text-primary);
}

/* Apply consistent styles to raw content */
.docs-content:not(:has(.docs-body)) {
  font-size: var(--font-size-md);
  line-height: var(--line-height-relaxed);
  color: var(--text-primary);
}

/* Fallback styles for main content areas */
main h1,
main h2,
main h3,
main h4,
main h5,
main h6 {
  color: var(--text-primary);
  line-height: var(--line-height-tight);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
}

main p {
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-6);
}

main ul,
main ol {
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  padding-left: var(--space-8);
}

main pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--color-surface1);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin: var(--space-6) 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  display: block;
  tab-size: 2;
}

main code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--color-green);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

main pre code {
  background: transparent;
  padding: 0;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  display: block;
  tab-size: 2;
}

.docs-body > h1:first-child,
.docs-body > h1:first-of-type {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-bold);
  margin-top: 0;
  margin-bottom: var(--space-8);
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-lavender) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-fill-color: transparent;
}

.docs-body h1,
.docs-content h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-bold);
  margin-top: var(--space-12);
  margin-bottom: var(--space-6);
  color: var(--text-primary);
  line-height: var(--line-height-tight);
}

.docs-body h2,
.docs-content h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-semibold);
  margin-top: var(--space-10);
  margin-bottom: var(--space-6);
  color: var(--color-primary);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-surface1);
  position: relative;
  padding-left: var(--space-8);
  line-height: var(--line-height-snug);
}

.docs-body h2::before,
.docs-content h2::before {
  content: '§';
  position: absolute;
  left: 0;
  color: var(--color-lavender);
  font-weight: var(--font-bold);
  opacity: 0.5;
}

.docs-body h3,
.docs-content h3 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-semibold);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  color: var(--text-primary);
  position: relative;
  padding-left: var(--space-6);
  line-height: var(--line-height-snug);
}

.docs-body h3::before,
.docs-content h3::before {
  content: '▪';
  position: absolute;
  left: 0;
  color: var(--color-primary);
  opacity: 0.7;
}

.docs-body h4,
.docs-content h4 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-medium);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  color: var(--text-primary);
  line-height: var(--line-height-snug);
}

.docs-body p,
.docs-content p {
  margin-bottom: var(--space-6);
  color: var(--text-secondary);
  font-size: var(--font-size-md);
  line-height: var(--line-height-relaxed);
}

.docs-body ul,
.docs-body ol,
.docs-content ul,
.docs-content ol {
  margin-bottom: var(--space-6);
  padding-left: var(--space-8);
  list-style: none;
}

.docs-body li,
.docs-content li {
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
  font-size: var(--font-size-md);
  position: relative;
}

.docs-body ul li::before,
.docs-content ul li::before {
  content: '▸';
  position: absolute;
  left: calc(var(--space-8) * -1 + var(--space-2));
  color: var(--color-primary);
  font-weight: var(--font-bold);
}

.docs-body ol,
.docs-content ol {
  counter-reset: docs-counter;
}

.docs-body ol li::before,
.docs-content ol li::before {
  counter-increment: docs-counter;
  content: counter(docs-counter) ".";
  position: absolute;
  left: calc(var(--space-8) * -1 + var(--space-2));
  color: var(--color-primary);
  font-weight: var(--font-semibold);
}

.docs-body a,
.docs-content a {
  color: var(--color-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
  border-bottom: 1px solid transparent;
  font-weight: var(--font-medium);
}

.docs-body a:hover,
.docs-content a:hover {
  color: var(--color-lavender);
  border-bottom-color: var(--color-lavender);
}

/* Code blocks in documentation */
.docs-body pre,
.docs-content pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--color-surface1);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin: var(--space-6) 0;
  overflow-x: auto;
  position: relative;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  word-wrap: break-word;
  display: block;
  tab-size: 2;
}

.docs-body code,
.docs-content code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--color-green);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-surface0);
}

.docs-body pre code,
.docs-content pre code {
  background: transparent;
  padding: 0;
  color: var(--text-primary);
  border: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  display: block;
  tab-size: 2;
}

/* Tables in documentation */
.docs-body table,
.docs-content table {
  width: 100%;
  margin: var(--space-6) 0;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-surface1);
}

.docs-body th,
.docs-content th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  text-align: left;
  padding: var(--space-4);
  border-bottom: 2px solid var(--color-surface1);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.docs-body td,
.docs-content td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-surface0);
  color: var(--text-secondary);
  font-size: var(--font-size-md);
}

.docs-body tr:last-child td,
.docs-content tr:last-child td {
  border-bottom: none;
}

.docs-body tbody tr:hover,
.docs-content tbody tr:hover {
  background: rgba(137, 180, 250, 0.05);
  transition: background var(--transition-fast);
}

/* Blockquotes */
.docs-body blockquote,
.docs-content blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-6);
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(249, 226, 175, 0.05) 100%);
  border-left: 4px solid var(--color-yellow);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-style: italic;
}

.docs-body blockquote p,
.docs-content blockquote p {
  margin-bottom: 0;
}

/* Documentation Quick Links */
.docs-quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4);
  margin: var(--space-8) 0;
}

.quick-link-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(69, 71, 90, 0.5) 100%);
  border: 2px solid var(--color-surface1);
  border-radius: var(--radius-xl);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.quick-link-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    var(--color-blue) 0%,
    var(--color-lavender) 50%,
    var(--color-mauve) 100%);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-base);
}

.quick-link-card:hover::before {
  transform: scaleX(1);
}

.quick-link-card:hover {
  transform: translateY(-4px);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
  background: var(--bg-surface-hover);
}

.quick-link-card .icon {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-3);
}

.quick-link-card h3 {
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.quick-link-card p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
}

/* Help Section */
.help-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-8);
}

.help-card {
  padding: var(--space-6);
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(69, 71, 90, 0.3) 100%);
  border-radius: var(--radius-xl);
  border: 2px solid var(--color-surface1);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.help-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.help-card h3 {
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.help-card p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
}

.help-card a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--font-medium);
}

.help-card a:hover {
  color: var(--color-lavender);
  text-decoration: underline;
}

/* Page Navigation */
.docs-page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 2px solid var(--color-surface1);
}

.docs-nav-link {
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-6);
  background: var(--bg-tertiary);
  border: 2px solid var(--color-surface1);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition-base);
  max-width: 45%;
}

.docs-nav-link:hover {
  background: var(--bg-surface-hover);
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.docs-nav-link .nav-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.docs-nav-link .nav-title {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  font-weight: var(--font-medium);
}

.docs-nav-link.prev::before {
  content: '←';
  position: absolute;
  left: var(--space-3);
  font-size: var(--font-size-xl);
  opacity: 0.5;
}

.docs-nav-link.next::after {
  content: '→';
  position: absolute;
  right: var(--space-3);
  font-size: var(--font-size-xl);
  opacity: 0.5;
}

/* Documentation Footer */
.docs-footer {
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-surface1);
  text-align: right;
}

.edit-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--font-size-sm);
  transition: color var(--transition-fast);
}

.edit-link:hover {
  color: var(--color-primary);
}

/* ============================================================================
 * Direct content styling fallbacks
 * ============================================================================ */

/* Ensure direct markdown rendered in .docs-content gets styled */
.docs-content > h1,
.docs-content > h2,
.docs-content > h3,
.docs-content > h4,
.docs-content > h5,
.docs-content > h6,
.docs-content > p,
.docs-content > ul,
.docs-content > ol,
.docs-content > blockquote,
.docs-content > pre,
.docs-content > table {
  /* Inherit all the styles from docs-body */
}

/* Direct heading styles */
.docs-content > h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-bold);
  margin-top: 0;
  margin-bottom: var(--space-8);
  color: var(--text-primary);
  line-height: var(--line-height-tight);
}

.docs-content > h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-semibold);
  margin-top: var(--space-10);
  margin-bottom: var(--space-6);
  color: var(--color-primary);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-surface1);
  position: relative;
  padding-left: var(--space-8);
}

.docs-content > h3 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-semibold);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  color: var(--text-primary);
  position: relative;
  padding-left: var(--space-6);
}

/* Strong and emphasis styling */
.docs-content strong,
.docs-body strong {
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

.docs-content em,
.docs-body em {
  color: var(--color-lavender);
  font-style: italic;
}

/* Horizontal rules */
.docs-content hr,
.docs-body hr {
  margin: var(--space-10) 0;
  border: none;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--color-surface1) 20%,
    var(--color-surface1) 80%,
    transparent 100%);
}

/* Image styles */
.docs-content img,
.docs-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin: var(--space-6) 0;
}

/* Nested lists */
.docs-content ul ul,
.docs-content ol ol,
.docs-content ul ol,
.docs-content ol ul,
.docs-body ul ul,
.docs-body ol ol,
.docs-body ul ol,
.docs-body ol ul {
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

/* Definition lists */
.docs-content dl,
.docs-body dl {
  margin: var(--space-6) 0;
}

.docs-content dt,
.docs-body dt {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.docs-content dd,
.docs-body dd {
  margin-left: var(--space-8);
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

/* Keyboard shortcuts */
.docs-content kbd,
.docs-body kbd {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--color-surface1);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 var(--color-surface2);
}

/* Small text */
.docs-content small,
.docs-body small {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* Abbreviations */
.docs-content abbr,
.docs-body abbr {
  cursor: help;
  text-decoration: underline dotted;
  text-decoration-color: var(--color-primary);
}

/* ============================================================================
 * Responsive Design
 * ============================================================================ */
@media (max-width: 768px) {
  .docs-quick-links {
    grid-template-columns: 1fr;
  }

  .help-section {
    grid-template-columns: 1fr;
  }

  .docs-page-nav {
    flex-direction: column;
    gap: var(--space-4);
  }

  .docs-nav-link {
    max-width: 100%;
    width: 100%;
  }

  .docs-body h1 {
    font-size: var(--font-size-2xl);
  }

  .docs-body h2 {
    font-size: var(--font-size-xl);
  }

  .docs-body h3 {
    font-size: var(--font-size-lg);
  }
}

/* ============================================================================
 * Anchor Links Enhancement
 * ============================================================================ */

/* Enhanced anchor link positioning for documentation */
.docs-body h2,
.docs-body h3,
.docs-body h4,
.docs-body h5,
.docs-body h6,
.docs-content h2,
.docs-content h3,
.docs-content h4,
.docs-content h5,
.docs-content h6 {
  scroll-margin-top: 6rem;
}

/* Table of Contents Styling */
.table-of-contents,
.toc,
#toc {
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(137, 180, 250, 0.05) 100%);
  border: 2px solid var(--color-surface1);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin: var(--space-8) 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.table-of-contents::before,
.toc::before,
#toc::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    var(--color-blue) 0%,
    var(--color-lavender) 50%,
    var(--color-mauve) 100%);
}

.table-of-contents h3,
.table-of-contents h4,
.toc h3,
.toc h4,
#toc h3,
#toc h4 {
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-surface1);
  font-size: var(--font-size-lg);
  font-weight: var(--font-semibold);
}

/* Anchor link hover enhancements for documentation */
.docs-body .anchor-link,
.docs-content .anchor-link {
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(137, 180, 250, 0.1) 100%);
  border: 1px solid var(--color-surface1);
  backdrop-filter: blur(10px);
}

.docs-body .anchor-link:hover,
.docs-content .anchor-link:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(137, 180, 250, 0.3);
}

.docs-body .anchor-icon,
.docs-content .anchor-icon {
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.docs-body .anchor-link:hover .anchor-icon,
.docs-content .anchor-link:hover .anchor-icon {
  color: white;
}

/* Enhanced heading styles with better anchor link integration */
.docs-body h2::before,
.docs-content h2::before {
  left: calc(-1 * var(--space-8));
  color: var(--color-lavender);
  font-weight: var(--font-bold);
  opacity: 0.3;
  transition: opacity var(--transition-fast);
}

.docs-body h2:hover::before,
.docs-content h2:hover::before {
  opacity: 0.6;
}

.docs-body h3::before,
.docs-content h3::before {
  left: calc(-1 * var(--space-6));
  color: var(--color-primary);
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.docs-body h3:hover::before,
.docs-content h3:hover::before {
  opacity: 0.8;
}

/* Copy-to-clipboard toast notification */
.anchor-copy-toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--color-green);
  color: white;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-medium);
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition-base);
  z-index: 9999;
}

.anchor-copy-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Link highlight animation */
@keyframes highlight-heading {
  0% { background: transparent; }
  50% { background: rgba(137, 180, 250, 0.1); }
  100% { background: transparent; }
}

.heading-highlighted {
  animation: highlight-heading 1.5s ease-out;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-4));
}

/* ============================================================================
 * Collapsible Sections Integration
 * ============================================================================ */
/* Override h2 padding when collapsible sections are present */
.collapsible-section h2 {
  position: relative;
}

/* Ensure proper spacing for collapsible content */
.collapsible-content {
  margin-top: var(--space-6);
}

/* Smooth height transitions for collapsible content */
.collapsible-content > *:first-child {
  margin-top: 0;
}

.collapsible-content > *:last-child {
  margin-bottom: 0;
}

/* Adjust h2 decoration when it's collapsible */
.collapsible-section h2::before {
  left: calc(-1 * var(--space-12)) !important;
}

/* Ensure toggle button doesn't interfere with existing decorations */
.collapsible-section .section-toggle {
  left: calc(-1 * var(--space-10));
}

@media (max-width: 768px) {
  .collapsible-section .section-toggle {
    left: calc(-1 * var(--space-8));
  }

  .collapsible-section h2::before {
    left: calc(-1 * var(--space-10)) !important;
  }
}

/* ============================================================================
 * Print Styles
 * ============================================================================ */
@media print {
  .docs-sidebar {
    display: none;
  }

  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-footer {
    display: none;
  }

  .docs-page-nav {
    display: none;
  }

  .docs-body pre {
    page-break-inside: avoid;
  }

  .docs-body table {
    page-break-inside: avoid;
  }

  /* Hide anchor links in print */
  .anchor-link {
    display: none !important;
  }

  .table-of-contents {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  /* Hide collapsible controls in print */
  .collapsible-controls,
  .section-toggle {
    display: none !important;
  }

  /* Ensure all sections are expanded in print */
  .collapsed .collapsible-content {
    max-height: none !important;
    opacity: 1 !important;
  }
}
