/* ═══════════════════════════════════════════════════════════════════
   FlutterPlaza Code Push — Docs-Specific Styles
   Extends base.css design tokens and components
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Docs Layout (3-column) ───────────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 240px 1fr 200px;
  min-height: calc(100vh - var(--nav-height));
}

/* ─── Left Sidebar ─────────────────────────────────────────────────── */
.docs-sidebar {
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: 20px 0;
  z-index: 20;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.docs-sidebar::-webkit-scrollbar {
  width: 4px;
}

.docs-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.sidebar-search {
  padding: 0 16px 16px;
}

.sidebar-search .form-input {
  padding: 8px 12px;
  font-size: 0.82rem;
  background: var(--surface);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
}

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

.sidebar-section.hidden {
  display: none;
}

.sidebar-heading {
  padding: 10px 20px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.sidebar-link {
  display: block;
  padding: 5px 20px 5px 24px;
  font-size: 0.84rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: 1.5;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--surface-hover);
  text-decoration: none;
}

.sidebar-link.active {
  color: var(--accent-light);
  border-left-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}

.sidebar-link.hidden {
  display: none;
}

/* ─── Sidebar Toggle (mobile) ──────────────────────────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  z-index: 50;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s;
}

.sidebar-toggle:hover {
  transform: scale(1.08);
}

/* ─── Main Content ─────────────────────────────────────────────────── */
.docs-main {
  padding: 40px 48px 80px;
  overflow-y: auto;
  min-width: 0;
}

.docs-content {
  max-width: 760px;
  margin: 0 auto;
}

/* ─── Doc Sections ─────────────────────────────────────────────────── */
.doc-section {
  display: none;
  animation: fadeIn 0.2s ease;
}

.doc-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Typography ───────────────────────────────────────────────────── */
.docs-content h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-bright);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.docs-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-top: 48px;
  margin-bottom: 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--nav-height) + 24px);
}

.docs-content h2:first-of-type {
  border-top: none;
  padding-top: 0;
}

.docs-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-top: 32px;
  margin-bottom: 8px;
  scroll-margin-top: calc(var(--nav-height) + 24px);
}

.docs-content h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 8px;
  scroll-margin-top: calc(var(--nav-height) + 24px);
}

.section-lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.7;
}

.docs-content p {
  margin-bottom: 14px;
  line-height: 1.7;
}

.docs-content ul,
.docs-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.docs-content li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.docs-content strong {
  color: var(--text-bright);
  font-weight: 600;
}

/* Anchor link styling for headings */
.docs-content h1[id],
.docs-content h2[id],
.docs-content h3[id] {
  scroll-margin-top: calc(var(--nav-height) + 24px);
}

/* ─── Code Blocks ──────────────────────────────────────────────────── */
.code-block {
  position: relative;
  margin-bottom: 20px;
}

.code-block pre {
  padding-right: 52px;
}

.code-block .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.code-block:hover .copy-btn {
  opacity: 1;
}

.code-block .copy-btn:hover {
  color: var(--text-bright);
  background: var(--surface-active);
}

.code-block .copy-btn.copied {
  color: var(--green);
  border-color: var(--green);
}

.code-block .copy-btn svg {
  width: 16px;
  height: 16px;
}

/* Language label */
.code-block::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  left: 16px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0 6px;
  transform: translateY(-50%);
  z-index: 1;
}

/* ─── Syntax Highlighting (CSS-based) ──────────────────────────────── */

/* Keywords (Dart/bash) */
.code-block[data-lang="dart"] code .kw,
.code-block[data-lang="bash"] code .kw {
  color: #c678dd;
}

/* Strings */
.code-block code .str {
  color: #98c379;
}

/* Comments */
.code-block code .cmt {
  color: var(--text-muted);
  font-style: italic;
}

/* Numbers */
.code-block code .num {
  color: #d19a66;
}

/* JSON keys */
.code-block[data-lang="json"] code .key {
  color: #61afef;
}

/* JSON strings */
.code-block[data-lang="json"] code .str {
  color: #98c379;
}

/* Type names */
.code-block code .type {
  color: #e5c07b;
}

/* ─── Callouts ─────────────────────────────────────────────────────── */
.callout {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.6;
  border-left: 3px solid;
}

.callout strong {
  display: inline;
}

.callout-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--blue);
  color: var(--text);
}

.callout-info strong {
  color: var(--blue);
}

.callout-warn {
  background: rgba(234, 179, 8, 0.08);
  border-color: var(--yellow);
  color: var(--text);
}

.callout-warn strong {
  color: var(--yellow);
}

.callout-success {
  background: rgba(34, 197, 94, 0.08);
  border-color: var(--green);
  color: var(--text);
}

.callout-success strong {
  color: var(--green);
}

.callout-error {
  background: rgba(239, 68, 68, 0.08);
  border-color: var(--red);
  color: var(--text);
}

.callout-error strong {
  color: var(--red);
}

/* ─── Tables ───────────────────────────────────────────────────────── */
.docs-content .table {
  margin-bottom: 24px;
}

.docs-content .table code {
  font-size: 0.82rem;
}

/* ─── Badges inside content ────────────────────────────────────────── */
.docs-content .badge {
  vertical-align: middle;
  margin-left: 4px;
  margin-bottom: 12px;
}

.docs-content h2 + .badge {
  display: inline-flex;
  margin-bottom: 16px;
}

/* ─── Right Sidebar (Table of Contents) ────────────────────────────── */
.docs-toc {
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  padding: 24px 16px 24px 0;
  border-left: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.docs-toc::-webkit-scrollbar {
  width: 4px;
}

.docs-toc::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.toc-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 16px 12px;
}

.toc-nav {
  display: flex;
  flex-direction: column;
}

.toc-link {
  display: block;
  padding: 4px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.5;
}

.toc-link:hover {
  color: var(--text);
  text-decoration: none;
}

.toc-link.active {
  color: var(--accent-light);
  border-left-color: var(--accent);
}

.toc-link.toc-h3 {
  padding-left: 28px;
  font-size: 0.74rem;
}

/* ─── Mobile Nav ───────────────────────────────────────────────────── */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.mobile-menu-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.mobile-menu-btn.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.open span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 90;
  padding: 24px;
}

.mobile-nav-overlay.open {
  display: block;
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-nav-links a {
  display: block;
  padding: 14px 16px;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.mobile-nav-links a:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.mobile-nav-links a.active {
  color: var(--accent-light);
  background: rgba(99, 102, 241, 0.08);
}

/* ─── Responsive: Tablet (hide TOC) ───────────────────────────────── */
@media (max-width: 1100px) {
  .docs-layout {
    grid-template-columns: 240px 1fr;
  }

  .docs-toc {
    display: none;
  }
}

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

  .docs-sidebar {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 80;
    background: var(--bg);
    box-shadow: var(--shadow-lg);
  }

  .docs-sidebar.open {
    display: block;
  }

  .sidebar-toggle {
    display: flex;
  }

  .docs-main {
    padding: 24px 20px 80px;
  }

  .docs-content h1 {
    font-size: 1.6rem;
  }

  .docs-content h2 {
    font-size: 1.2rem;
  }

  /* Show mobile hamburger, hide desktop nav links */
  .mobile-menu-btn {
    display: flex;
  }

  .nav-links {
    display: none !important;
  }
}

/* ─── Sidebar backdrop (mobile) ────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--nav-height);
  background: rgba(0, 0, 0, 0.5);
  z-index: 70;
}

.sidebar-backdrop.open {
  display: block;
}

/* ─── Smooth scroll ────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
}

/* ─── Selection ────────────────────────────────────────────────────── */
::selection {
  background: rgba(99, 102, 241, 0.3);
  color: var(--text-bright);
}
