/* Kitbix Commerce Docs Styles */
:root {
  /* Brand */
  --kb-primary: #2563eb;
  --kb-primary-soft: #dbeafe;
  --kb-accent: #f59e0b;

  /* Backgrounds */
  --kb-bg-main: #f8fafc;
  --kb-bg-surface: #ffffff;
  --kb-bg-muted: #f1f5f9;

  /* Text */
  --kb-text-main: #0f172a;
  --kb-text-secondary: #475569;
  --kb-text-muted: #64748b;

  /* Borders */
  --kb-border-light: #e2e8f0;
  --kb-border-muted: #cbd5e1;

  /* Links */
  --kb-link: var(--kb-primary);
  --kb-link-hover: #1e40af;

  /* Radius */
  --kb-radius-sm: 6px;
  --kb-radius-md: 10px;
  --kb-radius-lg: 16px;

  --kb-max-width: 1100px;
  --kb-line-height: 1.7;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--kb-text-main);
  background: var(--kb-bg-main);
  line-height: var(--kb-line-height);
}

a {
  color: var(--kb-link);
  text-decoration: none;
}

a:hover, a:focus {
  color: var(--kb-link-hover);
}

.docs-header {
  background: var(--kb-bg-surface);
  border-bottom: 1px solid var(--kb-border-light);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.docs-header .brand {
  font-weight: 600;
  color: var(--kb-text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-nav-toggle {
  display: none;
  border: none;
  background: var(--kb-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--kb-radius-sm);
  font-weight: 600;
}

.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  max-width: 1400px;
  margin: 0 auto;
}

.docs-sidebar {
  background: var(--kb-bg-surface);
  border-right: 1px solid var(--kb-border-light);
  min-height: calc(100vh - 72px);
  position: sticky;
  top: 72px;
}

.sidebar-inner {
  padding: 1.5rem;
  height: 100%;
}

.sidebar-inner .logo {
  font-weight: 700;
  display: block;
  margin-bottom: 1rem;
  color: var(--kb-text-main);
}

.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-section {
  border: 1px solid var(--kb-border-light);
  border-radius: var(--kb-radius-md);
  background: var(--kb-bg-surface);
}

.nav-section__toggle {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--kb-text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.nav-section__toggle::after {
  content: '▾';
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}

.nav-section.collapsed .nav-section__toggle::after {
  transform: rotate(-90deg);
}

.nav-section ul {
  margin: 0;
  padding: 0 0 0.5rem 0;
  list-style: none;
  border-top: 1px solid var(--kb-border-light);
}

.nav-section li {
  margin: 0;
}

.nav-section a {
  display: block;
  padding: 0.4rem 1.25rem;
  color: var(--kb-text-secondary);
  border-left: 3px solid transparent;
}

.nav-section a.active {
  border-left-color: var(--kb-primary);
  color: var(--kb-primary);
  font-weight: 600;
  background: var(--kb-primary-soft);
}

.docs-content {
  padding: 2rem 3rem;
  max-width: var(--kb-max-width);
  width: 100%;
}

.page-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--kb-text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.page-title {
  font-size: 2rem;
  margin: 0 0 1rem;
}

.page-intro {
  color: var(--kb-text-secondary);
  margin-bottom: 2rem;
}

.section-title {
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.callout {
  border-radius: var(--kb-radius-md);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border: 1px solid var(--kb-border-light);
  background: var(--kb-bg-muted);
}

.callout.tip {
  border-color: var(--kb-primary);
  background: var(--kb-primary-soft);
}

.callout.warning {
  border-color: #f97316;
  background: #fff7ed;
}

.callout.info {
  border-color: #38bdf8;
  background: #ecfeff;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--kb-radius-md);
  padding: 1rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  overflow-x: auto;
  font-size: 0.9rem;
}

.screenshot {
  margin: 2rem 0;
}

.screenshot__frame {
  border: 1px dashed var(--kb-border-muted);
  border-radius: var(--kb-radius-lg);
  background: var(--kb-bg-muted);
  padding: 2rem;
  text-align: center;
  color: var(--kb-text-muted);
}

.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.docs-table th,
.docs-table td {
  border: 1px solid var(--kb-border-light);
  padding: 0.75rem 1rem;
  text-align: left;
}

.docs-table th {
  background: var(--kb-bg-muted);
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.quick-card {
  border-radius: var(--kb-radius-md);
  border: 1px solid var(--kb-border-light);
  background: var(--kb-bg-surface);
  padding: 1.25rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.quick-card:hover {
  border-color: var(--kb-primary);
  transform: translateY(-2px);
}

.quick-card h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.search-box {
  max-width: 500px;
  margin-top: 1rem;
}

.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;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--kb-radius-md);
  border: 1px solid var(--kb-border-light);
  font-size: 1rem;
}

.search-results {
  margin-top: 1rem;
  background: var(--kb-bg-surface);
  border: 1px solid var(--kb-border-light);
  border-radius: var(--kb-radius-md);
  display: none;
}

.search-results.active {
  display: block;
}

.search-results li {
  list-style: none;
  border-bottom: 1px solid var(--kb-border-light);
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results a {
  display: block;
  padding: 0.75rem 1rem;
}

.code-inline {
  background: #0f172a;
  color: #f8fafc;
  padding: 0.1rem 0.4rem;
  border-radius: var(--kb-radius-sm);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
}

.breadcrumbs {
  font-size: 0.9rem;
  color: var(--kb-text-muted);
  margin-bottom: 1rem;
}

@media (max-width: 960px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 15;
    box-shadow: 0 0 40px rgba(15, 23, 42, 0.1);
  }

  body.nav-open .docs-sidebar {
    transform: translateX(0);
  }

  body.nav-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 10;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }

  .docs-content {
    padding: 1.5rem;
  }
}
