/* ╔════════════════════════════════════════════════════════════════════════════╗
   ║ 🛡️  CRITICAL GUARDRAIL FOR AI AGENTS                                       ║
   ║ Module-specific CSS files (style.chat.css, style.docs.css, etc.) MUST NOT: ║
   ║   • Use hardcoded hex colors (#222, #fff, etc.)                             ║
   ║   • Define [data-theme="dark"] selectors                                    ║
   ║ REQUIRED: All colors must use CSS tokens from :root (--bg-*, --text-*, etc) ║
   ║ If a module needs a new color:                                              ║
   ║   1. Define the token in :root (including [data-theme="dark"] override)     ║
   ║   2. Use var(--token-name) in the module's CSS file                         ║
   ║ Violation example (FORBIDDEN): background-color: #222; in style.chat.css    ║
   ║ Correct pattern: background-color: var(--bg-surface); in style.chat.css     ║
   └════════════════════════════════════════════════════════════════════════════┘ */

/* ==============================
   DOCUMENTATION VIEWER (SPA)
   Template: static/module/user/docs/templates/docs.html
   Controller: static/module/user/docs/js/docsController.js
   Source: public/docs/<lang>/<service>/*.md (fetched at runtime)
   ──────────────────────────────────────
  .docs-layout          2-col grid (280px + 1fr), stacks ≤992px
  .docs-sidebar         sticky left nav (top:100px)
  .app-nav-item        nav link; .active — brand inverted
   .docs-content-wrapper right panel (padding:32px)
   .markdown-body        GitHub-style typography (h1-h3, code, pre, blockquote)
   .docs-loading-placeholder centered spinner during fetch
   ============================== */

.docs-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-6);
  align-items: start;
}

/* Sidebar Topics */
/* The sidebar is an .app-panel with the card modifier. */
.docs-sidebar {
  --panel-pad: var(--space-5);
  position: sticky;
  top: 100px;
}

.docs-sidebar h2,
.docs-sidebar h3 {
  font-size: var(--fs-base-sm);
  text-transform: uppercase;
  letter-spacing: 0.075rem;
  color: var(--text-faint);
  margin-bottom: var(--space-3-5);
}

/* The list of topics is an .app-stack. */
.docs-nav {
  --stack-gap: var(--space-2);
}

/* Content Area. The wrapper is an .app-panel with the card modifier. */
.docs-content-wrapper {
  --panel-pad: var(--space-8);
  min-height: 460px;
}

/* Markdown Styling */
.markdown-body {
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--text-primary);
}

.markdown-body h1 {
  font-size: var(--fs-3xl);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-6);
  line-height: 1.2;
}

.markdown-body h2 {
  font-size: var(--fs-xl);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

.markdown-body h3 {
  font-size: var(--fs-lg);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.markdown-body p {
  margin-bottom: var(--space-4);
}

.markdown-body ul,
.markdown-body ol {
  margin-bottom: var(--space-4);
  padding-inline-start: var(--space-6);
}

.markdown-body li {
  margin-bottom: var(--space-2);
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius-md);
}

.markdown-body a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.markdown-body a:hover {
  color: var(--brand-hover);
}

.markdown-body code {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-0-5) var(--space-1-5);
  font-size: 0.92em;
}

.markdown-body pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  margin: var(--space-5) 0;
}

.markdown-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

.markdown-body blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-6);
  background: var(--bg-subtle);
  border-inline-start: 4px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}

/* The "guide source (Markdown)" footer both viewers append after a successful render
   (markdown-view.js: appendSourceLink()). It is an .app-page-footer, thus it reads as metadata.
   overflow-wrap keeps the absolute URL from overflowing the column on a phone. */
.docs-source-link {
  overflow-wrap: anywhere;
}

.docs-source-link a {
  color: var(--text-muted);
}

.docs-source-link a:hover {
  color: var(--brand);
}

/* Alert Styling for MD (GitHub Liked) */
.markdown-body blockquote>p:first-child strong:first-child {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--fs-body);
  text-transform: uppercase;
}

/* Loading State */
.docs-loading-placeholder {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

/* app-spinner and @keyframes spin are defined in style.app.css (shared after login) */

/* Responsive Docs */
@media (max-width: 992px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: static;
  }
}

@media (max-width: 600px) {
  .docs-content-wrapper {
    --panel-pad: var(--space-6);
  }

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

  .markdown-body h2 {
    font-size: var(--fs-xl-sm);
  }
}

/* .hidden — defined in style.app.css (single source) */

/* --- Documentation Index (the signpost page) --- */
.docs-index {
  padding: var(--space-6) 0;
}

/* The topic list of the docs sidebar. It restyles the shared .app-nav-item of
   style.app.css as a vertical list with an active pill. A topic name wraps: the shared
   item keeps its label on one line, and a long name then ran out of the 280px column. */
.docs-sidebar .app-nav-item {
  display: block;
  white-space: normal;
  padding: var(--space-2-5) var(--space-3-5);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: var(--fs-body);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.docs-sidebar .app-nav-item:hover {
  color: var(--brand);
}

.docs-sidebar .app-nav-item.active,
.docs-sidebar .app-nav-item.is-active {
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  border: 1px solid var(--brand);
  box-shadow: var(--shadow-sm);
}

.docs-sidebar .app-nav-item.active:hover,
.docs-sidebar .app-nav-item.is-active:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-light);
}
