/* ============================================================
   Bootstrap 5 Navbar — Mobile Offcanvas Fix
   ============================================================ */

/* ----------------------------------------------------------
   1. Navbar base (all viewports)
   ---------------------------------------------------------- */
.cis-navbar {
    z-index: 1030;
    position: relative;
}

/* ----------------------------------------------------------
   2. Mobile header bar (< 992px)
   ---------------------------------------------------------- */
@media (max-width: 991.98px) {
    /* Container: single-row flex, no wrapping */
    .cis-navbar .container-fluid {
        flex-wrap: nowrap;
        min-height: 56px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    /* Navbar padding — tighter on mobile */
    .cis-navbar {
        padding: 0 0.75rem;
    }

    /* CIS brand: leave room for red side-menu button */
    .cis-has-sidemenu .cis-navbar {
        padding-left: 3.25rem;
    }

    /* Brand logo */
    .navbar-brand-switcher {
        margin-right: 0.5rem !important;
    }

    /* Hide desktop collapse entirely on mobile */
    #mainNavbarDesktop {
        display: none !important;
    }

    /* Desktop profile area: take no flex space but stay in DOM for #basket */
    .navbar-actions {
        flex: 0 0 0px !important;
        width: 0 !important;
        overflow: visible;
        padding: 0 !important;
        margin: 0 !important;
    }
    /* Hide desktop profile icons/dropdown on mobile, keep #basket accessible */
    .navbar-actions .cis-profile > *:not(#basket) {
        display: none !important;
    }
}

/* ----------------------------------------------------------
   3. Mobile action buttons (search + cart)
   ---------------------------------------------------------- */
.btn-mobile-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    color: #111;
    position: relative;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn-mobile-action:hover,
.btn-mobile-action:active {
    background: rgba(0,0,0,0.05);
    color: #d40511;
}

/* Cart badge */
.cart-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #d40511;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ----------------------------------------------------------
   4. Hamburger toggler
   ---------------------------------------------------------- */
.cis-navbar .navbar-toggler {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 0.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    margin-left: 0.25rem;
    flex-shrink: 0;
}
.cis-navbar .navbar-toggler:focus {
    box-shadow: none;
    outline: 2px solid rgba(212, 5, 17, 0.3);
    outline-offset: -2px;
}
.cis-navbar .navbar-toggler-icon {
    width: 22px;
    height: 22px;
}

/* ----------------------------------------------------------
   5. Offcanvas overrides
   ---------------------------------------------------------- */
#mainNavbarOffcanvas {
    max-width: 340px;
    z-index: 2200;
}
#mainNavbarOffcanvas .offcanvas-backdrop,
.offcanvas-backdrop {
    z-index: 2150;
}

@media (max-width: 575.98px) {
    #mainNavbarOffcanvas {
        max-width: 100vw;
    }
}

/* Offcanvas header */
#mainNavbarOffcanvas .offcanvas-header {
    border-bottom: 1px solid rgba(0,0,0,0.08);
    padding: 1rem 1.25rem;
}

/* Offcanvas body */
#mainNavbarOffcanvas .offcanvas-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* ----------------------------------------------------------
   6. Offcanvas inner styles
   ---------------------------------------------------------- */

/* User info */
.offcanvas-user-info {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* Brand switcher */
.offcanvas-brand-switcher {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.offcanvas-brand-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 2rem;
    border: 1px solid #e0e0e0;
    text-decoration: none;
    color: #495057;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
}
.offcanvas-brand-item:hover {
    background: rgba(212, 5, 17, 0.06);
    color: #d40511;
    border-color: rgba(212, 5, 17, 0.2);
    text-decoration: none;
}
.offcanvas-brand-item img {
    border-radius: 3px;
}

/* Search */
.offcanvas-search {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.offcanvas-search .form-control {
    border-radius: 0.5rem;
    border: 1px solid #ddd;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}
.offcanvas-search .form-control:focus {
    border-color: #d40511;
    box-shadow: 0 0 0 2px rgba(212, 5, 17, 0.1);
}

/* Nav links */
.offcanvas-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.5rem 0;
}
.offcanvas-nav-link {
    display: block;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    color: #222;
    text-decoration: none;
    font-size: 0.95rem;
}
.offcanvas-nav-link:hover {
    background: rgba(0,0,0,0.03);
    color: #d40511;
    text-decoration: none;
}
.offcanvas-nav-link.active {
    color: #d40511;
    border-left: 3px solid #d40511;
    padding-left: calc(1.25rem - 3px);
}

/* Accordion styling in offcanvas */
.offcanvas-nav .accordion-item {
    border: none;
    background: transparent;
}
.offcanvas-nav .accordion-button {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: #222;
    background: transparent;
    box-shadow: none;
    border-radius: 0 !important;
}
.offcanvas-nav .accordion-button:not(.collapsed) {
    color: #d40511;
    background: rgba(212, 5, 17, 0.03);
}
.offcanvas-nav .accordion-button::after {
    width: 1rem;
    height: 1rem;
    background-size: 1rem;
}
.offcanvas-nav .accordion-body {
    padding: 0;
}

/* Nested accordion (sections inside Modules) */
.offcanvas-nav .accordion .accordion .accordion-button {
    padding: 0.6rem 1.25rem 0.6rem 2rem;
    font-weight: 500;
    font-size: 0.9rem;
}
.offcanvas-nav .accordion .accordion .accordion-button:not(.collapsed) {
    background: rgba(0,0,0,0.02);
}

/* Course links inside accordion */
.offcanvas-course-link {
    display: block;
    padding: 0.5rem 1.25rem 0.5rem 3rem;
    font-size: 0.85rem;
    color: #555;
    text-decoration: none;
    border-bottom: 1px solid rgba(0,0,0,0.03);
}
.offcanvas-course-link:last-child {
    border-bottom: none;
}
.offcanvas-course-link:hover {
    background: rgba(0,0,0,0.03);
    color: #d40511;
    text-decoration: none;
}

/* Profile actions at bottom */
.offcanvas-profile-actions {
    margin-top: auto;
    border-top: 1px solid rgba(0,0,0,0.08);
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.offcanvas-profile-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: #495057;
    font-size: 0.9rem;
    font-weight: 500;
}
.offcanvas-profile-link:hover {
    background: rgba(0,0,0,0.04);
    color: #222;
    text-decoration: none;
}
.offcanvas-profile-link.text-danger:hover {
    background: rgba(220, 53, 69, 0.06);
    color: #dc3545;
}

/* ----------------------------------------------------------
   7. Basket mobile fix — bottom sheet
   ---------------------------------------------------------- */
@media (max-width: 991.98px) {
    #basket {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        margin: 0 !important;
        border-radius: 1rem 1rem 0 0;
        max-width: 100vw;
        min-width: auto;
        max-height: 70vh;
        overflow-y: auto;
        z-index: 1050;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
    }
}

/* ----------------------------------------------------------
   8. Autocomplete z-index (above offcanvas)
   ---------------------------------------------------------- */
.ui-autocomplete {
    z-index: 2300 !important;
}

/* ----------------------------------------------------------
   9. CIS side menu coexistence
   ---------------------------------------------------------- */
/* Side menu elements keep their existing z-index (2000/2100).
   Offcanvas at 2200 sits above them when open.
   No changes needed to side menu CSS. */
