/* ------------------------------------------------------------------
   App shell (header.html / footer.html)

   <aside class="sidenav">          fixed sidebar        (css/sidebar.css)
   <div class="page-scroll">        scrolling column beside it
       <header class="app-header">  item navigator + page actions
       <main class="app-content">   page content

   Replaces the old container-fluid > row > col-2 / col-10 grid.
   Sidebar widths and gutters are px so they ignore the base font size.
   ------------------------------------------------------------------ */

.page-scroll {
    margin-left: 200px;               /* sidebar width */
    width: calc(100% - 200px);
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
}
.page-scroll > main{
    flex: 1;
}
/* Pages rendered without the sidebar (e.g. trim-exit-calc) */
.page-scroll--full {
    margin-left: 0;
    width: 100%;
}
.app-content {
    padding: 0 15px;
}

@media (max-width: 992px) {
    .page-scroll {
        margin-left: 100px;           /* collapsed sidebar width */
        width: calc(100% - 100px);
    }

    .page-scroll--full {
        margin-left: 0;
        width: 100%;
    }

}

/* ---------- Sidebar toggle (hamburger, header.html) ---------- */

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}

.sidebar-toggle:hover {
    background: #f1f3f5;
    color: #111827;
}

.sidebar-toggle:focus-visible {
    outline: 3px solid rgba(156, 163, 175, 0.6);
    outline-offset: 2px;
}

/* Desktop: collapsed sidebar slides out, content takes the full width */
body.sidebar-collapsed .sidenav {
    transform: translateX(-100%);
    box-shadow: none;
}

body.sidebar-collapsed .page-scroll {
    margin-left: 0;
    width: 100%;
}

/* Small screens (<=992px, same breakpoint as the old 100px compact sidebar):
   sidebar is fully hidden and slides in over the page at full width with full labels.
   z-index 1030/1025 sits above the sticky header (1020), below modals (1040). */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 992px) {

    .page-scroll {
        margin-left: 0;
        width: 100%;
    }

    .sidenav {
        width: 200px;
        min-width: 200px;
        flex-basis: 200px;
        transform: translateX(-100%);
        box-shadow: none;
    }

    /* Full names instead of the short codes (D, PD, VD...) */
    .sidenav .d-lg-none {
        display: none !important;
    }

    .sidenav .d-none.d-lg-inline {
        display: inline !important;
    }

    body.sidebar-open .sidenav {
        transform: none;
        z-index: 1030;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1025;
        background: rgba(0, 0, 0, 0.35);
    }
}

/* No slide animation while the page first loads with a saved state */
body.sidebar-init .sidenav,
body.sidebar-init .page-scroll {
    transition: none;
}

/* Stays pinned to the top while .page-scroll scrolls underneath.
   z-index 1020 = Bootstrap's sticky layer: above page content and the
   sidebar (1000), below modals (1040+) and flash messages (9999). */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 15px;             /* 15px = content gutter below */
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Item navigator: prev / item text / next / fullscreen.
   The text box is 400px wide but shrinks (with ellipsis) when space runs out. */
.app-header .item-nav {
    min-width: 0;
    max-width: 100%;
    flex: 0 1 auto;
}

.item-nav > a,
.item-nav > button {
    flex-shrink: 0;
}

.item-nav-input {
    flex: 0 1 400px;
    width: 400px;
    min-width: 0;
    text-align: center;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    /* Navigator fills the row beside the hamburger; page actions wrap below */
    .app-header .item-nav {
        flex: 1 1 0;
    }

    .item-nav-input {
        flex: 1 1 auto;
        width: auto;
    }

    /* Fullscreen is not useful on phones/tablets */
    .item-nav button[title="Fullscreen"] {
        display: none;
    }
}

/* Right-hand groups: page actions (valve sizing Add/Copy/...) then
   Quick Guide / Help / account. Whichever comes first takes the free space. */
.app-header .sizing-help-icons,
.app-header .header-actions {
    margin-left: auto;
}

.app-header .sizing-help-icons + .header-actions {
    margin-left: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-actions form {
    margin: 0;
}

/* Header buttons: Quick Guide, Help, account, project type */
.help-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 8px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    border-radius: 5px;
    background: #EAF2F8;
    color: #000;
    font-weight: 300;
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease;
}

.help-btn:hover {
    background: #d4d5d8;
    color: #000;
    text-decoration: none;
    transform: translateY(-1px);
}

.help-btn:active {
    transform: translateY(0);
}

.help-btn:focus-visible {
    outline: 3px solid rgba(156, 163, 175, 0.6);
    outline-offset: 2px;
}

select.help-btn {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
}

@media (prefers-reduced-motion: reduce) {
    .help-btn {
        transition: none;
    }
}

.account-menu {
    min-width: 128px;
    font-size: 12px;
}

.account-menu .dropdown-item {
    padding: 8px 10px;
}

/* 15px matches Bootstrap's row gutter, so page-level .row elements
   (margin: 0 -15px) line up with the edges without overflowing */
