/* =============================================================================
   VitePress-Style Documentation Theme
   Clean, modern documentation styling inspired by Vue.js docs
   ============================================================================= */

/* Custom CSS Variables for Design System */
:root {
  /* Typography */
  --font-family-sans: "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-family-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Spacing and Layout */
  --vp-nav-height: 64px;
  --vp-sidebar-width: 272px;
  --vp-toc-width: 256px;
  --vp-content-width: 720px;

  /* Border radius */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* =============================================================================
   Base Styles
   ============================================================================= */

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--vp-nav-height) + 24px);
  height: 100%;
}

body {
  font-family: var(--font-family-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ide-text-primary);
  background: var(--ide-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--ide-accent-primary);
  outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--ide-content-bg);
  color: var(--ide-text-primary);
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: 100;
  border-radius: var(--border-radius-md);
}

.skip-link:focus {
  top: 8px;
  left: 8px;
}

/* =============================================================================
   VitePress Navbar
   ============================================================================= */

.vp-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--vp-nav-height);
  background: var(--ide-bg);
  border-bottom: 1px solid var(--ide-border);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  backdrop-filter: blur(12px);
  background: rgba(var(--ide-bg), 0.85);
}

.vp-nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 18px;
  font-weight: 600;
  color: var(--ide-text-primary);
}

.vp-nav-brand:hover {
  color: var(--ide-accent-primary);
}

.vp-nav-brand svg {
  width: 24px;
  height: 24px;
}

.vp-nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.vp-nav-link {
  color: var(--ide-text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.vp-nav-link:hover {
  color: var(--ide-text-primary);
}

.vp-nav-link.active {
  color: var(--ide-accent-primary);
  border-bottom-color: var(--ide-accent-primary);
}

.vp-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vp-nav-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--border-radius-md);
  background: transparent;
  color: var(--ide-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.vp-nav-action:hover {
  background: var(--ide-hover-bg);
  color: var(--ide-text-primary);
}

.vp-nav-action svg {
  width: 20px;
  height: 20px;
}

/* Mobile menu button */
.vp-mobile-menu-btn {
  display: none;
}

@media (max-width: 768px) {
  .vp-mobile-menu-btn {
    display: flex;
  }

  .vp-nav-links {
    display: none;
  }
}

/* =============================================================================
   VitePress Theme Toggle Switch
   ============================================================================= */

.vp-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 20px;
  transition: background-color 0.2s ease;
}

.vp-theme-toggle:hover {
  background-color: var(--ide-hover-bg);
}

.vp-theme-toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  width: 44px;
  height: 24px;
  background: var(--ide-border);
  border-radius: 12px;
  padding: 2px;
  transition: background-color 0.3s ease;
}

/* Dark mode: darker track */
.dark .vp-theme-toggle-track {
  background: #3a3a3a;
}

/* The sliding thumb */
.vp-theme-toggle-thumb {
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  left: 3px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Dark mode: thumb slides right */
.dark .vp-theme-toggle-thumb {
  transform: translateX(20px);
}

/* Icons */
.vp-theme-icon {
  position: absolute;
  width: 14px;
  height: 14px;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.vp-theme-icon-sun {
  left: 5px;
  color: #888;
}

.vp-theme-icon-moon {
  right: 5px;
  color: #888;
}

/* Light mode: sun is visible and highlighted */
.vp-theme-icon-sun {
  opacity: 1;
  color: #f59e0b;
}

.vp-theme-icon-moon {
  opacity: 0.4;
}

/* Dark mode: moon is visible and highlighted */
.dark .vp-theme-icon-sun {
  opacity: 0.4;
  color: #888;
}

.dark .vp-theme-icon-moon {
  opacity: 1;
  color: #8b5cf6;
}

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

.vp-layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--vp-nav-height);
}

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

.vp-sidebar {
  position: fixed;
  top: var(--vp-nav-height);
  left: 0;
  bottom: 0;
  width: var(--vp-sidebar-width);
  background: var(--ide-sidebar-bg);
  border-right: 1px solid var(--ide-border);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 50;
}

.vp-sidebar-group {
  margin-bottom: 24px;
}

.vp-sidebar-heading {
  padding: 0 20px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ide-text-primary);
  text-transform: capitalize;
}

.vp-sidebar-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.vp-sidebar-item {
  margin: 0;
}

.vp-sidebar-link {
  display: block;
  padding: 8px 20px;
  font-size: 14px;
  color: var(--ide-text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all var(--transition-fast);
}

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

.vp-sidebar-link.active {
  color: var(--ide-accent-primary);
  background: var(--ide-active-bg);
  border-left-color: var(--ide-accent-primary);
  font-weight: 500;
}

/* Nested sidebar items */
.vp-sidebar-nested {
  list-style: none;
  margin: 0;
  padding: 0;
}

.vp-sidebar-nested .vp-sidebar-link {
  padding-left: 36px;
  font-size: 13px;
}

/* Sidebar group collapse toggle */
.vp-sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ide-text-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.vp-sidebar-toggle:hover {
  background: var(--ide-hover-bg);
}

.vp-sidebar-toggle svg {
  width: 16px;
  height: 16px;
  color: var(--ide-text-tertiary);
  transition: transform var(--transition-fast);
}

.vp-sidebar-toggle.collapsed svg {
  transform: rotate(-90deg);
}

/* Mobile sidebar */
@media (max-width: 960px) {
  .vp-sidebar {
    position: fixed;
    left: -100%;
    transition: left var(--transition-base);
    z-index: 60;
    width: 280px;
    box-shadow: var(--shadow-lg);
  }

  .vp-sidebar.open {
    left: 0;
  }
}

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

.vp-content {
  flex: 1;
  margin-left: var(--vp-sidebar-width);
  min-width: 0;
  box-sizing: border-box;
}

.vp-doc {
  max-width: var(--vp-content-width);
  width: 100%;
}

@media (max-width: 960px) {
  .vp-content {
    margin-left: 0;
  }
}

/* =============================================================================
   "On This Page" TOC (Right Sidebar)
   ============================================================================= */

.vp-toc {
  position: fixed;
  top: calc(var(--vp-nav-height) + 48px);
  right: 24px;
  width: var(--vp-toc-width);
  max-height: calc(100vh - var(--vp-nav-height) - 96px);
  overflow-y: auto;
}

.vp-toc-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ide-text-primary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vp-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--ide-border);
  padding-left: 12px;
}

.vp-toc-list li {
  margin: 0;
}

.vp-toc-link {
  display: block;
  padding: 4px 0;
  font-size: 13px;
  color: var(--ide-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
  line-height: 1.4;
}

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

.vp-toc-link.active {
  color: var(--ide-accent-primary);
  font-weight: 500;
}

/* Nested TOC */
.vp-toc-list .vp-toc-list {
  border-left: none;
  padding-left: 12px;
  margin-top: 4px;
}

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

/* =============================================================================
   Documentation Content Styles
   ============================================================================= */

.vp-doc-content {
  color: var(--ide-text-primary);
  line-height: 1.7;
}

.vp-doc-content h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
}

.vp-doc-content h2 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.35;
  margin: 48px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ide-border);
}

.vp-doc-content h3 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  margin: 32px 0 12px;
}

.vp-doc-content h4 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  margin: 24px 0 8px;
}

.vp-doc-content p {
  margin: 16px 0;
}

.vp-doc-content a {
  color: var(--ide-accent-primary);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
  transition: text-decoration-color var(--transition-fast);
}

.vp-doc-content a:hover {
  text-decoration-color: var(--ide-accent-primary);
}

/* Lists */
.vp-doc-content ul,
.vp-doc-content ol {
  margin: 16px 0;
  padding-left: 24px;
}

.vp-doc-content li {
  margin: 8px 0;
}

.vp-doc-content li > ul,
.vp-doc-content li > ol {
  margin: 8px 0;
}

/* Tables */
.vp-doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}

.vp-doc-content th,
.vp-doc-content td {
  border: 1px solid var(--ide-border);
  padding: 12px 16px;
  text-align: left;
}

.vp-doc-content th {
  background: var(--ide-hover-bg);
  font-weight: 600;
  white-space: nowrap;
}

.vp-doc-content tr:hover td {
  background: var(--ide-hover-bg);
}

/* Blockquotes */
.vp-doc-content blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--ide-accent-primary);
  background: var(--ide-hover-bg);
  border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
  color: var(--ide-text-secondary);
}

.vp-doc-content blockquote p:first-child {
  margin-top: 0;
}

.vp-doc-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Horizontal Rule */
.vp-doc-content hr {
  border: none;
  border-top: 1px solid var(--ide-border);
  margin: 48px 0;
}

/* Inline Code */
.vp-doc-content code:not(pre code) {
  background: var(--ide-hover-bg);
  color: var(--ide-text-primary);
  padding: 3px 6px;
  border-radius: var(--border-radius-sm);
  font-size: 0.875em;
  font-family: var(--font-family-mono);
}

/* Code Blocks */
.vp-doc-content pre {
  margin: 24px 0;
  padding: 20px 24px;
  background: var(--syntax-pre-bg);
  border: 1px solid var(--ide-border);
  border-radius: var(--border-radius-md);
  overflow-x: auto;
}

.vp-doc-content pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--syntax-text);
}

/* Images */
.vp-doc-content img {
  max-width: 100%;
  border-radius: var(--border-radius-md);
}

/* =============================================================================
   VitePress-Style Callouts / Custom Blocks
   ============================================================================= */

.vp-custom-block {
  margin: 24px 0;
  padding: 16px 20px;
  border-radius: var(--border-radius-md);
  border-left: 4px solid;
}

.vp-custom-block.info {
  background: rgba(66, 184, 131, 0.1);
  border-left-color: var(--ide-accent-primary);
}

.vp-custom-block.tip {
  background: rgba(66, 184, 131, 0.1);
  border-left-color: var(--ide-accent-primary);
}

.vp-custom-block.warning {
  background: rgba(234, 179, 8, 0.1);
  border-left-color: #eab308;
}

.vp-custom-block.danger {
  background: rgba(239, 68, 68, 0.1);
  border-left-color: #ef4444;
}

.vp-custom-block-title {
  font-weight: 600;
  margin-bottom: 8px;
}

/* =============================================================================
   Page Navigation (Prev/Next)
   ============================================================================= */

.vp-page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--ide-border);
}

.vp-page-nav-link {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  border: 1px solid var(--ide-border);
  border-radius: var(--border-radius-md);
  text-decoration: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.vp-page-nav-link:hover {
  border-color: var(--ide-accent-primary);
  box-shadow: var(--shadow-sm);
}

.vp-page-nav-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ide-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.vp-page-nav-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ide-accent-primary);
}

.vp-page-nav-link.next {
  text-align: right;
  grid-column: 2;
}

.vp-page-nav-link.prev {
  grid-column: 1;
}

@media (max-width: 640px) {
  .vp-page-nav {
    grid-template-columns: 1fr;
  }

  .vp-page-nav-link.next,
  .vp-page-nav-link.prev {
    grid-column: 1;
    text-align: left;
  }
}

/* =============================================================================
   Footer
   ============================================================================= */

.vp-footer {
  border-top: 1px solid var(--ide-border);
  padding: 24px;
  text-align: center;
}

.vp-footer-content {
  max-width: var(--vp-content-width);
  margin: 0 auto;
  font-size: 14px;
  color: var(--ide-text-secondary);
}

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

.vp-footer a:hover {
  color: var(--ide-accent-primary);
}

/* =============================================================================
   Sidebar Overlay (Mobile)
   ============================================================================= */

.vp-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 55;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.vp-sidebar-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* =============================================================================
   Print Styles
   ============================================================================= */

@media print {
  .vp-nav,
  .vp-sidebar,
  .vp-toc,
  .vp-page-nav,
  .vp-footer,
  .no-print {
    display: none !important;
  }

  .vp-content {
    margin-left: 0;
  }

  .vp-doc {
    max-width: 100%;
    padding: 0;
  }

  .vp-doc-content {
    font-size: 12pt;
    line-height: 1.5;
  }

  .vp-doc-content h1 { font-size: 24pt; }
  .vp-doc-content h2 { font-size: 18pt; }
  .vp-doc-content h3 { font-size: 14pt; }

  .vp-doc-content a {
    text-decoration: none;
    color: inherit;
  }
}

/* =============================================================================
   Reduced Motion
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
