/* TOC bullet / check indicators */
.toc-indicator {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-right: 6px;
    width: 13px;
    justify-content: center;
}
.toc-dot {
    font-size: 5px;
    color: #4B5563;
    transition: all 0.2s;
}
.toc-check {
    display: none;
    font-size: var(--fs-xs);
    color: var(--c-muted);
}

/* ── Search row magnifying glass ─────────────────── */
.search-mag-icon {
    font-size: var(--fs-base);
    color: var(--c-muted);
    flex-shrink: 0;
    pointer-events: none;
}

/* ── TOC nav (in sidebar) ─────────────────────────── */
#toc-nav {
    position: relative;
    width: 100%;
    flex-shrink: 0;
    max-height: 40%;
    overflow-y: auto;
    background: var(--c-dark);
    border-bottom: 1px solid var(--c-border-dark);
    padding: 0;
}
#toc-nav .toc-title {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--c-dark);
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--c-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 12px 8px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--c-border-dark);
}
.toc-title-label { flex: 1; }
.toc-expand-all {
    font-size: var(--fs-xs);
    color: var(--c-subtle);
    cursor: pointer;
    background: none;
    border: none;
    padding: 2px 5px;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}
.toc-expand-all:hover { color: var(--c-surface); background: rgba(255,255,255,0.1); }
#toc-nav ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0 8px;
}
#toc-nav > ul { padding: 0; }
#toc-nav ul li { margin: 2px 0; }
#toc-nav ul li a {
    display: flex;
    align-items: center;
    color: var(--c-muted);
    font-size: var(--fs-md);
    padding: 4px 6px;
    border-radius: 4px;
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.15s, background 0.15s;
}
#toc-nav ul > li > a.toc-h1 {
    color: #E5E7EB;
    font-weight: 600;
    font-size: var(--fs-md);
    letter-spacing: 0.01em;
    margin-top: 6px;
}
#toc-nav ul li ul li a { font-size: var(--fs-sm); }
#toc-nav ul li ul li ul li a { font-size: var(--fs-xs); }
#toc-nav ul li a:hover {
    color: var(--c-surface);
    background: rgba(255,255,255,0.08);
    text-decoration: none;
}
#toc-nav ul li a.active {
    color: var(--c-surface);
    background: rgba(255,255,255,0.1);
    font-weight: 600;
}
/* Active TOC item: swap dot → check */
#toc-nav ul li a.active .toc-dot  { display: none; }
#toc-nav ul li a.active .toc-check { display: inline-flex; }

/* ── Scroll progress bar ──────────────────────────── */
#scroll-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--c-dark);
    z-index: 999;
    width: 0%;
    pointer-events: none;
}

/* ── Breadcrumb ───────────────────────────────────── */
#breadcrumb {
    position: fixed;
    top: 48px;
    left: 300px;
    right: 0;
    height: 36px;
    background: var(--c-surface);
    border-left: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: var(--fs-md);
    font-weight: 500;
    color: var(--c-muted);
    z-index: 98;
    white-space: nowrap;
    overflow: hidden;
    transition: left 0.25s ease;
}
#breadcrumb a { color: var(--c-subtle); text-decoration: none; transition: color 0.15s; }
#breadcrumb a:hover { color: var(--c-dark); }
#breadcrumb .bc-sep { margin: 0 8px; color: #D1D5DB; font-size: var(--fs-xs); }
#breadcrumb .bc-cur { color: var(--c-heading); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
#breadcrumb .bc-ai-date {
    margin-left: auto;
    font-size: var(--fs-xs);
    color: var(--c-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
body.has-breadcrumb .content { padding-top: 90px !important; }

/* ── HTTP method badges ───────────────────────────── */
.markdown-section code.http-get    { background: #dcfce7 !important; color: #15803d !important; font-weight: 700 !important; }
.markdown-section code.http-post   { background: #dbeafe !important; color: #1d4ed8 !important; font-weight: 700 !important; }
.markdown-section code.http-put    { background: #fef9c3 !important; color: #854d0e !important; font-weight: 700 !important; }
.markdown-section code.http-patch  { background: #fef3c7 !important; color: #b45309 !important; font-weight: 700 !important; }
.markdown-section code.http-delete { background: #fee2e2 !important; color: #dc2626 !important; font-weight: 700 !important; }

/* ── HTTP status code badges ──────────────────────── */
.status-badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: var(--fs-sm); font-weight: 600; }
.status-badge.s2xx { background: #dcfce7; color: #15803d; }
.status-badge.s3xx { background: #dbeafe; color: #1d4ed8; }
.status-badge.s4xx { background: #fef3c7; color: #b45309; }
.status-badge.s5xx { background: #fee2e2; color: #dc2626; }

/* ── HTTP status row colors ───────────────────────── */
.markdown-section tr.row-2xx td { background: rgba(220,252,231,0.45) !important; }
.markdown-section tr.row-3xx td { background: rgba(219,234,254,0.45) !important; }
.markdown-section tr.row-4xx td { background: rgba(254,243,199,0.45) !important; }
.markdown-section tr.row-5xx td { background: rgba(254,226,226,0.45) !important; }
.markdown-section tr.row-2xx:hover td,
.markdown-section tr.row-3xx:hover td,
.markdown-section tr.row-4xx:hover td,
.markdown-section tr.row-5xx:hover td { background: var(--c-hover) !important; }

/* ── Collapsible sections ─────────────────────────── */
.markdown-section h2 .section-toggle {
    display: inline;
    vertical-align: baseline;
    margin-right: 6px;
    color: var(--c-muted);
    background: none;
    border: none;
    user-select: none;
    cursor: pointer;
    transition: color 0.15s;
}
.markdown-section h2:hover .section-toggle {
    color: var(--c-text);
}
.section-body {
    overflow: hidden;
    transition: max-height 0.28s ease;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

/* ── BLF step coloring (synced with flowchart) ───── */
/* Colors are driven by CSS custom properties set at runtime by main.js,
   which parses styles-flowchart.puml. Fallbacks match the .puml defaults. */
.blf-step {
    padding: 10px 14px 10px 16px;
    border-radius: 6px;
    border-left: 3px solid var(--blf-default-border, #90CAF9);
    background: var(--blf-default-bg, #E3F2FD);
    margin-bottom: 8px !important;
}
.blf-step > p  { margin: 0 0 4px 0 !important; }
.blf-step > ul { margin: 4px 0 0 0  !important; padding-left: 20px !important; }
.blf-step.blf-db       { background: var(--blf-db-bg, #A5D6A7);   border-left-color: var(--blf-db-border, #2E7D32); }
.blf-step.blf-error    { background: var(--blf-error-bg, #FFCDD2); border-left-color: var(--blf-error-border, #BA68C8); }
.blf-step.blf-decision { background: var(--blf-decision-bg, #F5F5DC); border-left-color: var(--blf-decision-border, #A1887F); }
/* Sub-item coloring (list items matching flowchart stereotypes) */
li.blf-step-li {
    border-radius: 4px;
    padding: 3px 8px 3px 6px;
    margin-bottom: 4px !important;
    list-style-position: inside;
}
li.blf-step-li.blf-db       { background: var(--blf-db-bg, #A5D6A7); }
li.blf-step-li.blf-error    { background: var(--blf-error-bg, #FFCDD2); }
li.blf-step-li.blf-decision { background: var(--blf-decision-bg, #F5F5DC); }

/* ── Diagram tabs ─────────────────────────────────── */
.diagram-tabs {
    border: 1px solid var(--c-border);
    border-radius: 8px;
    overflow: hidden;
    margin: 8px 0 24px;
}
.diagram-tab-strip {
    display: flex;
    background: var(--c-surface);
    border-bottom: 2px solid var(--c-border);
    padding: 0;
    gap: 0;
}
.diagram-tab-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: transparent;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--c-subtle);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    letter-spacing: 0.01em;
    user-select: none;
}
.diagram-tab-btn i {
    font-size: var(--fs-xs);
    opacity: 0.7;
}
.diagram-tab-btn:hover {
    color: var(--c-text);
    background: var(--c-hover);
}
.diagram-tab-btn.active {
    color: var(--c-dark);
    border-bottom-color: var(--c-dark);
    background: #fff;
}
.diagram-tab-btn.active i {
    opacity: 1;
}
.diagram-tab-panel {
    display: none;
    padding: 20px 24px 16px;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.diagram-tab-panel,
.diagram-tab-panel p,
.diagram-tab-panel li,
.diagram-tab-panel strong {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.diagram-tab-panel.active {
    display: block;
}
/* When tab strip is pinned as fixed, add shadow to distinguish it */
.diagram-tab-strip.is-stuck {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ── PlantUML diagrams — full width ───────────────── */
.plantuml-diagram {
    display: block;
    position: relative;
}
.puml-expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 5px;
    background: rgba(28, 28, 30, 0.55);
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
    z-index: 10;
}
.puml-expand-btn:hover {
    background: rgba(28, 28, 30, 0.85);
    color: #fff;
}
.plantuml-diagram svg {
    display: block;
    width: 100% !important;
    height: auto !important;
}

/* Constrain diagrams inside tabs so they fit without scrolling */
.diagram-tab-panel.tab-panel-flowchart .plantuml-diagram svg,
.diagram-tab-panel.tab-panel-flowchart img {
    max-height: 150vh !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 0 auto;
}

/* ── PlantUML lightbox ─────────────────────────────── */
#puml-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    flex-direction: column;
    background: rgba(17, 24, 39, 0.97);
}
#puml-lightbox.open {
    display: flex;
}
.puml-lb-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.35);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.puml-lb-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.puml-lb-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}
.puml-lb-close {
    margin-left: 8px;
}
.puml-lb-zoom-label {
    font-family: 'Outfit', -apple-system, sans-serif;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    min-width: 44px;
    text-align: center;
    padding: 0 8px;
    letter-spacing: 0.03em;
}
#puml-lb-stage {
    flex: 1;
    overflow: auto;
}
#puml-lb-stage::-webkit-scrollbar { width: 8px; height: 8px; }
#puml-lb-stage::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); }
#puml-lb-stage::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.22); border-radius: 4px; }
#puml-lb-stage::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.38); }
#puml-lb-stage::-webkit-scrollbar-corner { background: transparent; }
#puml-lb-wrap {
    min-width: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    line-height: 0;
}
#puml-lb-wrap svg {
    display: block;
    flex-shrink: 0;
    max-width: none !important;
}

/* ── Copy anchor link ─────────────────────────────── */
.heading-anchor {
    opacity: 0;
    margin-left: 8px;
    font-size: var(--fs-md);
    color: var(--c-muted);
    cursor: pointer;
    transition: opacity 0.15s, color 0.15s;
    text-decoration: none !important;
    user-select: none;
    vertical-align: middle;
}
.markdown-section h1:hover .heading-anchor,
.markdown-section h2:hover .heading-anchor,
.markdown-section h3:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--c-dark) !important; }

/* ── Section toggle FA icon ───────────────────────── */
.markdown-section h2 .section-toggle i {
    font-size: var(--fs-base);
    pointer-events: none;
}


/* ── Page title bar home icon ─────────────────────── */
#page-title-bar .ptb-home i { font-size: var(--fs-h4); }

/* ── Breadcrumb home icon ─────────────────────────── */
#breadcrumb .bc-home-icon { margin-right: 5px; font-size: var(--fs-xs); }

/* ── PlantUML Tooltip Popover ───────────────── */
.plantuml-popover {
    position: absolute;
    background: linear-gradient(180deg, #FFFDE7 0%, #FFF59D 100%);
    color: var(--c-text);
    padding: 10px 16px;
    border-radius: 0 6px 6px 0;
    border-left: 4px solid var(--c-dark);
    font-size: var(--fs-md, 15px);
    max-width: auto;
    min-height: 50px;
    z-index: 10001;
    pointer-events: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}