:root {
    --doc-sidebar-width: 420px;
    --doc-resize-hitbox: 12px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    overflow-x: hidden;
}

body {
    background: #fff;
}

/* Global safety against horizontal overflow */
.doc-layout,
.doc-sidebar,
.doc-content,
#contentList,
.card,
.card-body,
.accordion,
.accordion-item,
.accordion-body,
.offcanvas,
.offcanvas-body {
    min-width: 0;
    max-width: 100%;
}

img,
iframe,
table {
    max-width: 100%;
}

pre,
code {
    max-width: 100%;
}

pre {
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* =========================
   MOBILE + TABLET DEFAULT
   ========================= */

html,
body {
    height: auto;
}

body {
    overflow-y: auto;
    overflow-x: hidden;
}

.doc-layout {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: auto;
    height: auto;
    position: relative;
}

.doc-sidebar {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex: none;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 0;
    background: #f8f9fa;
}

.doc-content {
    min-width: 0;
    min-height: auto;
    overflow: visible;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.sidebar-resize-handle {
    display: none !important;
}

/* =========================
   DESKTOP (>= 992px)
   ========================= */

@media (min-width: 992px) {
    html,
    body {
        height: 100%;
    }

    body {
        overflow: hidden;
    }

    .doc-layout {
        display: flex;
        width: 100%;
        height: 100vh;
        min-height: 0;
        position: relative;
    }

    .doc-sidebar {
        width: var(--doc-sidebar-width);
        min-width: 260px;
        max-width: 900px;
        flex: 0 0 var(--doc-sidebar-width);
        overflow-y: auto;
        overflow-x: hidden;
        border-right: 1px solid #dee2e6;
        background: #f8f9fa;
        position: relative;
        z-index: 2;
    }

    .doc-content {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scroll-behavior: smooth;
    }

    .sidebar-resize-handle {
        display: block !important;
        position: absolute;
        top: 0;
        bottom: 0;
        left: calc(var(--doc-sidebar-width) - (var(--doc-resize-hitbox) / 2));
        width: var(--doc-resize-hitbox);
        cursor: e-resize;
        z-index: 10;
        background: transparent;
    }

    .sidebar-resize-handle::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 1px;
        background: #ced4da;
    }

    .sidebar-resize-handle:hover,
    .sidebar-resize-handle.is-resizing {
        background: rgba(0, 0, 0, 0.04);
    }
}

/* =========================
   OFFCANVAS
   ========================= */

.offcanvas.offcanvas-start {
    --bs-offcanvas-width: 100vw;
    width: var(--bs-offcanvas-width);
    max-width: 100vw;
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .offcanvas.offcanvas-start {
        --bs-offcanvas-width: 600px;
    }
}

@media (max-width: 767.98px) {
    .offcanvas.offcanvas-start {
        --bs-offcanvas-width: 100vw;
    }
}

/* =========================
   HEADER / STICKY
   ========================= */

.doc-sticky-top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f8f9fa;
}

.top-anchor {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
}

/* =========================
   TREE
   ========================= */

.tree-nested {
    padding-left: 1rem;
    margin-left: 0.5rem;
    border-left: 1px dashed #d0d7de;
}

.form-control {
    box-shadow: none !important;
}

.folder-button {
    box-shadow: none !important;
    padding: 0.35rem 0.5rem;
    background: transparent;
}

.folder-button:not(.collapsed) {
    background: #eef2f6;
    color: inherit;
}

.folder-label {
    font-weight: 600;
}

.tree-file-link {
    display: block;
    padding: 0.35rem 0.5rem;
    border-radius: 0.375rem;
    text-decoration: none;
    color: #212529;
}

.tree-file-link:hover {
    background: #e9ecef;
}

.small-fqcn {
    font-size: 0.9rem;
    color: #6c757d;
    word-break: break-word;
}

/* =========================
   CONTENT
   ========================= */

.doc-entry + .doc-entry {
    margin-top: 2rem;
}

.doc-entry {
    scroll-margin-top: 6rem;
}

.method-accordion .accordion-button {
    align-items: center;
}

.method-accordion .accordion-button:not(.collapsed) {
    background: #f8f9fa;
}

.text-preline {
    white-space: pre-line;
}

.muted-empty {
    color: #6c757d;
    font-style: italic;
}

.lt-spading {
    letter-spacing: 2px;
}

.badge {
    text-transform: lowercase;
}

/* =========================
   BOOTSTRAP TWEAKS
   ========================= */

.accordion-button:focus {
    z-index: 3;
    outline: 0;
    box-shadow: none;
}