/* ============================================================
   YeeroAI Documentation System — Shared Stylesheet
   Native HTML · Light/Dark Theme · Responsive
   ============================================================ */

/* === CSS Custom Properties: Light Theme (default) === */
:root {
  /* Core backgrounds */
  --doc-bg: #f8f8f8;
  --doc-surface: #ffffff;
  --doc-surface-hover: #f5f5f5;

  /* Text hierarchy */
  --doc-text-primary: #171717;
  --doc-text-secondary: #525252;
  --doc-text-muted: #a3a3a3;

  /* Borders */
  --doc-border: #e5e5e5;
  --doc-border-subtle: #f0f0f0;

  /* Brand */
  --doc-primary: #2563eb;
  --doc-primary-hover: #1d4ed8;
  --doc-primary-subtle: #eff6ff;
  --doc-primary-foreground: #ffffff;

  /* Code */
  --doc-code-bg: #f5f5f5;
  --doc-code-text: #c7254e;
  --doc-pre-bg: #1e293b;
  --doc-pre-text: #e2e8f0;

  /* Shadows */
  --doc-shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --doc-shadow-md: 0 2px 8px rgba(0,0,0,0.06);

  /* Sidebar */
  --doc-sidebar-bg: #fafafa;
  --doc-sidebar-active: #eff6ff;
  --doc-sidebar-active-text: #2563eb;
  --doc-sidebar-hover: #f5f5f5;

  /* Table */
  --doc-table-header-bg: #f5f5f5;
  --doc-table-stripe: #fafafa;

  /* Tip/Warning boxes */
  --doc-tip-bg: #eff6ff;
  --doc-tip-border: #2563eb;
  --doc-warning-bg: #fffbeb;
  --doc-warning-border: #d97706;
  --doc-danger-bg: #fef2f2;
  --doc-danger-border: #dc2626;

  /* Scrollbar */
  --doc-scrollbar-thumb: #d4d4d4;
  --doc-scrollbar-thumb-hover: #a3a3a3;

  /* TOC */
  --doc-toc-active: #2563eb;

  /* Misc */
  --doc-radius: 8px;
  --doc-transition: 0.2s ease;
  --doc-max-content: 820px;
}

/* === Dark Theme === */
[data-theme="dark"] {
  --doc-bg: #0a0a0a;
  --doc-surface: #1a1a1a;
  --doc-surface-hover: #1f1f1f;

  --doc-text-primary: #ededed;
  --doc-text-secondary: #b4b4b4;
  --doc-text-muted: #6b6b6b;

  --doc-border: #2a2a2a;
  --doc-border-subtle: #1e1e1e;

  --doc-primary: #818cf8;
  --doc-primary-hover: #6366f1;
  --doc-primary-subtle: rgba(99,102,241,0.12);
  --doc-primary-foreground: #ffffff;

  --doc-code-bg: #1f1f1f;
  --doc-code-text: #f472b6;
  --doc-pre-bg: #0f172a;
  --doc-pre-text: #e2e8f0;

  --doc-shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --doc-shadow-md: 0 2px 8px rgba(0,0,0,0.4);

  --doc-sidebar-bg: #121212;
  --doc-sidebar-active: rgba(99,102,241,0.12);
  --doc-sidebar-active-text: #818cf8;
  --doc-sidebar-hover: #1a1a1a;

  --doc-table-header-bg: #1a1a1a;
  --doc-table-stripe: #0f0f0f;

  --doc-tip-bg: rgba(99,102,241,0.08);
  --doc-tip-border: #6366f1;
  --doc-warning-bg: rgba(217,119,6,0.08);
  --doc-warning-border: #d97706;
  --doc-danger-bg: rgba(220,38,38,0.08);
  --doc-danger-border: #dc2626;

  --doc-scrollbar-thumb: rgba(255,255,255,0.15);
  --doc-scrollbar-thumb-hover: rgba(255,255,255,0.25);

  --doc-toc-active: #818cf8;
}

/* === Global Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 72px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--doc-text-primary);
  background-color: var(--doc-bg);
  transition: background-color var(--doc-transition), color var(--doc-transition);
  overflow-x: hidden;
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--doc-scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--doc-scrollbar-thumb-hover);
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--doc-scrollbar-thumb) transparent;
}

/* === Layout: Top Header === */
.doc-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background-color: var(--doc-surface);
  border-bottom: 1px solid var(--doc-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  transition: background-color var(--doc-transition), border-color var(--doc-transition);
}

.doc-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.doc-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.doc-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--doc-text-primary);
  font-weight: 700;
  font-size: 1.125rem;
  transition: color var(--doc-transition);
}

.doc-logo:hover {
  color: var(--doc-primary);
}

.doc-logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: block;
  object-fit: contain;
}

.doc-header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--doc-text-muted);
}

.doc-header-breadcrumb a {
  color: var(--doc-text-secondary);
  text-decoration: none;
  transition: color var(--doc-transition);
}

.doc-header-breadcrumb a:hover {
  color: var(--doc-primary);
}

.doc-header-breadcrumb .sep {
  color: var(--doc-text-muted);
  user-select: none;
}

.doc-header-breadcrumb .current {
  color: var(--doc-text-primary);
  font-weight: 500;
}

.doc-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Header buttons */
.doc-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--doc-border);
  border-radius: 6px;
  background: var(--doc-surface);
  color: var(--doc-text-secondary);
  cursor: pointer;
  transition: all var(--doc-transition);
  font-size: 1rem;
}

.doc-btn-icon:hover {
  background: var(--doc-surface-hover);
  color: var(--doc-text-primary);
  border-color: var(--doc-border);
}

.doc-lang-btn {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* === Layout: Body (Sidebar + Content + TOC) === */
.doc-body {
  display: flex;
  margin-top: 56px;
  min-height: calc(100vh - 56px);
}

/* === Sidebar === */
.doc-sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 260px;
  background-color: var(--doc-sidebar-bg);
  border-right: 1px solid var(--doc-border);
  overflow-y: auto;
  padding: 16px 0;
  transition: background-color var(--doc-transition), border-color var(--doc-transition), transform 0.25s ease;
  z-index: 90;
}

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

.doc-sidebar-heading {
  padding: 8px 20px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--doc-text-muted);
}

.doc-sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  font-size: 0.875rem;
  color: var(--doc-text-secondary);
  text-decoration: none;
  transition: all var(--doc-transition);
  border-left: 3px solid transparent;
}

.doc-sidebar-link:hover {
  background-color: var(--doc-sidebar-hover);
  color: var(--doc-text-primary);
}

.doc-sidebar-link.active {
  background-color: var(--doc-sidebar-active);
  color: var(--doc-sidebar-active-text);
  border-left-color: var(--doc-primary);
  font-weight: 500;
}

.doc-sidebar-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.doc-sidebar-link.active .doc-sidebar-icon {
  opacity: 1;
}

/* === Main Content === */
.doc-main {
  flex: 1;
  min-width: 0;
  margin-left: 260px;
  display: flex;
  justify-content: center;
}

.doc-content-wrapper {
  width: 100%;
  max-width: var(--doc-max-content);
  padding: 40px 40px 80px;
}

/* === TOC (Right side) === */
.doc-toc {
  position: sticky;
  top: 72px;
  width: 200px;
  flex-shrink: 0;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  padding: 0 16px;
  display: none; /* shown on large screens via media query */
}

.doc-toc-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--doc-text-muted);
  margin-bottom: 8px;
}

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

.doc-toc-list li {
  margin-bottom: 2px;
}

.doc-toc-link {
  display: block;
  padding: 3px 0 3px 12px;
  font-size: 0.8125rem;
  color: var(--doc-text-muted);
  text-decoration: none;
  border-left: 2px solid var(--doc-border-subtle);
  transition: all var(--doc-transition);
  line-height: 1.4;
}

.doc-toc-link:hover {
  color: var(--doc-text-primary);
}

.doc-toc-link.active {
  color: var(--doc-toc-active);
  border-left-color: var(--doc-toc-active);
  font-weight: 500;
}

.doc-toc-link[data-level="3"] {
  padding-left: 24px;
  font-size: 0.75rem;
}

/* === Typography === */
.doc-content-wrapper h1 {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--doc-text-primary);
  line-height: 1.3;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.doc-content-wrapper .doc-subtitle {
  font-size: 1.125rem;
  color: var(--doc-text-secondary);
  margin-bottom: 32px;
  line-height: 1.6;
}

.doc-content-wrapper h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--doc-text-primary);
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--doc-border-subtle);
  line-height: 1.35;
}

.doc-content-wrapper h3 {
  font-size: 1.175rem;
  font-weight: 600;
  color: var(--doc-text-primary);
  margin-top: 32px;
  margin-bottom: 12px;
  line-height: 1.4;
}

.doc-content-wrapper h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--doc-text-primary);
  margin-top: 24px;
  margin-bottom: 8px;
}

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

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

.doc-content-wrapper li {
  margin-bottom: 6px;
  color: var(--doc-text-secondary);
}

.doc-content-wrapper strong {
  color: var(--doc-text-primary);
  font-weight: 600;
}

.doc-content-wrapper a {
  color: var(--doc-primary);
  text-decoration: none;
  transition: color var(--doc-transition);
}

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

/* === Code === */
.doc-content-wrapper code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.875em;
}

.doc-content-wrapper :not(pre) > code {
  background-color: var(--doc-code-bg);
  color: var(--doc-code-text);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.doc-content-wrapper pre {
  background-color: var(--doc-pre-bg);
  color: var(--doc-pre-text);
  padding: 16px 20px;
  border-radius: var(--doc-radius);
  margin-bottom: 16px;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 0.875rem;
}

.doc-content-wrapper pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* === Keyboard shortcuts === */
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.75rem;
  color: var(--doc-text-secondary);
  background-color: var(--doc-code-bg);
  border: 1px solid var(--doc-border);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--doc-border);
  line-height: 1.4;
  white-space: nowrap;
}

/* === Tables === */
.doc-content-wrapper table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.doc-content-wrapper th,
.doc-content-wrapper td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--doc-border);
}

.doc-content-wrapper th {
  background-color: var(--doc-table-header-bg);
  font-weight: 600;
  color: var(--doc-text-primary);
}

.doc-content-wrapper tr:nth-child(even) td {
  background-color: var(--doc-table-stripe);
}

/* === Callout Boxes === */
.doc-callout {
  padding: 16px 20px;
  border-radius: var(--doc-radius);
  margin-bottom: 16px;
  border-left: 4px solid;
}

.doc-callout-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc-callout p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.doc-callout.tip {
  background-color: var(--doc-tip-bg);
  border-left-color: var(--doc-tip-border);
}
.doc-callout.tip .doc-callout-title {
  color: var(--doc-tip-border);
}

.doc-callout.warning {
  background-color: var(--doc-warning-bg);
  border-left-color: var(--doc-warning-border);
}
.doc-callout.warning .doc-callout-title {
  color: var(--doc-warning-border);
}

.doc-callout.danger {
  background-color: var(--doc-danger-bg);
  border-left-color: var(--doc-danger-border);
}
.doc-callout.danger .doc-callout-title {
  color: var(--doc-danger-border);
}

/* === Feature Cards (for index page) === */
.doc-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.doc-feature-card {
  display: block;
  padding: 20px;
  background-color: var(--doc-surface);
  border: 1px solid var(--doc-border);
  border-radius: var(--doc-radius);
  text-decoration: none;
  transition: all var(--doc-transition);
}

.doc-feature-card:hover {
  border-color: var(--doc-primary);
  box-shadow: var(--doc-shadow-md);
  text-decoration: none;
}

.doc-feature-card-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
  color: var(--doc-primary);
}

.doc-feature-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--doc-text-primary);
  margin-bottom: 4px;
}

.doc-feature-card-desc {
  font-size: 0.8125rem;
  color: var(--doc-text-muted);
  line-height: 1.5;
}

/* === Step List === */
.doc-steps {
  counter-reset: step-counter;
  list-style: none;
  padding-left: 0;
  margin: 24px 0;
}

.doc-steps li {
  counter-increment: step-counter;
  position: relative;
  padding: 12px 12px 12px 48px;
  margin-bottom: 8px;
  background-color: var(--doc-surface);
  border: 1px solid var(--doc-border-subtle);
  border-radius: var(--doc-radius);
}

.doc-steps li::before {
  content: counter(step-counter);
  position: absolute;
  left: 14px;
  top: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--doc-primary);
  color: var(--doc-primary-foreground);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Navigation: Prev / Next === */
.doc-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--doc-border);
  gap: 16px;
}

.doc-nav-link {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  background-color: var(--doc-surface);
  border: 1px solid var(--doc-border);
  border-radius: var(--doc-radius);
  text-decoration: none;
  flex: 1;
  max-width: 48%;
  transition: all var(--doc-transition);
}

.doc-nav-link:hover {
  border-color: var(--doc-primary);
  box-shadow: var(--doc-shadow-sm);
  text-decoration: none;
}

.doc-nav-link.next {
  align-items: flex-end;
  text-align: right;
}

.doc-nav-link-label {
  font-size: 0.75rem;
  color: var(--doc-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.doc-nav-link-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--doc-primary);
}

/* === Footer === */
.doc-footer {
  margin-top: 48px;
  padding: 24px 0;
  border-top: 1px solid var(--doc-border);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--doc-text-muted);
}

.doc-footer a {
  color: var(--doc-text-secondary);
  text-decoration: none;
}

.doc-footer a:hover {
  color: var(--doc-primary);
}

/* === Mobile sidebar overlay === */
.doc-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 85;
}

.doc-sidebar-overlay.visible {
  display: block;
}

/* === Mobile menu button === */
.doc-mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--doc-text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0;
}

/* === Responsive === */
@media (min-width: 1200px) {
  .doc-main {
    padding-right: 220px;
  }
  .doc-toc {
    display: block;
    position: fixed;
    right: max(calc((100vw - var(--doc-max-content) - 260px - 220px) / 2), 16px);
  }
}

@media (max-width: 1023px) {
  .doc-toc {
    display: none !important;
  }
  .doc-sidebar {
    transform: translateX(-100%);
  }
  .doc-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0,0,0,0.1);
  }
  .doc-main {
    margin-left: 0;
  }
  .doc-mobile-menu-btn {
    display: inline-flex;
  }
  .doc-content-wrapper {
    padding: 32px 24px 64px;
  }
  .doc-content-wrapper h1 {
    font-size: 1.75rem;
  }
  .doc-content-wrapper h2 {
    font-size: 1.25rem;
  }
}

@media (max-width: 640px) {
  .doc-header {
    padding: 0 16px;
  }
  .doc-header-breadcrumb {
    display: none;
  }
  .doc-content-wrapper {
    padding: 24px 16px 48px;
  }
  .doc-content-wrapper h1 {
    font-size: 1.5rem;
  }
  .doc-nav-footer {
    flex-direction: column;
  }
  .doc-nav-link {
    max-width: 100%;
  }
  .doc-feature-grid {
    grid-template-columns: 1fr;
  }
}

/* === Print === */
@media print {
  .doc-header,
  .doc-sidebar,
  .doc-toc,
  .doc-sidebar-overlay,
  .doc-nav-footer,
  .doc-footer {
    display: none !important;
  }
  .doc-main {
    margin-left: 0 !important;
    padding-right: 0 !important;
  }
  body {
    background: #fff;
    color: #000;
  }
}
