/* =====================================================================
 * RabDash sidebar (layouts/partials/sidebar.blade.php)
 *
 * Loaded site-wide after rabdash-mobile.css.
 *  - All modes: brand red, a touch deeper than SB Admin's #e74a3b so white
 *    text passes WCAG AA (~4.7:1); same red as the About banner.
 *  - Hover/active use a darker tint, not a white one: white tint on red
 *    would drop text contrast below 4.5:1.
 *  - Expanded sidebar (>= 768px, not minimised): submenus sit inside the
 *    red panel instead of white boxes, rounded hover/active pills.
 *  - Slim/flyout mode (phones, tablets, minimised desktop) keeps its white
 *    flyout boxes from rabdash-mobile.css; only icons/labels are styled.
 * =================================================================== */

#accordionSidebar.bg-gradient-danger {
    background: linear-gradient(180deg, #d13f2f 10%, #b52d1e 100%) !important;
}

/* Submenu rows: icon + label, wrapping naturally (no hard line breaks). */
#accordionSidebar .collapse-inner .collapse-item {
    display: flex !important;
    align-items: flex-start;
    gap: .6rem;
    white-space: normal !important;
    line-height: 1.35;
}

#accordionSidebar .collapse-inner .collapse-item > i {
    flex: 0 0 1rem;
    margin-top: .15rem;
    text-align: center;
    color: #c0392b;
}

#accordionSidebar .collapse-inner .collapse-item.active {
    color: #a82b20 !important;
    font-weight: 700;
    background: #fdf0ee;
}

#accordionSidebar .collapse-inner .collapse-header {
    color: #6e707e !important;
}


/* ---------------------------------------------------------------------
 * Expanded sidebar
 * ------------------------------------------------------------------- */
@media (min-width: 768px) {
    #accordionSidebar:not(.toggled) .sidebar-brand {
        height: 4rem;
        padding: 1rem;
    }

    #accordionSidebar:not(.toggled) hr.sidebar-divider {
        margin: .5rem 1rem;
        border-top-color: rgba(255, 255, 255, .18);
    }

    #accordionSidebar:not(.toggled) hr.sidebar-divider.my-0 {
        margin-top: 0;
        margin-bottom: 0;
    }

    #accordionSidebar:not(.toggled) .sidebar-heading {
        padding: .5rem 1.25rem .25rem;
        font-size: .65rem;
        letter-spacing: .08em;
        color: rgba(255, 255, 255, .7);
    }

    /* Top-level links: rounded pill inside the panel. */
    #accordionSidebar:not(.toggled) .nav-item .nav-link {
        width: auto !important;
        margin: .1rem .6rem;
        padding: .7rem .75rem;
        border-radius: .6rem;
        color: rgba(255, 255, 255, .92);
        transition: background-color .15s ease, color .15s ease;
    }

    #accordionSidebar:not(.toggled) .nav-item .nav-link i {
        color: rgba(255, 255, 255, .85);
        margin-right: .4rem;
    }

    #accordionSidebar:not(.toggled) .nav-item .nav-link:hover,
    #accordionSidebar:not(.toggled) .nav-item .nav-link:focus-visible {
        background: rgba(0, 0, 0, .12);
        color: #fff;
    }

    #accordionSidebar:not(.toggled) .nav-item .nav-link:focus-visible {
        outline: 2px solid #fff;
        outline-offset: -2px;
    }

    /* Current section: soft highlight -- darker tint and bold white text.
       (The exact page inside an open submenu gets the white pill below, so
       it still stands out.) */
    #accordionSidebar:not(.toggled) .nav-item.active > .nav-link {
        background: rgba(0, 0, 0, .2);
        color: #fff;
        font-weight: 700;
    }

    #accordionSidebar:not(.toggled) .nav-item.active > .nav-link i,
    #accordionSidebar:not(.toggled) .nav-item.active > .nav-link::after {
        color: #fff;
    }

    /* Submenus: inside the red panel instead of a white box. */
    #accordionSidebar:not(.toggled) .nav-item .collapse,
    #accordionSidebar:not(.toggled) .nav-item .collapsing {
        margin: .25rem .6rem .5rem;
    }

    #accordionSidebar:not(.toggled) .nav-item .collapse .collapse-inner {
        background: rgba(0, 0, 0, .18) !important;
        border-radius: .6rem !important;
        box-shadow: none !important;
        margin: 0;
        padding: .4rem 0;
        min-width: 0;
    }

    #accordionSidebar:not(.toggled) .collapse-inner .collapse-header {
        padding: .45rem 1rem .3rem;
        font-size: .62rem;
        letter-spacing: .08em;
        color: rgba(255, 255, 255, .75) !important;
        white-space: normal;
    }

    #accordionSidebar:not(.toggled) .collapse-inner .collapse-item {
        margin: .1rem .4rem;
        padding: .5rem .6rem;
        border-radius: .45rem;
        color: #fff;
        font-size: .82rem;
        transition: background-color .15s ease;
    }

    #accordionSidebar:not(.toggled) .collapse-inner .collapse-item > i {
        color: rgba(255, 255, 255, .8);
    }

    #accordionSidebar:not(.toggled) .collapse-inner .collapse-item:hover,
    #accordionSidebar:not(.toggled) .collapse-inner .collapse-item:focus-visible {
        background: rgba(0, 0, 0, .14);
        color: #fff;
        text-decoration: none;
    }

    #accordionSidebar:not(.toggled) .collapse-inner .collapse-item.active {
        background: #fff;
        color: #a82b20 !important;
    }

    #accordionSidebar:not(.toggled) .collapse-inner .collapse-item.active > i {
        color: #c0392b;
    }

    #accordionSidebar:not(.toggled) #sidebarToggle {
        margin: .75rem 0 1rem;
    }
}

/* Desktop: the expanded sidebar stays in view and scrolls on its own when
   all menus are open, instead of stretching the page. (Not when minimised:
   its flyouts are positioned outside the column and would be clipped.) */
@media (min-width: 992px) {
    #accordionSidebar.sidebar:not(.toggled) {
        position: sticky;
        top: 0;
        align-self: flex-start;
        height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, .3) transparent;
    }

    #accordionSidebar.sidebar:not(.toggled)::-webkit-scrollbar {
        width: 6px;
    }

    #accordionSidebar.sidebar:not(.toggled)::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, .3);
        border-radius: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #accordionSidebar .nav-link,
    #accordionSidebar .collapse-item {
        transition: none !important;
    }
}


/* =====================================================================
 * Logged-out top bar (replaces the sidebar for visitors, who can only see
 * the homepage): logo, homepage section links, Log in button.
 * =================================================================== */
.rd-topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin-right: 1.5rem;
    color: #2f3039;
    font-weight: 800;
    font-size: 1.1rem;
    text-decoration: none;
    white-space: nowrap;
}

.rd-topbar-brand:hover,
.rd-topbar-brand:focus {
    color: #b52d1e;
    text-decoration: none;
}

.rd-topnav {
    display: flex;
    align-items: center;
    gap: .25rem;
}

/* Desktop: links centred in the bar (logo left, links centre, Log in
   right). Absolutely centred so the logo and button widths don't pull
   them off-centre; the bar is position:sticky, so it is the reference. */
@media (min-width: 992px) {
    body.rd-guest .rd-topnav {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }
}

.rd-topnav a {
    padding: .45rem .8rem;
    border-radius: 2rem;
    color: #4a4c57;
    font-weight: 600;
    font-size: .875rem;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.rd-topnav a:hover,
.rd-topnav a:focus-visible {
    background: #fdf0ee;
    color: #b52d1e;
    text-decoration: none;
}

/* Set by the homepage's scroll highlight. */
.rd-topnav a.active {
    background: #fdf0ee;
    color: #b52d1e;
}

.rd-login-btn {
    padding: .4rem 1.25rem;
    border-radius: 2rem;
    background: #d13f2f;
    border: 0;
    color: #fff !important;
    font-weight: 700;
    font-size: .875rem;
}

.rd-login-btn:hover,
.rd-login-btn:focus {
    background: #b52d1e;
    color: #fff;
}

/* Shared side spacing for visitors' pages, so the header's logo/Log in
   line up with the banner and panels. The landing page nests a second
   .container-fluid, which used to add its padding on top of the layout's. */
body.rd-guest {
    --rd-gutter: 2rem;
    --rd-page-max: 75rem;   /* page width cap on wide screens (1200px) */
}

/* Side padding that is at least the gutter, and on wide screens grows so
   the content is a centred 75rem column. % padding is relative to the
   parent's width, which is the full content area for both the header and
   the page container, so their edges always match. */
body.rd-guest .topbar,
body.rd-guest #content > .container-fluid {
    padding-left: max(var(--rd-gutter), calc((100% - var(--rd-page-max)) / 2));
    padding-right: max(var(--rd-gutter), calc((100% - var(--rd-page-max)) / 2));
}

body.rd-guest .topbar {
    /* Pinned, so the section links stay reachable while scrolling. */
    position: sticky;
    top: 0;
    z-index: 1030;
}

body.rd-guest .rd-landing {
    padding-left: 0;
    padding-right: 0;
}

/* SB Admin's overflow-x:hidden on this wrapper disables position:sticky;
   clip hides overflow without that side effect (same fix rabdash-mobile.css
   uses below 992px). */
body.rd-guest #content-wrapper {
    overflow-x: clip;
}

/* Jumping to a section lands its heading below the pinned header. */
body.rd-guest .rd-landing > section {
    scroll-margin-top: 5.5rem;
}

@media (max-width: 991.98px) {
    body.rd-guest {
        --rd-gutter: 1rem;
    }
}

@media (max-width: 767.98px) {
    body.rd-guest {
        --rd-gutter: .75rem;
    }

    body.rd-guest .rd-landing > section {
        scroll-margin-top: 4.5rem;
    }
}

/* Section links only where there's room; on smaller screens the page is
   one short scroll and the banner's "Learn more" covers it. */
@media (max-width: 991.98px) {
    .rd-topnav {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rd-topnav a {
        transition: none;
    }
}
