/* Book navigation improvements for MB2 NewLearning + mod_book. */

/* Hide available-but-not-on-course-page activities only in the MB2 TOC. */
.coursetoc-section-modules .booknav-stealth-hidden {
    display: none !important;
}

/* --- Book's own Previous / Next controls --------------------------------- */
/* Keep Moodle Book's native icon-only arrows, but make the hit-area and visual
   treatment clearer. This deliberately does not inject Previous/Next text. */
.path-mod-book a.btn-previous[href*="/mod/book/view.php"],
.path-mod-book a.btn-next[href*="/mod/book/view.php"],
.path-mod-book a.booknav-enhanced-button {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid rgba(0, 0, 0, .10) !important;
    background: rgba(255, 255, 255, .96) !important;
    color: var(--bs-primary, #0d6efd) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .10) !important;
    text-decoration: none !important;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease !important;
}

.path-mod-book a.btn-previous[href*="/mod/book/view.php"]:hover,
.path-mod-book a.btn-next[href*="/mod/book/view.php"]:hover,
.path-mod-book a.booknav-enhanced-button:hover,
.path-mod-book a.booknav-enhanced-button:focus-visible {
    transform: translateY(-1px) scale(1.06);
    background: #fff !important;
    box-shadow: 0 7px 18px rgba(0, 0, 0, .15) !important;
    text-decoration: none !important;
}

.path-mod-book a.btn-previous[href*="/mod/book/view.php"]:active,
.path-mod-book a.btn-next[href*="/mod/book/view.php"]:active,
.path-mod-book a.booknav-enhanced-button:active {
    transform: scale(.96);
}

.path-mod-book a.btn-previous[href*="/mod/book/view.php"] .icon,
.path-mod-book a.btn-next[href*="/mod/book/view.php"] .icon,
.path-mod-book a.booknav-enhanced-button .icon {
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    font-size: 1.35rem !important;
    line-height: 1 !important;
}

/* Bottom MB2 course navigation: show only Previous / Next and ensure both
   labels sit on exactly the same vertical and horizontal axis. */
.path-mod-book .theme-coursenav .coursenav-modname {
    display: none !important;
}

.path-mod-book .theme-coursenav .coursenav-prev,
.path-mod-book .theme-coursenav .coursenav-next {
    display: flex !important;
    align-items: stretch !important;
}

.path-mod-book .theme-coursenav .coursenav-link {
    min-height: 54px !important;
    height: 54px !important;
    padding: 0 1rem !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

.path-mod-book .theme-coursenav .coursenav-text {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
}

/* --- MB2 Sections sidebar: Book > chapters ------------------------------- */
.coursetoc-section-modules .booknav-book-item {
    position: relative;
    flex-wrap: wrap !important;
    align-items: center !important;
    padding-right: 2rem;
}

.coursetoc-section-modules .booknav-book-item > .booknav-book-link {
    flex: 1 1 auto;
    min-width: 0;
}

.booknav-book-toggle {
    position: absolute;
    top: .28rem;
    right: .2rem;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.booknav-book-toggle:hover,
.booknav-book-toggle:focus-visible {
    background: rgba(0, 0, 0, .055);
}

.booknav-book-toggle-icon {
    display: inline-block;
    font-size: 1.2rem;
    line-height: 1;
    transform: rotate(90deg);
    transition: transform .16s ease;
}

.booknav-collapsed .booknav-book-toggle-icon {
    transform: rotate(0deg);
}

.booknav-chapters {
    flex: 0 0 100%;
    width: 100%;
    margin: .25rem 0 .2rem 0;
    padding: .12rem 0 .12rem 1.82rem;
    list-style: none;
    border-left: 1px solid rgba(0, 0, 0, .09);
}

.booknav-chapters[hidden] {
    display: none !important;
}

.booknav-chapter-item {
    margin: 0;
    padding: 0;
}

.booknav-chapter-link {
    min-height: 30px;
    padding: .28rem .28rem .28rem .15rem;
    display: flex;
    align-items: center;
    gap: .48rem;
    text-decoration: none !important;
    border-radius: .35rem;
    font-size: .82rem;
    line-height: 1.2;
}

.booknav-chapter-link:hover,
.booknav-chapter-link:focus-visible {
    background: rgba(0, 0, 0, .045);
}

.booknav-chapter-marker {
    width: .42rem;
    height: .42rem;
    border-radius: 50%;
    flex: 0 0 .42rem;
    border: 1px solid currentColor;
    opacity: .45;
}

.booknav-current-chapter > .booknav-chapter-link {
    font-weight: 700;
    background: rgba(37, 161, 142, .09);
}

.booknav-current-chapter .booknav-chapter-marker {
    opacity: 1;
    background: currentColor;
}

.booknav-subchapter > .booknav-chapter-link {
    padding-left: .85rem;
    font-size: .79rem;
}

.booknav-chapter-title {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

@media (max-width: 767.98px) {
    .path-mod-book a.btn-previous[href*="/mod/book/view.php"],
    .path-mod-book a.btn-next[href*="/mod/book/view.php"],
    .path-mod-book a.booknav-enhanced-button {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
    }

    .path-mod-book .theme-coursenav .coursenav-link {
        min-height: 50px !important;
        height: 50px !important;
    }
}
