/* ═══════════════════════════════════════════════════
   Deliverty Hub Documentation — Design System
   ═══════════════════════════════════════════════════ */

/* ─── Fonts ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── CSS Variables ─── */
:root {
  /* Brand Teal Scale (HSL) */
  --teal-50:  #eef8fa;
  --teal-100: #d5eef3;
  --teal-200: #afdde8;
  --teal-300: #7ac5d6;
  --teal-400: #44a9bf;
  --teal-500: #2E9BB8; /* primary */
  --teal-600: #267d95;
  --teal-700: #1f6579;
  --teal-800: #194f5e;
  --teal-900: #143d49;
  --teal-950: #0a2530;

  /* Gold Accent */
  --gold: #d4a843;
  --gold-light: #e8cc7a;
  --gold-dark: #b08a2e;

  /* Semantic */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Light Theme */
  --bg: #ffffff;
  --bg-secondary: #f8fafb;
  --bg-tertiary: #f0f4f5;
  --text: #1a2332;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border: #e2e8f0;
  --border-light: #edf2f7;

  /* Sidebar */
  --sidebar-bg: #f8fafb;
  --sidebar-width: 280px;
  --sidebar-border: #e2e8f0;

  /* Header */
  --header-height: 60px;
  --header-bg: #ffffff;
  --header-border: #e2e8f0;

  /* Content */
  --content-max-width: 820px;
  --toc-width: 220px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);

  /* Transitions */
  --transition: 200ms ease;

  /* Radius */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* ─── Dark Theme ─── */
[data-theme="dark"] {
  --bg: #0d1b2a;
  --bg-secondary: #112233;
  --bg-tertiary: #162a3d;
  --text: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --border: #1e3a50;
  --border-light: #162a3d;

  --sidebar-bg: #0f1f30;
  --sidebar-border: #1e3a50;

  --header-bg: #0d1b2a;
  --header-border: #1e3a50;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);

  --teal-50: #0a2530;
  --teal-100: #0f3040;
}

/* ─── Reset ─── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Typography ─── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-top: 2em;
  margin-bottom: 0.6em;
}

h1 { font-size: 2rem; font-weight: 800; margin-top: 0; }
h2 { font-size: 1.5rem; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5, h6 { font-size: 1rem; color: var(--text-secondary); }

p {
  margin-bottom: 1em;
}

a {
  color: var(--teal-500);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--teal-600);
  text-decoration: underline;
}

strong { font-weight: 600; }

ul, ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

li { margin-bottom: 0.35em; }

li > ul, li > ol {
  margin-top: 0.35em;
  margin-bottom: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

img {
  max-width: 100%;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.9em;
}

th, td {
  padding: 0.65em 1em;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text);
  white-space: nowrap;
}

tr:hover td {
  background: var(--bg-secondary);
}

/* ─── Code ─── */
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85em;
  background: var(--bg-tertiary);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--teal-600);
}

[data-theme="dark"] code {
  color: var(--teal-400);
}

pre {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1em 1.2em;
  overflow-x: auto;
  margin-bottom: 1.5em;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.85em;
}

/* Copy button for code blocks */
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.75em;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}

pre:hover .code-copy {
  opacity: 1;
}

.code-copy:hover {
  background: var(--teal-500);
  color: white;
  border-color: var(--teal-500);
}

.code-copy.copied {
  background: var(--success);
  color: white;
  border-color: var(--success);
  opacity: 1;
}

/* ═══════════════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════════════ */

/* ─── Header ─── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.header-logo img {
  height: 32px;
  width: auto;
  border-radius: 0;
}

.header-logo span {
  white-space: nowrap;
}

.header-logo .docs-badge {
  font-size: 0.65em;
  font-weight: 500;
  color: var(--teal-500);
  background: var(--teal-50);
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 2px;
}

[data-theme="dark"] .header-logo .docs-badge {
  background: rgba(46, 155, 184, 0.15);
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 24px;
}

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

/* Search trigger */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85em;
  min-width: 220px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-trigger:hover {
  border-color: var(--teal-400);
  box-shadow: 0 0 0 3px rgba(46, 155, 184, 0.1);
}

.search-trigger kbd {
  font-family: 'Inter', sans-serif;
  font-size: 0.8em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: auto;
  color: var(--text-muted);
}

.search-trigger svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--teal-500);
  border-color: var(--teal-400);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  padding: 20px 0;
  z-index: 90;
  transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 0.8em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.sidebar-heading:hover {
  color: var(--teal-500);
}

.sidebar-heading .chevron {
  width: 16px;
  height: 16px;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.sidebar-heading.collapsed .chevron {
  transform: rotate(-90deg);
}

.sidebar-links {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.sidebar-links.collapsed {
  max-height: 0 !important;
}

.sidebar-links a {
  display: block;
  padding: 6px 20px 6px 28px;
  color: var(--text-secondary);
  font-size: 0.88em;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all var(--transition);
}

.sidebar-links a:hover {
  color: var(--teal-500);
  background: rgba(46, 155, 184, 0.05);
  text-decoration: none;
}

.sidebar-links a.active {
  color: var(--teal-500);
  background: rgba(46, 155, 184, 0.08);
  border-left-color: var(--teal-500);
  font-weight: 500;
}

/* Nested links */
.sidebar-links .nested {
  padding-left: 40px;
  font-size: 0.85em;
}

/* Persona tag in sidebar */
.sidebar-persona-tag {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

.sidebar-persona-tag.admin { background: rgba(46,155,184,0.12); color: var(--teal-600); }
.sidebar-persona-tag.business { background: rgba(34,197,94,0.12); color: var(--success); }
.sidebar-persona-tag.agent { background: rgba(249,115,22,0.12); color: #ea580c; }
.sidebar-persona-tag.developer { background: rgba(59,130,246,0.12); color: var(--info); }
.sidebar-persona-tag.courier { background: rgba(212,168,67,0.12); color: var(--gold-dark); }

/* ─── Main Content ─── */
.main {
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
}

.content-wrapper {
  display: flex;
  max-width: calc(var(--content-max-width) + var(--toc-width) + 80px);
  margin: 0 auto;
  padding: 32px 40px;
}

.content {
  flex: 1;
  max-width: var(--content-max-width);
  min-width: 0;
}

/* ─── Breadcrumbs ─── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  font-size: 0.85em;
  color: var(--text-muted);
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs a:hover {
  color: var(--teal-500);
  text-decoration: none;
}

.breadcrumbs .sep {
  color: var(--border);
  font-size: 0.8em;
}

/* ─── Table of Contents (right side) ─── */
.toc {
  position: sticky;
  top: calc(var(--header-height) + 32px);
  width: var(--toc-width);
  max-height: calc(100vh - var(--header-height) - 64px);
  overflow-y: auto;
  margin-left: 40px;
  padding-left: 20px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.toc-title {
  font-size: 0.75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 4px 0;
  font-size: 0.82em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.toc-list a:hover {
  color: var(--teal-500);
  text-decoration: none;
}

.toc-list a.active {
  color: var(--teal-500);
  font-weight: 500;
}

.toc-list .toc-h3 {
  padding-left: 12px;
}

.toc-list .toc-h4 {
  padding-left: 24px;
}

/* ─── Footer ─── */
.footer {
  margin-left: var(--sidebar-width);
  padding: 32px 40px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85em;
}

.footer a {
  color: var(--teal-500);
}

/* Page nav (prev/next) */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.page-nav a {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  max-width: 50%;
}

.page-nav a:hover {
  border-color: var(--teal-400);
  background: var(--bg-secondary);
  text-decoration: none;
}

.page-nav .label {
  font-size: 0.75em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page-nav .title {
  font-weight: 600;
  color: var(--teal-500);
}

.page-nav .next { text-align: right; margin-left: auto; }

/* ─── Search Modal ─── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.search-overlay.open {
  display: flex;
}

.search-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.search-input-wrapper svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 1rem;
  color: var(--text);
  font-family: inherit;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.search-results:empty::after {
  content: 'Start typing to search...';
  display: block;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9em;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition);
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--bg-secondary);
  text-decoration: none;
}

.search-result-item .result-title {
  font-weight: 600;
  font-size: 0.9em;
  margin-bottom: 2px;
}

.search-result-item .result-section {
  font-size: 0.8em;
  color: var(--text-muted);
}

.search-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  font-size: 0.75em;
  color: var(--text-muted);
}

.search-footer kbd {
  font-family: inherit;
  font-size: 0.9em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 5px;
}

/* ─── Sidebar overlay for mobile ─── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 85;
  display: none;
}

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