/* Shared shell CSS (per user instruction 2026-09-02): the collapsible icon rail
   (.cp-rail/.cp-dashboard) and pill-shaped top bar (.cp-topbar) rolled out from
   cockpit.html to every report page. Each page keeps its own <style> block for its own
   content (charts, tables, KPI tiles, filter popovers, etc.) with its own class prefix -
   this file only covers the shared navigation shell so it isn't duplicated 9 times.

   Requires the including page to:
   - set a page body class that hides .axys-navbar/.axys-footer (same pattern every page
     already has, e.g. `.cockpit-body .axys-navbar { display: none; }`)
   - define `--cp-ink`, `--cp-ink-soft`, `--cp-accent`, `--cp-accent-deep` (or reuse
     existing page-local --page-* vars by aliasing them to these names) since some layout
     rules below read them for color
   - include templates/_cp_rail.html for the <aside class="cp-rail"> markup
   - include static/js/cp_shell.js once for the collapse-toggle behavior */

.cp-shell {
    min-height: 100vh;
    background: transparent;
}

.cp-dashboard {
    display: grid;
    grid-template-columns: 84px 1fr;
    grid-template-rows: 1fr auto;
    min-height: 100vh;
    transition: grid-template-columns 0.18s ease;
}

.cp-dashboard.cp-dashboard--expanded {
    grid-template-columns: 248px 1fr;
}

/* Collapsible icon rail: collapsed by default to a slim icon-only strip, expands to
   icon+label on toggle. State is remembered per-viewer via localStorage (see
   cp_shell.js) so it doesn't reset to collapsed on every navigation. The toggle button
   lives inline in the brand row at the very top of the rail, always visible without
   scrolling. */
.cp-rail {
    grid-row: 1 / span 2;
    background: #0b0f75;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    position: relative;
    overflow: hidden;
}

.cp-rail-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0 0 20px;
}

.cp-dashboard--expanded .cp-rail-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 20px;
}

.cp-rail-brand {
    display: flex;
    justify-content: center;
    min-width: 0;
}

.cp-rail-brand__mark {
    /* Collapsed state: a rounded-square badge (like an app icon), matching the reference
       screenshot (per user instruction 2026-09-02). mask-image (tried first, to recolor
       the source PNG's teal chevron solid white) doesn't render in this environment, so
       the chevron keeps its own teal/cyan color here instead - a background-image crop
       (proven reliable elsewhere in this file) centered inside a colored, rounded
       container. image1.png is the full lockup (chevron + "HYPERFIN" wordmark); the
       chevron's pixel bounding box was measured directly from the file at x:[18,92]
       y:[57,144] out of its native 390x190. */
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 9px;
    background-color: #10184f;
    position: relative;
}

.cp-rail-brand__mark::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 23.51px;
    transform: translate(-50%, -50%);
    background-image: url("/static/img/image1.png");
    background-size: 105.41px 51.35px;
    background-position: -4.86px -15.41px;
    background-repeat: no-repeat;
}

/* Expanded state: the full lockup (chevron + wordmark), bigger than the old size (per
   user instruction 2026-09-02 - "a bit bigger like on the navbar itself"). */
.cp-dashboard--expanded .cp-rail-brand__mark {
    width: 170px;
    height: 64px;
    border-radius: 0;
    background-color: transparent;
}

.cp-dashboard--expanded .cp-rail-brand__mark::after {
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    height: 100%;
    background-image: url("/static/img/image1.png");
    background-size: contain;
    background-position: left center;
    background-repeat: no-repeat;
}

.cp-rail-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.cp-rail-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 0;
    justify-content: center;
    color: #9db0d8;
    border-left: 3px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}

.cp-dashboard--expanded .cp-rail-link {
    justify-content: flex-start;
    padding: 13px 22px;
}

.cp-rail-link__icon {
    width: 21px;
    height: 21px;
    flex-shrink: 0;
}

.cp-rail-link__label {
    display: none;
    font-size: 14px;
    font-weight: 600;
}

.cp-dashboard--expanded .cp-rail-link__label {
    display: inline;
}

.cp-rail-link:hover {
    color: #ffffff;
}

.cp-rail-link.active {
    color: #ffffff;
    background: #0b3d78;
    border-left-color: #4d8dff;
}

/* Divider between the Statements and Operations & Analysis link groups - same split as
   the old accordion sidebar. Caption is hidden when collapsed since there's no room for
   it - just the rule line. */
.cp-rail-divider {
    margin: 10px 0;
    padding: 0 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cp-rail-divider::before {
    content: "";
    display: block;
    height: 1px;
    background: rgba(255, 255, 255, 0.14);
}

/* The very first divider ("Statements", right under the brand row) has nothing above it
   in the rail to separate from - the rule line would just double up against the brand
   row's own bottom padding, so it's dropped for this one divider only. */
.cp-rail-divider--first {
    margin-top: 0;
}

.cp-rail-divider--first::before {
    display: none;
}

.cp-rail-divider__label {
    display: none;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
}

/* Rail group captions recolored in orange shades (per user instruction 2026-10-01), one
   per section so "Analysis & Statements" / "Operations" / "Board Pack" stay
   distinguishable at a glance, matching the navbar/home-page section colors above. */
.cp-rail-divider--first .cp-rail-divider__label {
    color: #e08a2b;
}

.cp-rail-divider:not(.cp-rail-divider--first) .cp-rail-divider__label {
    color: #c1620f;
}

.cp-rail-divider:last-of-type .cp-rail-divider__label {
    color: #f0a84a;
}

.cp-dashboard--expanded .cp-rail-divider__label {
    display: block;
}

.cp-rail-toggle {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cp-rail-toggle__icon {
    width: 16px;
    height: 16px;
    transition: transform 0.18s ease;
}

.cp-dashboard--expanded .cp-rail-toggle__icon {
    transform: rotate(180deg);
}

.cp-rail-meta {
    margin-top: 12px;
    padding: 10px 10px 0;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    display: none;
}

.cp-dashboard--expanded .cp-rail-meta {
    display: block;
    text-align: left;
}

.cp-page-footer {
    grid-column: 2;
    text-align: center;
    padding: 16px 24px;
    color: var(--page-slate, var(--cp-slate, #667085));
    font-size: 12px;
    font-weight: 600;
    border-top: 1px solid rgba(22, 33, 62, 0.08);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(10px);
}

.cp-content {
    background: transparent;
    padding: 18px;
}

/* Shared title and filter row: the controls remain grouped, while the page background
    stays visible behind the row instead of framing it as a capsule. */
.cp-topbar {
     background: transparent;
     border: none;
     border-radius: 0;
     box-shadow: none;
     backdrop-filter: none;
     padding: 8px 0 16px;
    display: flex;
    align-items: center;
    gap: 26px;
    margin-bottom: 22px;
    /* backdrop-filter creates a new stacking context, which traps any descendant's
       z-index (e.g. a filter popover) inside it - no z-index on the popover, however
       high, can ever paint above a later sibling section (like a page's data table)
       outside .cp-topbar unless .cp-topbar's OWN stacking level is raised too (per user
       instruction 2026-09-02 - a Variance Analysis filter popover was being visually cut
       off by the table below it despite the popover's z-index already being very high). */
    position: relative;
    z-index: 30;
}

.cp-topbar__identity {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: -6px;
}

.cp-title {
    margin: 0;
    font-size: 32px;
    line-height: 1.1;
    font-weight: 900;
    color: var(--page-ink, var(--cp-ink, #16213e));
    letter-spacing: 0.01em;
}

.cp-topbar__tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(15, 108, 189, 0.06);
    border-radius: 999px;
    padding: 6px;
    flex: 1;
    justify-content: flex-start;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 108, 189, 0.35) transparent;
}

.cp-tab {
    flex: 0 0 auto;
    padding: 12px 26px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 700;
    color: var(--page-ink-soft, var(--cp-ink-soft, #44526c));
    text-decoration: none;
    white-space: nowrap;
    text-align: center;
    line-height: 1.25;
}

.cp-tab:hover {
    color: var(--page-accent, var(--cp-accent-deep, #0b4f8a));
}

.cp-tab.active {
    background: var(--page-accent, var(--cp-accent, #0f6cbd));
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(15, 108, 189, 0.35);
}

.cp-topbar__controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.cp-topbar__field {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(22, 33, 62, 0.12);
    border-radius: 999px;
    padding: 10px 20px;
}

.cp-topbar__field-label {
    color: var(--page-accent, var(--cp-accent, #0f6cbd));
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.cp-topbar__field select {
    border: none;
    background: transparent;
    color: var(--page-ink, var(--cp-ink, #16213e));
    font-size: 15px;
    font-weight: 700;
    padding: 0;
}

.cp-topbar__field-value {
    color: var(--page-ink, var(--cp-ink, #16213e));
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

.cp-topbar__export {
    display: flex;
    align-items: center;
    gap: 7px;
    border: none;
    background: none;
    color: #1e8a3d;
    font-size: 15px;
    font-weight: 800;
    padding: 8px 4px;
    cursor: pointer;
    white-space: nowrap;
}

.cp-topbar__export svg {
    width: 19px;
    height: 19px;
}

@media (max-width: 900px) {
    .cp-dashboard {
        grid-template-columns: 1fr;
    }

    .cp-rail {
        display: none;
    }

    .cp-content {
        padding: 12px;
    }

    .cp-topbar {
        flex-direction: column;
        align-items: stretch;
        border-radius: 16px;
        padding: 14px 16px;
    }

    .cp-topbar__tabs {
        scrollbar-width: thin;
    }
}
