/**
 * docs.css - Documentation-specific styles
 * Extends landing.css with documentation layout and components
 */

/* ============================================
   Layout
   ============================================ */

.docs-layout {
  display: flex;
  min-height: calc(100vh - 92px);
  margin-top: 92px;
}

/* ============================================
   Sidebar
   ============================================ */

.docs-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: #fafafa;
  border-right: 1px solid #e5e5e5;
  position: fixed;
  top: 92px;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.docs-sidebar-header {
  padding: 20px 20px 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.docs-sidebar-header h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0;
}

.docs-sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}

/* Search */
.docs-search-container {
  padding: 16px 20px;
  flex-shrink: 0;
}

/* API Reference Link */
.docs-nav-api-link {
  padding: 0 12px 16px 12px;
  flex-shrink: 0;
}

.docs-nav-api-link a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  border-radius: 8px;
  color: var(--text, #333);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.docs-nav-api-link a:hover {
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  border-color: var(--accent, #fd6c1d);
  color: var(--accent, #fd6c1d);
}

.docs-nav-api-link a i:first-child {
  color: var(--accent, #fd6c1d);
}

.docs-nav-api-link a i:last-child {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.5;
}

.docs-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.docs-search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  font-size: 14px;
}

.docs-search-input {
  width: 100%;
  padding: 10px 40px 10px 36px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  transition: all 0.2s ease;
}

.docs-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(253, 108, 29, 0.1);
}

.docs-search-input::placeholder {
  color: #aaa;
}

.docs-search-kbd {
  position: absolute;
  right: 10px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: monospace;
  color: var(--muted);
}

/* Search Results */
.docs-search-results {
  border-top: 1px solid #e5e5e5;
  padding: 12px 20px;
  background: white;
}

.docs-search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.docs-search-clear {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.docs-search-clear:hover {
  text-decoration: underline;
}

.docs-search-results-list {
  max-height: 300px;
  overflow-y: auto;
}

.docs-search-result-item {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s ease;
  margin-bottom: 4px;
}

.docs-search-result-item:hover {
  background: rgba(253, 108, 29, 0.08);
}

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

.docs-search-result-match {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.docs-search-result-match mark {
  background: rgba(253, 108, 29, 0.2);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.docs-search-no-results {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
}

/* Navigation */
.docs-nav {
  padding: 0 12px 20px 12px;
  flex: 1;
  overflow-y: auto;
}

.docs-nav-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}

.docs-nav-category {
  margin-bottom: 8px;
}

.docs-nav-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.docs-nav-category-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

.docs-nav-category-header i {
  font-size: 12px;
  color: var(--accent);
  width: 16px;
  text-align: center;
}

.docs-nav-category-toggle {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.docs-nav-category.collapsed .docs-nav-category-toggle {
  transform: rotate(-90deg);
}

.docs-nav-category.collapsed .docs-nav-items {
  display: none;
}

.docs-nav-items {
  padding-left: 12px;
}

.docs-nav-item {
  display: block;
  padding: 8px 12px 8px 24px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s ease;
  border-left: 2px solid transparent;
}

.docs-nav-item:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.docs-nav-item.active {
  color: var(--accent);
  background: rgba(253, 108, 29, 0.08);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* Sidebar Toggle (mobile) */
.docs-sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 18px;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(253, 108, 29, 0.4);
  transition: transform 0.2s ease;
}

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

/* ============================================
   Main Content
   ============================================ */

.docs-main {
  flex: 1;
  margin-left: 280px;
  display: flex;
  min-width: 0;
  /* Constrain total width and center on very wide screens */
  max-width: 1100px;
  margin-right: auto;
}

.docs-content {
  flex: 1;
  max-width: 780px;
  padding: 32px 48px;
  min-width: 0;
  min-height: 60vh;
}

/* Breadcrumb */
.docs-breadcrumb {
  display: none; /* Hide by default, show only when viewing a doc */
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 24px;
}

.docs-breadcrumb.visible {
  display: flex;
}

.docs-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.docs-breadcrumb a:hover {
  color: var(--accent);
}

.docs-breadcrumb-sep {
  color: #ddd;
}

.docs-breadcrumb span:last-child {
  color: var(--text);
  font-weight: 500;
}

/* Welcome Screen */
.docs-welcome {
  text-align: center;
  padding: 60px 20px;
}

.docs-welcome-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px auto;
  background: linear-gradient(135deg, var(--accent) 0%, #ff8c42 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: white;
}

.docs-welcome h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px 0;
}

.docs-welcome > p {
  font-size: 16px;
  color: var(--muted);
  max-width: 500px;
  margin: 0 auto 40px auto;
  line-height: 1.6;
}

.docs-welcome-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
  text-align: left;
}

.docs-welcome-card {
  display: block;
  padding: 24px;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.docs-welcome-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.docs-welcome-card-icon {
  width: 40px;
  height: 40px;
  background: rgba(253, 108, 29, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 16px;
}

.docs-welcome-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.docs-welcome-card-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.docs-welcome-card.hidden {
  display: none;
}

/* Category Groups */
.docs-welcome-category {
  margin-bottom: 40px;
}

.docs-welcome-category:last-child {
  margin-bottom: 0;
}

.docs-welcome-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e5e5;
}

.docs-welcome-category-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.docs-welcome-category-title i {
  color: var(--accent);
  font-size: 16px;
}

.docs-welcome-category-count {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

/* Pagination */
.docs-welcome-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
}

.docs-welcome-page-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--text);
}

.docs-welcome-page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.docs-welcome-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.docs-welcome-page-info {
  font-size: 13px;
  color: var(--muted);
  min-width: 50px;
  text-align: center;
}

/* Cards Grid */
.docs-welcome-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

/* Article */
.docs-article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e5e5e5;
}

.docs-article-header h1 {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px 0;
  line-height: 1.2;
}

.docs-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.docs-article-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.docs-article-meta i {
  font-size: 12px;
}

.docs-article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.docs-article-tag {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(253, 108, 29, 0.1);
  color: var(--accent);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

/* Article Body (rendered markdown) */
.docs-article-body {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
}

.docs-article-body h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 40px 0 16px 0;
  padding-top: 20px;
  border-top: 1px solid #e5e5e5;
}

.docs-article-body h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.docs-article-body h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 32px 0 12px 0;
}

.docs-article-body h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 8px 0;
}

.docs-article-body p {
  margin: 0 0 16px 0;
}

.docs-article-body a {
  color: var(--accent);
  text-decoration: none;
}

.docs-article-body a:hover {
  text-decoration: underline;
}

.docs-article-body strong {
  font-weight: 600;
}

.docs-article-body ul,
.docs-article-body ol {
  margin: 0 0 16px 0;
  padding-left: 24px;
}

.docs-article-body li {
  margin-bottom: 8px;
}

.docs-article-body li ul,
.docs-article-body li ol {
  margin-top: 8px;
  margin-bottom: 0;
}

/* Inline code */
.docs-article-body code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* Code blocks */
.docs-article-body pre {
  background: #282c34;
  border-radius: 8px;
  padding: 20px;
  overflow-x: auto;
  margin: 0 0 20px 0;
}

.docs-article-body pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #abb2bf;
}

/* Tables */
.docs-article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 20px 0;
  font-size: 14px;
}

.docs-article-body th,
.docs-article-body td {
  padding: 12px 16px;
  text-align: left;
  border: 1px solid #e5e5e5;
}

.docs-article-body th {
  background: #f9f9f9;
  font-weight: 600;
}

.docs-article-body tr:hover td {
  background: #fafafa;
}

/* Blockquotes */
.docs-article-body blockquote {
  margin: 0 0 20px 0;
  padding: 16px 20px;
  background: rgba(253, 108, 29, 0.05);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

.docs-article-body blockquote p:last-child {
  margin-bottom: 0;
}

/* Horizontal rules */
.docs-article-body hr {
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 32px 0;
}

/* Heading anchors */
.docs-heading-anchor {
  color: var(--muted);
  text-decoration: none;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.docs-article-body h2:hover .docs-heading-anchor,
.docs-article-body h3:hover .docs-heading-anchor,
.docs-article-body h4:hover .docs-heading-anchor {
  opacity: 1;
}

.docs-heading-anchor:hover {
  color: var(--accent);
}

/* ============================================
   Table of Contents
   ============================================ */

.docs-toc {
  width: 220px;
  flex-shrink: 0;
  padding: 32px 24px 32px 0;
  position: sticky;
  top: 102px;
  max-height: calc(100vh - 134px);
  overflow-y: auto;
}

.docs-toc h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 16px 0;
}

.docs-toc nav {
  border-left: 1px solid #e5e5e5;
}

.docs-toc-item {
  display: block;
  padding: 6px 0 6px 16px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.docs-toc-item:hover {
  color: var(--text);
}

.docs-toc-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.docs-toc-item.level-3 {
  padding-left: 28px;
  font-size: 12px;
}

.docs-toc-item.level-4 {
  padding-left: 40px;
  font-size: 12px;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1200px) {
  .docs-toc {
    display: none;
  }

  .docs-content {
    max-width: none;
  }
}

@media (max-width: 900px) {
  .docs-sidebar {
    transform: translateX(-100%);
  }

  .docs-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  }

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

  .docs-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .docs-main {
    margin-left: 0;
  }

  .docs-content {
    padding: 24px;
    padding-top: 16px;
  }

  .docs-breadcrumb {
    margin-top: 0;
  }

  .docs-article-header h1 {
    font-size: 28px;
  }

  .docs-welcome h1 {
    font-size: 26px;
  }
}

@media (max-width: 600px) {
  .docs-layout {
    margin-top: 80px;
  }

  .docs-content {
    padding: 16px;
  }

  .docs-article-header h1 {
    font-size: 24px;
  }

  .docs-article-body {
    font-size: 15px;
  }

  .docs-article-body h2 {
    font-size: 20px;
  }

  .docs-article-body h3 {
    font-size: 18px;
  }

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

/* ============================================
   Simple Docs Footer
   ============================================ */

.docs-footer {
  margin-left: 280px;
  padding: 16px 32px;
  text-align: center;
  font-size: 13px;
  color: var(--muted, #666);
  border-top: 1px solid #e5e5e5;
  background: #fafafa;
}

.docs-footer a {
  color: var(--muted, #666);
  text-decoration: none;
}

.docs-footer a:hover {
  color: var(--accent, #fd6c1d);
}

.docs-footer-sep {
  margin: 0 12px;
  opacity: 0.4;
}

@media (max-width: 768px) {
  .docs-footer {
    margin-left: 0;
    padding: 12px 16px;
  }
}

/* ============================================
   Mermaid Diagrams
   ============================================ */

.mermaid-diagram {
  margin: 24px 0;
  padding: 20px;
  background: #fafafa;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  overflow-x: auto;
  text-align: center;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

.mermaid-error {
  color: #c00;
  background: #fff0f0;
  border: 1px solid #fcc;
  padding: 12px;
  border-radius: 4px;
  font-size: 13px;
}
