/* ============================================================
   SBK Operations — Premium Dark Docs Theme
   Inspired by Mintlify / Medusa v2 / Stripe
   Dense micro-grid · surface hierarchy · neutral zinc palette
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root,
[data-md-color-scheme="slate"] {
  /* Surface hierarchy (4 elevation levels) */
  --bg-deep:            #09090b;  /* deepest: code blocks */
  --bg-subtle:          #111113;  /* level 0: sidebar bg */
  --bg-base:            #161618;  /* level 1: main content */
  --bg-base-hover:      #1c1c1f;
  --bg-component:       #1e1e21;  /* level 2: cards, elevated panels */
  --bg-surface:         #232326;  /* level 3: raised elements */
  --bg-field:           rgba(255, 255, 255, 0.03);
  --bg-field-hover:     rgba(255, 255, 255, 0.06);
  --bg-highlight:       rgba(255, 255, 255, 0.04);

  /* Foreground / Text */
  --fg-base:            #ececef;
  --fg-subtle:          #a8a8b0;
  --fg-muted:           #7c7c88;
  --fg-disabled:        #55555f;
  --fg-interactive:     #cdcdd4;
  --fg-interactive-hover: #ececef;
  --fg-on-color:        #ffffff;

  /* Borders */
  --border-base:        rgba(255, 255, 255, 0.06);
  --border-strong:      rgba(255, 255, 255, 0.12);
  --border-hover:       rgba(255, 255, 255, 0.16);

  /* Shadows (layered depth) */
  --shadow-sm:          0 1px 2px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-md:          0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);

  /* Material theme wiring */
  --md-default-bg-color:           var(--bg-base);
  --md-default-fg-color:           var(--fg-base);
  --md-default-fg-color--light:    var(--fg-subtle);
  --md-default-fg-color--lighter:  var(--fg-muted);
  --md-default-fg-color--lightest: var(--fg-disabled);

  --md-primary-fg-color:           var(--fg-base);
  --md-primary-bg-color:           var(--bg-subtle);
  --md-accent-fg-color:            var(--fg-interactive);

  --md-typeset-color:              var(--fg-base);
  --md-typeset-a-color:            var(--fg-interactive);

  --md-code-bg-color:              var(--bg-deep);
  --md-code-fg-color:              #b4b4bc;
  --md-code-hl-color:              rgba(255, 255, 255, 0.05);

  --md-footer-bg-color:            var(--bg-subtle);
  --md-footer-bg-color--dark:      var(--bg-subtle);
}

/* ---------- Font Stack ---------- */
:root {
  --md-text-font: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --md-code-font: "JetBrains Mono", "Roboto Mono", SFMono-Regular, Menlo, monospace;
}

/* ---------- Global ---------- */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.md-typeset {
  font-size: 0.8125rem;     /* 13px — dense like Stripe */
  line-height: 1.65;
  color: var(--fg-subtle);
}

/* ---------- Headings ---------- */
.md-typeset h1 {
  font-size: 1.375rem;      /* 22px */
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--fg-base);
  margin: 0 0 0.75rem;
  line-height: 1.25;
}

.md-typeset h2 {
  font-size: 1rem;           /* 16px */
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-base);
  margin: 1.75rem 0 0.625rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-base);
}

.md-typeset h3 {
  font-size: 0.875rem;       /* 14px */
  font-weight: 600;
  color: var(--fg-base);
  margin: 1.25rem 0 0.5rem;
}

.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg-subtle);
  margin: 1rem 0 0.375rem;
}

/* ---------- Body Text ---------- */
.md-typeset p {
  color: var(--fg-subtle);
  margin-bottom: 0.875rem;
}

.md-typeset strong {
  color: var(--fg-base);
  font-weight: 600;
}

.md-typeset a {
  color: var(--fg-interactive);
  text-decoration: none;
  border-bottom: 1px solid var(--border-base);
  padding-bottom: 1px;
  transition: all 120ms ease;
}

.md-typeset a:hover {
  color: var(--fg-interactive-hover);
  border-bottom-color: var(--border-hover);
}

/* ---------- Header ---------- */
.md-header {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-base);
  box-shadow: none;
}

.md-header[data-md-state="shadow"] {
  box-shadow: none;
  border-bottom: 1px solid var(--border-base);
}

.md-header .md-header__inner {
  padding: 0 0.75rem;
}

.md-header__title {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-base);
}

.md-header .md-header__topic {
  font-weight: 600;
  color: var(--fg-base);
}

.md-header .md-header__topic + .md-header__topic {
  font-weight: 400;
  color: var(--fg-subtle);
}

.md-header__button.md-logo {
  display: inline-flex;
  padding: 0 0.25rem;
}

.md-header__button.md-logo img {
  height: 1.5rem;
  width: auto;
  border-radius: 4px;
  border: none;
  box-shadow: none;
}

/* Header nav buttons (hamburger, search, etc.) */
.md-header__button {
  color: var(--fg-subtle);
}

.md-header__button:hover {
  color: var(--fg-base);
}

/* Search */
.md-search__input {
  background: var(--bg-field);
  border: 1px solid var(--border-base);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--fg-base);
  height: 2rem;
  transition: border-color 120ms ease;
}

.md-search__input::placeholder {
  color: var(--fg-subtle);
  font-size: 0.75rem;
}

.md-search__input:focus {
  border-color: var(--border-hover);
}

.md-search__input:hover {
  background: var(--bg-field-hover);
}

/* ---------- Sidebar (left nav) ---------- */
.md-sidebar {
  background: transparent;
}

.md-sidebar--primary {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-base);
}

/* Section group headers */
.md-nav__title {
  font-size: 0.625rem;       /* 10px — tiny uppercase label */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  padding: 0.875rem 0.75rem 0.25rem;
  margin: 0;
}

/* Nav items — tight Medusa-like spacing */
.md-nav__link {
  font-size: 0.8125rem;      /* 13px */
  font-weight: 400;
  color: var(--fg-subtle);
  padding: 0.3125rem 0.625rem;  /* 5px 10px */
  border-radius: 6px;
  margin: 1px 4px;
  transition: all 100ms ease;
  line-height: 1.4;
}

.md-nav__link:hover {
  color: var(--fg-base);
  background: rgba(255, 255, 255, 0.05);
}

.md-nav__link--active,
.md-nav__item--active > .md-nav__link {
  color: var(--fg-base) !important;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.07);
}

/* Section labels in nav */
.md-nav__item--section > .md-nav__link {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  padding: 0.625rem 0.625rem 0.1875rem;
  margin-top: 0.375rem;
}

/* Nested nav — tighter */
.md-nav--secondary .md-nav__link {
  font-size: 0.6875rem;      /* 11px */
}

/* Nav nesting depth — subtle indent */
.md-nav .md-nav .md-nav__link {
  padding-left: 1.25rem;
}

.md-nav .md-nav .md-nav .md-nav__link {
  padding-left: 1.875rem;
}

/* ---------- Content ---------- */
.md-main__inner {
  margin-top: 0;
}

.md-content {
  max-width: 46rem;
}

.md-content__inner {
  padding: 1.25rem 1.5rem 3rem;
}

/* ---------- Tables (card-style with surface bg) ---------- */
.md-typeset table:not([class]) {
  font-size: 0.75rem;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  border: 1px solid var(--border-base);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.md-typeset table:not([class]) thead {
  background: var(--bg-component);
}

.md-typeset table:not([class]) th {
  font-weight: 600;
  color: var(--fg-subtle);
  font-size: 0.6875rem;      /* 11px — compact header */
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.3125rem 0.5rem;
  border-bottom: 1px solid var(--border-base);
  background: var(--bg-component);
  text-align: left;
}

.md-typeset table:not([class]) td {
  padding: 0.3125rem 0.5rem;
  color: var(--fg-subtle);
  border-bottom: 1px solid var(--border-base);
  line-height: 1.4;
}

.md-typeset table:not([class]) tbody tr:last-child td {
  border-bottom: none;
}

.md-typeset table:not([class]) tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- Code ---------- */
.md-typeset code {
  font-size: 0.6875rem;     /* 11px — tight inline code */
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #b4b4bc;
  border: 1px solid var(--border-base);
  font-weight: 400;
}

.md-typeset pre {
  border-radius: 8px;
  border: 1px solid var(--border-base);
  background: var(--bg-deep) !important;
  box-shadow: var(--shadow-sm);
  margin: 0.875rem 0;
}

.md-typeset pre > code {
  font-size: 0.75rem;       /* 12px for blocks */
  line-height: 1.6;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.highlight {
  background: var(--bg-deep);
  border-radius: 8px;
}

/* ---------- Blockquotes (surface card style) ---------- */
.md-typeset blockquote {
  border-left: 2px solid var(--border-strong);
  background: var(--bg-component);
  padding: 0.625rem 0.875rem;
  border-radius: 0 6px 6px 0;
  margin: 0.875rem 0;
  color: var(--fg-subtle);
  box-shadow: var(--shadow-sm);
}

.md-typeset blockquote p {
  color: var(--fg-subtle);
  margin-bottom: 0.375rem;
}

.md-typeset blockquote p:last-child {
  margin-bottom: 0;
}

/* ---------- Lists (tighter) ---------- */
.md-typeset ul,
.md-typeset ol {
  color: var(--fg-subtle);
  margin-bottom: 0.875rem;
}

.md-typeset li {
  margin-bottom: 0.125rem;
}

.md-typeset li p {
  margin-bottom: 0.25rem;
}

/* ---------- HR ---------- */
.md-typeset hr {
  border-color: var(--border-base);
  margin: 1.5rem 0;
}

/* ---------- Admonitions (surface card) ---------- */
.md-typeset .admonition,
.md-typeset details {
  border: 1px solid var(--border-base);
  border-radius: 8px;
  background: var(--bg-component);
  box-shadow: var(--shadow-sm);
  font-size: 0.8125rem;
  margin: 0.875rem 0;
}

.md-typeset .admonition .admonition-title,
.md-typeset details summary {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-base);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
}

/* ---------- TOC (right sidebar) ---------- */
.md-sidebar--secondary {
  background: transparent;
  border-left: 1px solid var(--border-base);
}

.md-nav--secondary .md-nav__title {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.5rem 0.75rem 0.25rem;
}

.md-nav--secondary .md-nav__item .md-nav__link {
  font-size: 0.6875rem;     /* 11px */
  color: var(--fg-subtle);
  border-left: 1px solid transparent;
  border-radius: 0;
  margin: 0;
  padding: 0.1875rem 0.625rem;
  line-height: 1.4;
}

.md-nav--secondary .md-nav__item .md-nav__link:hover {
  color: var(--fg-base);
  background: transparent;
  border-left-color: var(--border-strong);
}

.md-nav--secondary .md-nav__item .md-nav__link--active {
  color: var(--fg-base) !important;
  border-left-color: var(--fg-subtle) !important;
  background: transparent;
  font-weight: 500;
}

/* ---------- Footer ---------- */
.md-footer {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-base);
}

.md-footer-meta {
  background: var(--bg-subtle);
}

.md-footer-nav__link {
  font-size: 0.75rem;
}

/* ---------- Tabs ---------- */
.md-typeset .tabbed-labels {
  border-bottom: 1px solid var(--border-base);
}

.md-typeset .tabbed-labels > label {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-weight: 500;
  padding: 0.375rem 0.75rem;
}

.md-typeset .tabbed-labels > label--active,
.md-typeset .tabbed-labels > input:checked + label {
  color: var(--fg-base);
  border-bottom-color: var(--fg-subtle);
}

/* ---------- Task lists ---------- */
.md-typeset .task-list-indicator::before {
  background-color: var(--fg-muted);
}

.md-typeset [type="checkbox"]:checked + .task-list-indicator::before {
  background-color: var(--fg-subtle);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ---------- Selection ---------- */
::selection {
  background: rgba(255, 255, 255, 0.12);
  color: var(--fg-base);
}

/* ---------- Mermaid diagrams ---------- */
.mermaid {
  background: var(--bg-component);
  border: 1px solid var(--border-base);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

/* ---------- Images ---------- */
.md-typeset img {
  border-radius: 8px;
  border: 1px solid var(--border-base);
  box-shadow: var(--shadow-sm);
}

/* ---------- Definition lists ---------- */
.md-typeset dt {
  font-weight: 600;
  color: var(--fg-base);
  font-size: 0.8125rem;
}

.md-typeset dd {
  margin-left: 1rem;
}

/* ---------- Mobile ---------- */
@media screen and (max-width: 76.25em) {
  .md-sidebar--primary {
    background: var(--bg-subtle);
  }

  .md-nav__link {
    font-size: 0.8125rem;
    padding: 0.4375rem 0.75rem;
  }
}

@media screen and (max-width: 60em) {
  .md-typeset h1 {
    font-size: 1.25rem;
  }

  .md-typeset h2 {
    font-size: 0.9375rem;
  }

  .md-content__inner {
    padding: 1rem;
  }
}

/* ---------- Print ---------- */
@media print {
  .md-sidebar,
  .md-header,
  .md-footer {
    display: none;
  }

  .md-content {
    max-width: 100%;
  }
}
