/* ========================================
   Tailwind CSS Builder Documentation Styles
   Inspired by Tailwind CSS Documentation
   ======================================== */

/* CSS Variables */
:root {
  --color-primary: #0ea5e9;
  --color-primary-dark: #0284c7;
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-bg-tertiary: #f1f5f9;
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --sidebar-width: 18rem;
  --toc-width: 16rem;
  --header-height: 4rem;
}

.dark {
  --color-bg: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-bg-tertiary: #334155;
  --color-text: #f1f5f9;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #94a3b8;
  --color-border: #334155;
  --color-border-light: #1e293b;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  margin: 0;
  padding: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Header */
.docs-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  z-index: 50;
}

.docs-header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.docs-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.docs-logo:hover {
  text-decoration: none;
}

.docs-logo-icon {
  width: 2rem;
  height: 2rem;
}

.docs-badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  background: var(--color-primary);
  color: white;
  border-radius: 9999px;
}

.docs-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Search Button */
.docs-search-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.docs-search-btn:hover {
  border-color: var(--color-text-muted);
}

.docs-kbd {
  display: none;
  font-size: 0.75rem;
  font-family: inherit;
  padding: 0.125rem 0.375rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  color: var(--color-text-muted);
}

@media (min-width: 640px) {
  .docs-kbd {
    display: inline;
  }
}

/* Icon Button */
.docs-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background-color 0.15s, color 0.15s;
}

.docs-icon-btn:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

.docs-icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* Dark mode toggle icons */
.dark .sun-icon {
  display: block;
}

.dark .moon-icon {
  display: none;
}

.sun-icon {
  display: none;
}

.moon-icon {
  display: block;
}

/* Mobile menu button */
.mobile-only {
  display: flex;
}

@media (min-width: 1024px) {
  .mobile-only {
    display: none;
  }
}

/* Mobile Navigation Overlay */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 25;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.mobile-nav-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Layout */
.docs-layout {
  padding-top: var(--header-height);
}

@media (min-width: 1024px) {
  .docs-layout {
    padding-left: var(--sidebar-width);
  }
}

@media (min-width: 1280px) {
  .docs-layout {
    padding-right: var(--toc-width);
  }
}

/* Sidebar */
.docs-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg);
  z-index: 30;
  transform: translateX(-100%);
  transition: transform 0.2s;
}

.docs-sidebar.active {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  .docs-sidebar {
    transform: translateX(0);
  }
}

.docs-nav {
  padding: 1.5rem 1rem;
}

/* Navigation Sections */
.nav-section {
  margin-bottom: 2rem;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
}

.nav-section-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-link {
  display: block;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  border-radius: 0.375rem;
  transition: color 0.15s, background-color 0.15s;
}

.nav-link:hover {
  color: var(--color-text);
  background: var(--color-bg-secondary);
  text-decoration: none;
}

.nav-link.active {
  color: var(--color-primary);
  font-weight: 500;
  background: rgba(14, 165, 233, 0.1);
}

/* Main Content */
.docs-main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Breadcrumbs */
.docs-breadcrumbs {
  margin-bottom: 1.5rem;
}

.docs-breadcrumbs ol {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.875rem;
}

.docs-breadcrumbs a {
  color: var(--color-text-muted);
}

.docs-breadcrumbs a:hover {
  color: var(--color-text);
}

.docs-breadcrumbs .separator {
  color: var(--color-text-muted);
}

.docs-breadcrumbs .current {
  color: var(--color-text);
  font-weight: 500;
}

/* Page Header */
.docs-page-header {
  margin-bottom: 2rem;
}

.docs-page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.025em;
}

@media (min-width: 640px) {
  .docs-page-header h1 {
    font-size: 2.5rem;
  }
}

.docs-page-description {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* Prose (Content Styling) */
.prose {
  color: var(--color-text);
}

.prose h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.prose h2:first-child {
  margin-top: 0;
}

.prose h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem 0;
}

.prose h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem 0;
}

.prose p {
  margin: 0 0 1rem 0;
}

.prose ul,
.prose ol {
  margin: 0 0 1rem 0;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose li > ul,
.prose li > ol {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.prose strong {
  font-weight: 600;
}

.prose code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
  padding: 0.2em 0.4em;
  background: var(--color-bg-secondary);
  border-radius: 0.25rem;
  color: var(--color-text);
}

.prose pre {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.prose pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
}

/* Code block wrapper with language label and copy button */
.code-block-wrapper {
  position: relative;
}

.code-block-wrapper::before {
  content: attr(data-language);
  position: absolute;
  top: 0;
  right: 3rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  background: #1e293b;
  border-radius: 0 0 0.25rem 0.25rem;
  z-index: 1;
}

.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.375rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  color: #94a3b8;
  transition: color 0.15s, background-color 0.15s;
  z-index: 2;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

.code-copy-btn.copied {
  color: #22c55e;
}

/* Dark mode Prism overrides */
.dark pre[class*="language-"],
pre[class*="language-"] {
  background: #0f172a;
  margin: 1.5rem 0;
}

.dark code[class*="language-"],
code[class*="language-"] {
  color: #e2e8f0;
}

.prose a {
  color: var(--color-primary);
  font-weight: 500;
}

.prose a:hover {
  text-decoration: underline;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  margin: 1.5rem 0;
}

.prose figure {
  margin: 1.5rem 0;
}

.prose figcaption {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 0.75rem;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}

.prose th,
.prose td {
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--color-border);
}

.prose th {
  font-weight: 600;
  background: var(--color-bg-secondary);
}

.prose tr:nth-child(even) {
  background: var(--color-bg-secondary);
}

/* Callout Boxes */
.callout {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.callout-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout-info {
  background: rgba(59, 130, 246, 0.1);
  border-left: 4px solid #3b82f6;
}

.callout-info .callout-title {
  color: #3b82f6;
}

.callout-warning {
  background: rgba(234, 179, 8, 0.1);
  border-left: 4px solid #eab308;
}

.callout-warning .callout-title {
  color: #ca8a04;
}

.callout-danger {
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid #ef4444;
}

.callout-danger .callout-title {
  color: #ef4444;
}

.callout-success {
  background: rgba(34, 197, 94, 0.1);
  border-left: 4px solid #22c55e;
}

.callout-success .callout-title {
  color: #22c55e;
}

.callout-pro {
  background: rgba(168, 85, 247, 0.1);
  border-left: 4px solid #a855f7;
}

.callout-pro .callout-title {
  color: #a855f7;
}

/* On-page Table of Contents */
.docs-toc {
  display: none;
}

@media (min-width: 1280px) {
  .docs-toc {
    display: block;
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: var(--toc-width);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 1.5rem 1rem;
    font-size: 0.875rem;
  }
}

.docs-toc h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 1rem 0;
}

.docs-toc nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toc-link {
  color: var(--color-text-muted);
  transition: color 0.15s;
}

.toc-link:hover {
  color: var(--color-text);
  text-decoration: none;
}

.toc-link.active {
  color: var(--color-primary);
}

.toc-link.toc-h3 {
  padding-left: 1rem;
}

/* Pagination */
.docs-pagination {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.docs-pagination-link {
  display: flex;
  flex-direction: column;
  max-width: 50%;
}

.docs-pagination-link:hover {
  text-decoration: none;
}

.docs-pagination-link.next {
  text-align: right;
  margin-left: auto;
}

.docs-pagination-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.docs-pagination-title {
  font-weight: 500;
  color: var(--color-text);
  transition: color 0.15s;
}

.docs-pagination-link:hover .docs-pagination-title {
  color: var(--color-primary);
}

/* Search Modal */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.search-modal.active {
  opacity: 1;
  visibility: visible;
}

.search-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.search-modal-content {
  position: relative;
  width: 100%;
  max-width: 36rem;
  background: var(--color-bg);
  border-radius: 0.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.search-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.search-modal-header .docs-icon {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.search-modal-header input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--color-text);
  outline: none;
}

.search-modal-header input::placeholder {
  color: var(--color-text-muted);
}

.search-results {
  max-height: 24rem;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-hint {
  padding: 1rem;
  text-align: center;
  color: var(--color-text-muted);
  margin: 0;
}

.search-result {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  color: var(--color-text);
  transition: background-color 0.15s;
}

.search-result:hover,
.search-result.selected {
  background: var(--color-bg-secondary);
  text-decoration: none;
}

.search-result.selected {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.search-result-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.search-result-section {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.search-no-results {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* Cards for homepage */
.docs-card-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
  margin: 2rem 0;
}

@media (min-width: 640px) {
  .docs-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.docs-card {
  display: block;
  padding: 1.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.docs-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.1);
  text-decoration: none;
}

.docs-card-icon {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 1rem;
  color: var(--color-primary);
}

.docs-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--color-text);
}

.docs-card p {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* Step-by-step instructions */
.docs-steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.docs-steps li {
  position: relative;
  padding-left: 2.5rem;
  padding-bottom: 1.5rem;
  border-left: 2px solid var(--color-border);
}

.docs-steps li:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.docs-steps li::before {
  content: counter(step);
  counter-increment: step;
  position: absolute;
  left: -0.875rem;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--color-primary);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Keyboard shortcuts */
kbd {
  font-family: inherit;
  font-size: 0.875em;
  padding: 0.125rem 0.375rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  box-shadow: 0 1px 0 var(--color-border);
}

/* Video container */
.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Responsive adjustments */
@media (max-width: 639px) {
  .docs-search-btn span {
    display: none;
  }

  .docs-page-header h1 {
    font-size: 1.75rem;
  }

  .docs-pagination {
    flex-direction: column;
  }

  .docs-pagination-link {
    max-width: 100%;
  }

  .docs-pagination-link.next {
    text-align: left;
    margin-left: 0;
  }
}

/* Print styles */
@media print {
  .docs-header,
  .docs-sidebar,
  .docs-toc,
  .docs-pagination,
  .search-modal {
    display: none !important;
  }

  .docs-layout {
    padding: 0;
  }

  .docs-main {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
}

/* Utility classes */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
