/* ============================================
   What Framework — Documentation Styles
   Imports shared design system, adds docs layout
   ============================================ */

@import url('../design-system.css');

/* --- Layout Variables --- */
:root, [data-theme="dark"] {
  --sidebar-width: 260px;
  --header-height: 64px;
  --toc-width: 220px;
  --accent-light: rgba(62, 207, 142, 0.08);
}

[data-theme="light"] {
  --accent-light: rgba(43, 168, 110, 0.08);
}

/* --- Navigation --- */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-left { display: flex; align-items: center; gap: 32px; }
.nav-right { display: flex; align-items: center; gap: 16px; }

.logo {
  font-weight: 800;
  font-size: 18px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--accent);
  color: white;
  border-radius: 4px;
}

.nav-links { display: flex; gap: 24px; }

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s;
}

.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); }

/* --- Search Placeholder --- */
.search-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 200px;
}

.search-placeholder:hover {
  border-color: var(--text-muted);
}

.search-placeholder svg { width: 16px; height: 16px; flex-shrink: 0; }

.search-placeholder .search-shortcut {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-muted);
}

/* --- AI Docs Button --- */
.ai-docs-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: not-allowed;
  opacity: 0.6;
  transition: all 0.2s;
  font-family: inherit;
}

.ai-docs-btn svg { width: 16px; height: 16px; }

.ai-docs-btn .coming-soon {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
}

/* --- AI Modal Shell --- */
.ai-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.ai-modal-overlay.active { display: flex; }

.ai-modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.ai-modal h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.ai-modal p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.ai-modal-close {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
}

.ai-modal-close:hover { border-color: var(--text-muted); }

/* --- Layout --- */
.layout {
  display: flex;
  margin-top: var(--header-height);
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg);
}

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

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 12px;
}

.sidebar-links { list-style: none; }
.sidebar-links li { margin-bottom: 1px; }

.sidebar-links a {
  display: block;
  padding: 6px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  transition: all 0.15s;
}

.sidebar-links a:hover {
  color: var(--text);
  background: var(--accent-light);
}

.sidebar-links a.active {
  color: var(--text);
  background: var(--accent-light);
  font-weight: 500;
}

/* --- Content --- */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: calc(100vh - var(--header-height));
}

.content-wrapper { display: flex; }

.content-inner {
  max-width: 720px;
  padding: 48px 48px 100px;
  flex: 1;
}

/* --- Table of Contents --- */
.toc {
  position: sticky;
  top: calc(var(--header-height) + 48px);
  width: var(--toc-width);
  padding: 0 24px;
  height: fit-content;
  max-height: calc(100vh - var(--header-height) - 96px);
  overflow-y: auto;
}

.toc-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.toc-links { list-style: none; }

.toc-links a {
  display: block;
  padding: 4px 0;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
  border-left: 2px solid transparent;
  padding-left: 12px;
  margin-left: -12px;
}

.toc-links a:hover { color: var(--text); }

.toc-links a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-links .toc-h3 {
  padding-left: 24px;
  margin-left: -12px;
}

/* --- Typography --- */
.content h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  line-height: 1.2;
}

.subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 40px;
  line-height: 1.6;
}

.content h2 {
  font-size: 22px;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  letter-spacing: -0.01em;
}

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

.content h3 {
  font-size: 17px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

.content p {
  margin-bottom: 16px;
  color: var(--text);
}

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

.content li { margin-bottom: 8px; }

.content a {
  color: var(--accent);
  text-decoration: none;
}

.content a:hover { text-decoration: underline; }

/* --- Inline Code --- */
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--code-border);
}

/* --- Code Blocks --- */
pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin-bottom: 24px;
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: 13.5px;
  line-height: 1.6;
}

/* Code block header (filename tab) */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--code-border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

.code-header + pre {
  border-radius: 0 0 8px 8px;
  margin-top: 0;
}

/* Copy button on code blocks */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  z-index: 1;
}

pre:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--border);
  color: var(--text);
}

.copy-btn.copied {
  color: var(--accent);
  opacity: 1;
}

/* --- Callouts --- */
.callout {
  padding: 16px 20px;
  margin: 24px 0;
  border-radius: 8px;
  border-left: 4px solid;
  background: var(--bg-raised);
}

.callout p { margin: 0; font-size: 14px; }
.callout p + p { margin-top: 8px; }

.callout-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}

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

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

.callout-warning {
  border-color: var(--warning);
}

.callout-warning .callout-title { color: var(--warning); }

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

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

.callout-note {
  border-color: var(--accent);
}

.callout-note .callout-title { color: var(--accent); }

/* Subtle background tint for callouts */
[data-theme="dark"] .callout-info { background: rgba(96, 165, 250, 0.06); }
[data-theme="dark"] .callout-warning { background: rgba(245, 158, 11, 0.06); }
[data-theme="dark"] .callout-success { background: rgba(62, 207, 142, 0.06); }
[data-theme="dark"] .callout-note { background: rgba(62, 207, 142, 0.06); }

[data-theme="light"] .callout-info { background: rgba(96, 165, 250, 0.08); }
[data-theme="light"] .callout-warning { background: rgba(245, 158, 11, 0.08); }
[data-theme="light"] .callout-success { background: rgba(62, 207, 142, 0.08); }
[data-theme="light"] .callout-note { background: rgba(62, 207, 142, 0.08); }

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.card {
  padding: 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
  display: block;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-surface);
}

/* --- Navigation Footer (prev/next) --- */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.page-nav a {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
  min-width: 180px;
}

.page-nav a:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.page-nav .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page-nav .title {
  font-weight: 500;
  font-size: 15px;
}

.page-nav .next { text-align: right; margin-left: auto; }

/* --- Interactive Elements --- */
.sandbox {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 24px 0;
}

.sandbox-preview {
  padding: 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.sandbox-code {
  padding: 16px 20px;
  background: var(--code-bg);
}

.sandbox-code pre {
  margin: 0;
  border: none;
  background: none;
  padding: 0;
}

/* --- Step Indicators (Tutorial) --- */
.step {
  display: flex;
  gap: 16px;
  margin: 24px 0;
}

.step-number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.step-content { flex: 1; }

.step-content h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.step-content p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* --- Playground / Live Demos --- */
.playground {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 24px 0;
}

.playground-header {
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.playground-result {
  padding: 24px;
  background: var(--bg-raised);
  min-height: 60px;
}

.playground-result button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s;
}

.playground-result button:hover {
  border-color: var(--text-muted);
  background: var(--bg-surface);
}

.playground-result input,
.playground-result select,
.playground-result textarea {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.playground-result input:focus,
.playground-result select:focus,
.playground-result textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* --- Responsive --- */
@media (max-width: 1280px) {
  .toc { display: none; }
  .content-inner { max-width: 800px; }
}

@media (max-width: 1024px) {
  .sidebar { display: none; }
  .content { margin-left: 0; }
  .content-inner { padding: 32px 24px; }
  .card-grid { grid-template-columns: 1fr; }
  .search-placeholder { display: none; }
}

@media (max-width: 768px) {
  .nav-links { display: none; }
  .page-nav { flex-direction: column; gap: 12px; }
  .page-nav a { min-width: auto; }
  .page-nav .next { text-align: left; margin-left: 0; }
  .ai-docs-btn { display: none; }
}
