/* Documentation System Styling */

/* ============================================
   BASE STYLES & VARIABLES
   ============================================ */

:root {
  --bg: #10101f;
  --fg: #eaeaea;
  --dim: #bdbdbd;
  --line: #bdbdbd2d;
  --accent: #19ef83;
  --code-bg: #020202;
  --color-red: #fe4e4e;
  --color-orange: #ff9500;
  --color-yellow: #ffd700;
  --color-green: #19ef83;
  --color-blue: #12e0ff;
  --color-indigo: #7d3de5;
  --color-violet: #d13de5;
  --color-pink: #e53d8f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 120px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  height: 100%;
  width: 100%;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: transparent;
}

::-webkit-scrollbar-track {
  background: transparent !important;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 80%, white);
}

body {
  min-height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  letter-spacing: 0.02em;
  font-size: 0.9em;
  line-height: 1.6;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: -3;
}

.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.03) 2px, rgba(255, 255, 255, 0.03) 3px);
}

/* ============================================
   LAYOUT
   ============================================ */

.docs-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.doc-content-wrapper {
  flex: 1;
  display: flex;
  gap: 24px;
  padding: 36px 24px;
  max-width: 1200px;
}

.doc-main {
  flex: 1;
  min-width: 0;
}

.main-content {
  flex: 1;
  padding: 36px 24px;
  max-width: 900px;
}

/* Page Header (Index) */
.page-header {
  padding: 0px 0px 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.headline {
  color: var(--dim);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.14em;
  margin-bottom: 12px;
}

h1 {
  font-family: 'League Spartan', sans-serif;
  font-size: 42px;
  margin: 10px 0 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 100%;
  color: #fff;
}

.sub {
  color: var(--dim);
  margin: 0;
  font-size: 16px;
}

/* ============================================
   MARKDOWN CONTENT
   ============================================ */

.markdown-content {
  max-width: 628px;
  width: 100%;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-family: 'League Spartan', sans-serif;
  margin: 32px 0 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  position: relative;
}

.markdown-content h1 {
  font-size: 36px;
  margin-top: 0;
}

.markdown-content h2 {
  font-size: 28px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.markdown-content h3 {
  font-size: 22px;
}

.markdown-content h4 {
  font-size: 18px;
}

.markdown-content h5 {
  font-size: 16px;
}

.markdown-content h6 {
  font-size: 14px;
}

.markdown-content p {
  margin: 0 0 16px;
  color: var(--fg);
}

.markdown-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.markdown-content a:hover {
  border-bottom-color: var(--accent);
}

.markdown-content ul,
.markdown-content ol {
  margin: 16px 0;
  padding-left: 24px;
}

.markdown-content li {
  margin: 8px 0;
  color: var(--fg);
}

.markdown-content code {
  background: transparent !important;
  padding: 3px 6px;
  border-radius: 3px;
  font-family: 'Fira Code', monospace;
  font-size: 0.9em;
  color: var(--accent);
  border: 1px solid var(--line);
}

.markdown-content pre {
  background: transparent !important;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
}

code[class*='language-'],
pre[class*='language-'] {
  background: transparent !important;
}

.markdown-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--dim);
  font-style: italic;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  border: 1px solid var(--line);
}

.markdown-content th,
.markdown-content td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.markdown-content th {
  background: rgba(0, 0, 0, 0.3);
  font-weight: 700;
  color: #fff;
}

.markdown-content img {
  max-width: 100%;
  height: auto;
  /* border: 1px solid var(--line); */
  border-radius: 6px;
  margin: 16px 0;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}

/* ============================================
   CODE TABS
   ============================================ */

.code-tabs {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.code-tabs-nav {
  display: flex;
  gap: 0;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--line);
  padding: 0;
}

.code-tab-btn {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  color: var(--dim);
  font-family: 'League Spartan', sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.code-tab-btn:last-child {
  border-right: none;
}

.code-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
}

.code-tab-btn.active {
  background: transparent;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.code-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.code-tabs-content {
  position: relative;
}

.code-tab-panel {
  display: none;
}

.code-tab-panel.active {
  display: block;
}

.code-tab-panel pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent !important;
}

.code-tab-panel pre code {
  display: block;
  padding: 16px;
}

.heading-anchor {
  text-decoration: none;
  color: var(--dim);
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  font-weight: 400;
}

.markdown-content h1:hover .heading-anchor,
.markdown-content h2:hover .heading-anchor,
.markdown-content h3:hover .heading-anchor,
.markdown-content h4:hover .heading-anchor,
.markdown-content h5:hover .heading-anchor,
.markdown-content h6:hover .heading-anchor {
  opacity: 1;
}

/* ============================================
   SIDEBAR NAVIGATION
   ============================================ */

.docs-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.docs-sidebar::-webkit-scrollbar {
  width: 6px;
}

.docs-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(16, 16, 31, 0.98);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 4px;
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--fg);
  transition: all 0.3s;
}

/* Sidebar Search */
.sidebar-search {
  padding: 12px 16px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.sidebar-search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  font-size: 13px;
  transition: all 0.2s;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 3px rgba(25, 239, 131, 0.1);
}

.sidebar-search input::placeholder {
  color: var(--dim);
  opacity: 0.7;
}

.sidebar-search .search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.4;
  pointer-events: none;
}

/* Sidebar Navigation */
.sidebar-nav {
  display: flex;
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  flex-direction: column;
  flex-wrap: nowrap;
  align-content: flex-start;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
  gap: 0;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  padding: 8px 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin: 0 0 8px;
  user-select: none;
}

.nav-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  margin: 0;
}

.nav-link {
  display: block;
  padding: 8px 20px;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  line-height: 1.5;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border-left-color: var(--accent);
}

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(25, 239, 131, 0.15) 0%, rgba(25, 239, 131, 0) 100%);
  font-weight: 600;
  text-shadow: 0 0 10px rgba(25, 239, 131, 0.3);
}

/* Nested nav items (subcategories) */
.nav-item .nav-items {
  margin: 4px 0 0 0;
}

.nav-item .nav-items .nav-link {
  padding-left: 36px;
  font-size: 12px;
  color: rgba(234, 234, 234, 0.8);
}

.nav-item .nav-items .nav-link:hover {
  color: #fff;
}

.nav-item .nav-items .nav-link.active {
  color: var(--accent);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content h2 {
  font-size: 28px;
  margin: 32px 0 16px;
  font-weight: 700;
  color: #fff;
}

.main-content h2:first-of-type {
  margin-top: 0;
}

/* Quick Start Section */
.quick-start-section {
  margin-bottom: 48px;
}

.quick-start-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.quick-start-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  transition: all 0.3s;
  text-decoration: none;
  display: block;
}

.quick-start-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(25, 239, 131, 0.1);
}

.quick-start-card h3 {
  font-size: 18px;
  margin: 0 0 8px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-start-card .icon {
  font-size: 24px;
}

.quick-start-card p {
  margin: 0;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.5;
}

/* Categories Section */
.categories-section {
  margin-bottom: 48px;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.category-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
  transition: all 0.2s;
  text-decoration: none;
  display: block;
}

.category-card:hover {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
}

.category-card h3 {
  font-size: 16px;
  margin: 0 0 6px;
  color: #fff;
  font-weight: 600;
}

.category-card .count {
  font-size: 12px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Popular Docs Section */
.popular-section {
  margin-bottom: 48px;
}

.popular-list {
  margin-top: 20px;
}

.popular-item {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: all 0.2s;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.popular-item:hover {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
}

.popular-item-content {
  flex: 1;
}

.popular-item h3 {
  font-size: 16px;
  margin: 0 0 4px;
  color: #fff;
  font-weight: 600;
}

.popular-item .meta {
  font-size: 12px;
  color: var(--dim);
  display: flex;
  gap: 12px;
}

.popular-item .arrow {
  color: var(--accent);
  font-size: 18px;
  transition: transform 0.2s;
}

.popular-item:hover .arrow {
  transform: translateX(4px);
}

/* ============================================
   BREADCRUMBS
   ============================================ */

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--dim);
}

.breadcrumbs a {
  color: var(--dim);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs .separator {
  color: var(--line);
}

.breadcrumbs .current {
  color: #fff;
}

/* ============================================
   TABLE OF CONTENTS (Right Sidebar)
   ============================================ */

.toc-sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 36px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

/* TOC Actions (Copy Button) */
.toc-actions {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.toc-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.toc-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
  color: #fff;
}

.toc-action-btn .icon {
  font-size: 14px;
}

.toc-action-btn.success {
  background: rgba(25, 239, 131, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.toc-sidebar::-webkit-scrollbar {
  width: 4px;
}

.toc-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 2px;
}

.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  margin: 0 0 16px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  margin: 0 0 8px;
}

.toc-link {
  display: block;
  color: var(--dim);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.4;
  padding: 4px 0 4px 12px;
  border-left: 2px solid transparent;
  transition: all 0.2s;
}

.toc-link:hover {
  color: #fff;
  border-left-color: var(--line);
}

.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.toc-link.level-1 {
  font-weight: 700;
  color: var(--fg);
}

.toc-link.level-2 {
  font-weight: 700;
  padding-left: 12px;
}

.toc-link.level-3 {
  padding-left: 24px;
  font-size: 11px;
}

.toc-link code {
  font-family: 'Fira Code', monospace;
  font-size: 0.9em;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

a.heading-anchor {
  padding-left: 8px;
  font-size: 0.75em;
}

/* ============================================
   PREV/NEXT NAVIGATION
   ============================================ */

.doc-navigation {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.doc-nav-link {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 20px;
  text-decoration: none;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-nav-link:hover {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
}

.doc-nav-link.prev {
  align-items: flex-start;
}

.doc-nav-link.next {
  align-items: flex-end;
  text-align: right;
}

.doc-nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.doc-nav-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */

.loading-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--dim);
}

.loading-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-state p {
  margin-top: 12px;
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--dim);
}

.empty-state h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: #fff;
}

.empty-state p {
  font-size: 14px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
  .toc-sidebar {
    display: none;
  }

  .docs-layout {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .docs-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
  }

  .docs-sidebar.open {
    left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .docs-layout {
    flex-direction: column;
  }

  .main-content {
    padding: 24px 16px;
  }

  .doc-content-wrapper {
    padding: 24px 16px;
  }

  .quick-start-grid {
    grid-template-columns: 1fr;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .doc-navigation {
    flex-direction: column;
  }

  .doc-nav-link.next {
    align-items: flex-start;
    text-align: left;
  }

  /* Mobile sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .page-header {
    padding: 24px 16px 16px;
    margin-bottom: 24px;
  }

  h1 {
    font-size: 32px;
  }

  .markdown-content h1 {
    font-size: 28px;
  }

  .markdown-content h2 {
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .categories-grid {
    grid-template-columns: 1fr;
  }

  .popular-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .popular-item .arrow {
    align-self: flex-end;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quick-start-card,
.category-card,
.popular-item {
  animation: fadeIn 0.3s ease-out;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .docs-sidebar,
  .toc-sidebar,
  .doc-navigation,
  .sidebar-toggle,
  .breadcrumbs {
    display: none;
  }

  .main-content {
    max-width: 100%;
    padding: 0;
  }

  .docs-layout {
    display: block;
  }

  .doc-content-wrapper {
    padding: 0;
  }
}

/* ============================================
   KEYBOARD SHORTCUT INDICATOR
   ============================================ */

.kbd {
  display: inline-block;
  padding: 3px 6px;
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1;
  color: var(--fg);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.search-shortcut {
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--dim);
  pointer-events: none;
}
