/* ============================================================
   DigiKey API Developer Portal — Main Stylesheet
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Sidebar */
  --sidebar-bg:       #0f1923;
  --sidebar-hover:    #1a2940;
  --sidebar-active:   #1e3a5f;
  --sidebar-text:     #a8b8c8;
  --sidebar-heading:  #4a6580;
  --sidebar-active-text: #ffffff;
  --sidebar-width:    260px;

  /* Content */
  --content-bg:       #ffffff;
  --content-text:     #1c2b3a;
  --content-muted:    #5a7080;
  --content-max:      820px;

  /* Brand */
  --brand-red:        #cc0000;
  --brand-blue:       #1a4b8c;
  --link-color:       #1563cc;
  --link-hover:       #0e4aa3;

  /* Borders */
  --border:           #dde3ea;
  --border-light:     #edf0f4;

  /* Code */
  --code-bg:          #1b2a3b;
  --code-text:        #cdd9e5;
  --inline-code-bg:   #f0f4f8;
  --inline-code-text: #c5363a;

  /* Callouts */
  --note-bg:          #eef6ff;
  --note-border:      #3b82f6;
  --note-text:        #1e40af;
  --warn-bg:          #fffbeb;
  --warn-border:      #f59e0b;
  --warn-text:        #92400e;
  --tip-bg:           #f0fdf4;
  --tip-border:       #22c55e;
  --tip-text:         #166534;

  /* Badges */
  --badge-get:        #0ea5e9;
  --badge-post:       #16a34a;
  --badge-put:        #d97706;
  --badge-patch:      #7c3aed;
  --badge-delete:     #dc2626;

  /* Typography */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --font-size:   15px;
  --line-height: 1.65;

  /* Spacing */
  --topbar-height: 52px;
}

html { font-size: var(--font-size); }

body {
  font-family: var(--font-body);
  color: var(--content-text);
  background: var(--content-bg);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Topbar (mobile) ---- */
.topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--sidebar-bg);
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 200;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.topbar-brand {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.nav-toggle {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-toggle:hover { color: #fff; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

.sidebar-header {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}
.sidebar-logo:hover { color: #fff; }

.sidebar-nav {
  padding: 0.75rem 0 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.nav-group {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.nav-group:last-of-type { border-bottom: none; }

.nav-group-label {
  display: block;
  padding: 0.2rem 1.25rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-heading);
}

.sidebar-nav a {
  display: block;
  padding: 0.35rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  border-radius: 0 4px 4px 0;
  line-height: 1.4;
}
.sidebar-nav a:hover {
  color: #ffffff;
  background: var(--sidebar-hover);
}
.sidebar-nav a.active {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active);
  border-left-color: var(--brand-red);
  font-weight: 500;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  margin-top: auto;
}

.btn-sidebar-cta {
  display: block;
  text-align: center;
  padding: 0.55rem 1rem;
  background: rgba(204,0,0,0.15);
  border: 1px solid rgba(204,0,0,0.4);
  color: #ff6b6b;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s, border-color 0.15s;
}
.btn-sidebar-cta:hover {
  background: rgba(204,0,0,0.25);
  border-color: rgba(204,0,0,0.6);
}

/* ---- Main Content ---- */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content-inner {
  flex: 1;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding: 3rem 2.5rem 4rem;
}

/* ---- Page Footer ---- */
.page-footer {
  border-top: 1px solid var(--border-light);
  padding: 1.25rem 2.5rem;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}
.page-footer p {
  font-size: 0.8rem;
  color: var(--content-muted);
}
.page-footer a { color: var(--content-muted); text-decoration: underline; }
.page-footer a:hover { color: var(--link-color); }

/* ---- Typography ---- */
.content-inner h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--content-text);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.content-inner h2 {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--content-text);
  margin-top: 2.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.content-inner h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--content-text);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.content-inner h4 {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--content-muted);
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
}

.content-inner p {
  margin-bottom: 1rem;
  max-width: 68ch;
}

.content-inner ul, .content-inner ol {
  margin: 0.5rem 0 1rem 1.5rem;
}
.content-inner li { margin-bottom: 0.3rem; }
.content-inner li p { margin-bottom: 0.3rem; }

.content-inner a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid rgba(21,99,204,0.25);
}
.content-inner a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

.content-inner hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.content-inner strong { font-weight: 600; }

/* ---- Inline code ---- */
.content-inner code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* ---- Code blocks ---- */
.content-inner pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 0.75rem 0 1.5rem;
  font-size: 0.82rem;
  line-height: 1.65;
  position: relative;
  border: 1px solid rgba(255,255,255,0.06);
}

.content-inner pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
}

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--sidebar-text);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0;
}
.content-inner pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.copy-btn.copied { color: #4ade80; border-color: #4ade80; }

/* ---- Tables ---- */
.content-inner table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 1rem 0 1.5rem;
}
.content-inner th {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--content-muted);
  background: var(--border-light);
}
.content-inner td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
.content-inner tr:last-child td { border-bottom: none; }
.content-inner tbody tr:hover td { background: #f8fafc; }

/* ---- Callouts ---- */
.content-inner blockquote {
  border-left: 3px solid var(--note-border);
  background: var(--note-bg);
  padding: 0.85rem 1.1rem;
  border-radius: 0 6px 6px 0;
  margin: 1.25rem 0;
  color: var(--note-text);
  font-size: 0.9rem;
}
.content-inner blockquote p { margin: 0; max-width: none; color: inherit; }
.content-inner blockquote strong { color: inherit; }

/* ---- API Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
  text-transform: uppercase;
}
.badge-get    { background: rgba(14,165,233,0.12); color: var(--badge-get); border: 1px solid rgba(14,165,233,0.3); }
.badge-post   { background: rgba(22,163,74,0.12);  color: var(--badge-post); border: 1px solid rgba(22,163,74,0.3); }
.badge-put    { background: rgba(217,119,6,0.12);  color: var(--badge-put); border: 1px solid rgba(217,119,6,0.3); }
.badge-patch  { background: rgba(124,58,237,0.12); color: var(--badge-patch); border: 1px solid rgba(124,58,237,0.3); }
.badge-delete { background: rgba(220,38,38,0.12);  color: var(--badge-delete); border: 1px solid rgba(220,38,38,0.3); }
.badge-2l     { background: rgba(16,185,129,0.1);  color: #059669; border: 1px solid rgba(16,185,129,0.3); font-family: var(--font-body); font-size: 0.72rem; letter-spacing: 0.02em; text-transform: none; }
.badge-3l     { background: rgba(139,92,246,0.1);  color: #7c3aed; border: 1px solid rgba(139,92,246,0.3); font-family: var(--font-body); font-size: 0.72rem; letter-spacing: 0.02em; text-transform: none; }
.badge-active { background: rgba(16,185,129,0.1);  color: #059669; border: 1px solid rgba(16,185,129,0.3); font-family: var(--font-body); font-size: 0.72rem; letter-spacing: 0.02em; text-transform: none; }

/* ---- API Page Header ---- */
.api-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.api-header h1 { margin-bottom: 0.4rem; }
.api-header .api-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.api-header .api-desc {
  color: var(--content-muted);
  font-size: 1rem;
  margin: 0.5rem 0;
  max-width: 60ch;
}
.api-header .base-url {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--content-muted);
  background: var(--border-light);
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: inline-block;
  margin-top: 0.35rem;
}
.swagger-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--content-muted);
  text-decoration: none !important;
  border-bottom: 1px solid var(--border) !important;
  background: var(--border-light);
  margin-top: 0.35rem;
  transition: border-color 0.15s, color 0.15s;
}
.swagger-link:hover {
  color: var(--link-color) !important;
  border-color: var(--link-color) !important;
}

/* ---- Endpoint Block ---- */
.endpoint {
  margin: 1.75rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.endpoint-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
}
.endpoint-path {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--content-text);
  font-weight: 500;
}
.endpoint-desc {
  font-size: 0.82rem;
  color: var(--content-muted);
  margin-left: auto;
}
.endpoint-body {
  padding: 1rem 1.25rem;
}
.endpoint-body p { font-size: 0.9rem; }
.endpoint-body pre { margin-top: 0.5rem; }
.endpoint-body table { font-size: 0.82rem; }

/* ---- Home page cards ---- */
.api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.api-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-decoration: none !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--content-text) !important;
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}
.api-card:hover {
  border-color: var(--link-color) !important;
  box-shadow: 0 2px 8px rgba(21,99,204,0.1);
}
.api-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--content-text);
  margin: 0 0 0.3rem;
}
.api-card .card-desc {
  font-size: 0.82rem;
  color: var(--content-muted);
  margin: 0;
  line-height: 1.5;
}
.api-card .card-meta {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* ---- Steps (numbered list for guides) ---- */
.steps { counter-reset: step-counter; list-style: none; margin-left: 0; padding: 0; }
.steps > li {
  counter-increment: step-counter;
  display: flex;
  gap: 1rem;
  margin-bottom: 1.75rem;
  align-items: flex-start;
}
.steps > li::before {
  content: counter(step-counter);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  background: var(--brand-blue);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 0.1rem;
}
.steps > li > div { flex: 1; }
.steps > li > div h3 { margin-top: 0; }

/* ---- Troubleshooting table ---- */
.troubleshoot-table { width: 100%; }
.troubleshoot-table th:first-child { width: 30%; }

/* ---- Note/Warn/Tip callout helpers via class ---- */
.callout-warn {
  border-left: 3px solid var(--warn-border);
  background: var(--warn-bg);
  padding: 0.85rem 1.1rem;
  border-radius: 0 6px 6px 0;
  margin: 1.25rem 0;
  font-size: 0.9rem;
  color: var(--warn-text);
}
.callout-warn p { margin: 0; max-width: none; color: inherit; }
.callout-tip {
  border-left: 3px solid var(--tip-border);
  background: var(--tip-bg);
  padding: 0.85rem 1.1rem;
  border-radius: 0 6px 6px 0;
  margin: 1.25rem 0;
  font-size: 0.9rem;
  color: var(--tip-text);
}
.callout-tip p { margin: 0; max-width: none; color: inherit; }

/* ---- Home hero ---- */
.home-hero {
  margin-bottom: 2.5rem;
}
.home-hero h1 {
  font-size: 2.25rem;
  margin-bottom: 0.6rem;
}
.home-hero .tagline {
  font-size: 1.1rem;
  color: var(--content-muted);
  max-width: 55ch;
  margin: 0;
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .topbar { display: flex; }

  .layout { display: block; padding-top: var(--topbar-height); }

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    height: calc(100vh - var(--topbar-height));
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 175;
    min-height: unset;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .content { min-height: calc(100vh - var(--topbar-height)); }
  .content-inner { padding: 2rem 1.25rem 3rem; }
  .page-footer { padding: 1rem 1.25rem; }
}

@media (max-width: 520px) {
  .content-inner h1 { font-size: 1.6rem; }
  .api-grid { grid-template-columns: 1fr; }
}


/* ---- Models Section ---- */
.models-section {
  margin-top: 3rem;
  border-top: 2px solid var(--border);
  padding-top: 2rem;
}

.models-intro {
  color: var(--content-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.model-card {
  margin-bottom: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.model-name {
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  background: #f4f7fa;
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.model-name code {
  font-size: 1rem;
  background: transparent;
  padding: 0;
  color: var(--content-text);
}

.model-desc {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--content-muted);
  border-bottom: 1px solid var(--border);
  background: #fafcff;
}

.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.model-table thead th {
  background: #f4f7fa;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--content-muted);
  border-bottom: 1px solid var(--border);
}

.model-table tbody tr {
  border-bottom: 1px solid #f0f3f6;
}

.model-table tbody tr:last-child {
  border-bottom: none;
}

.model-table tbody td {
  padding: 0.5rem 0.75rem;
  vertical-align: top;
}

.field-name {
  font-size: 0.85rem;
  color: var(--brand-blue);
  background: transparent;
  padding: 0;
  white-space: nowrap;
}

.field-type {
  color: #7a5a9e;
  white-space: nowrap;
  font-size: 0.82rem;
}

.field-desc {
  color: var(--content-muted);
  line-height: 1.5;
}

.model-ref {
  color: var(--link-color);
  text-decoration: none;
}
.model-ref:hover { text-decoration: underline; }

.badge-required {
  background: #fff0f0;
  color: #cc2222;
  border: 1px solid #ffcccc;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
}
