/* Chapter mode: full-height TOC left; book-style toolbar + full-height grid right */
body.prof-chapter-mode {
    min-height: 100vh;
    display: flex;
    flex-direction: column;

    & .book-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    & .book-container > .container {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        width: 100%;
        max-width: none;
    }

    & .book-container .row {
        flex: 1;
        display: flex;
        min-height: 0;
        margin-left: 0;
        margin-right: 0;
    }

    & .book-container .content-column {
        flex: 1;
        min-height: 0;
        min-width: 0;
        width: 100% !important;
        max-width: none !important;
        display: flex;
        flex-direction: column;
    }

    & #contentBody {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    & .prof-chapter-shell {
        flex: 1;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        min-height: 0;
    }

    & .prof-chapter-toc-aside {
        width: 280px;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        min-height: 0;
        background: #f8f9fa;
        border-right: 1px solid #e0e0e0;
    }

    & .prof-chapter-toc-wrap {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 10px 8px 16px 6px;
        font-size: 14px;
    }

    & .prof-chapter-right {
        flex: 1;
        min-width: 0;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    & .prof-chapter-toolbar-bar.content-header {
        margin: 0;
        padding: 14px 12px;
        position: relative;
        flex-shrink: 0;
        z-index: 2;
    }

    & .prof-chapter-toolbar-inner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    & .prof-chapter-radio-group {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }

    & .prof-chapter-radio {
        margin: 0;
        cursor: pointer;

        & input {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            border: 0;
        }
    }

    & .prof-chapter-host {
        flex: 1;
        min-height: 0;
        width: 100%;
        position: relative;

        & .w2ui-layout {
            position: absolute !important;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
        }
    }

    & .prof-toc-list {
        list-style: none;
        margin: 0;
        padding: 0;

        & li {
            margin: 0 0 4px 0;
            padding: 0;
            line-height: 1.35;
        }
    }

    & .prof-toc-link {
        display: block;
        padding: 4px 6px;
        border-radius: 4px;
        color: #333;
        text-decoration: none;

        &:hover {
            background: #e8eef3;
            text-decoration: none;
        }
    }

    & .prof-toc-back {
        font-weight: 600;
        margin-bottom: 6px;
    }

    & .prof-toc-chapter {
        font-weight: 600;
        margin: 8px 0 6px 0;
    }

    & .prof-toc-sub {
        padding-left: 12px;
    }
}

/* my dashboard: full-width column and height for w2layout */
.content-wrapper.prof-main-wrap {
    align-self: stretch;
    max-width: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    width: 100%;
}

#contentBody {
    flex: 1;
    min-height: min(420px, calc(100vh - 140px));
}

/* Layout */
.w2ui-layout > div .w2ui-panel {
    .w2ui-panel-content {
        background-color: #f8f9fa;
    }
}

/* Sidebar */
.w2ui-sidebar {
    & .w2ui-sidebar-top {
        .w2ui-flat-left,
        .w2ui-flat-right {
            height: 28px;
        }
    }

    & .w2ui-sidebar-body {
        overflow:auto;

        & .w2ui-node-group :nth-child(1) {
            display: none;
        }

        .w2ui-node:not(.w2ui-node-flat) {
            &.w2ui-level-0 {
                margin: 8px 5px 0 16px;
                .w2ui-node-data {
                    margin-left: 9px !important;
                }
            }
            &.w2ui-node.w2ui-level-1 {
                margin: 0 6px 0 16px;
                .w2ui-node-data {
                    margin-left: 9px !important;
                }
            }
            &:hover {
                background-color: #f1f0f2;
            }
            &.w2ui-selected:not(.sidebar-button, .sidebar-group),
            &.w2ui-selected:not(.sidebar-button, .sidebar-group):hover {
                background-color: #eee8f2 !important;
                border: 1px solid #eee8f2 !important;
                background: linear-gradient( to right, #a10a8d 0 3px, transparent 3px );
                border-radius: 3px;
            }

            .w2ui-node-data {
                padding: 5px 3px;
            }

            .w2ui-node-text {
                font-size: 14px;
            }

            &.sidebar-group {
                border: 0px;
                border-top: 1px solid #e3e3e3;
                margin-top: 10px;
                padding-top: 10px;
                margin: 10px 8px 4px 4px;
                background-color: transparent !important;

                .w2ui-node-image {
                    display: none;
                }

                .w2ui-sb-toggle {
                    width: 22px;
                    padding-left: 8px;
                }

                .w2ui-node-text {
                    margin-left: 0px !important;
                    color: #8e8e8e;
                    font-size: 14px;
                    text-transform: uppercase;
                }
            }
        }


        .w2ui-node-group {
            border-top: 1px solid #e3e3e3;
            margin-top: 10px;
            padding-top: 14px;
            margin: 12px 8px 0 8px;
            color: #8e8e8e;
            font-size: 13px;

            :nth-child(1) {
                display: none; // hide show/hide text
            }

            /* &:after {
                content: '▾'; // ⌄ ▾ ▿
                display: inline;
                float: right;
                width: 10px;
                color: #8e8e8e;
                font-size: 14px;
                margin-top: -2px;
            } */
        }

        .w2ui-node-flat:not(.sidebar-button) {
            padding: 6px 0;
        }

        .w2ui-node.sidebar-button {
            background-color: #25a2eb !important;
            color: white;
            border-radius: 26px;
            margin: 5px 5px !important;
            &:hover {
                background-color: #2a92cf !important;
            }
            .w2ui-node-data {
                display: flex;
                justify-content: center;
                margin-left: 0px !important;
                .w2ui-node-text {
                    margin-left: 0px;
                    color: white;
                    text-shadow: none;
                }
                .w2ui-node-image span {
                    color: white;
                    text-shadow: 0px 0px 2px #232323;
                }
            }
            .w2ui-selected,
            .w2ui-selected:hover {
                background-color: #25a2eb !important;
                border: 1px solid blue !important;
            }
        }

        .w2ui-selected,
        .w2ui-selected:hover {
            background-color: #efe5f6;
            border: 1px solid #b390cd;
        }
    }
}
.w2ui-grid {
    border: none;

    & .w2ui-grid-header {
        background-color: #fdfefd;
        border-bottom: 1px solid #e9e9e9 !important;
        font-size: 18px;
        height: 40px;
    }
    & .w2ui-grid-toolbar {
        padding-top: 18px;
        height: 65px;
        background-color: #fdfefd;

        & .w2ui-grid-search-input .w2ui-search-all {
            background-color: #f7f9fa !important;
            &:focus {
                border-color: transparent !important;
                box-shadow: 0 0 0 2px rgba(114, 178, 255) !important;
                outline: none !important;
            }
        }
    }

    & .w2ui-grid-body {
        top: 80px;
        border: 1px solid #ddd;

        & table td {
            font-size: 14px;
        }
    }

    & .w2ui-grid-footer {
        background-color: #fdfefd;
        font-size: 12px;
        padding: 4px 0;
        color: #b3b3b3;
    }
}

.w2ui-field > label {
    margin-top: 12px;
}

/* Class tools embedded in book viewer (#contentBody); w2grid renders into this node (gets .w2ui-grid). */
.book-prof-embed-root {
    min-height: max(calc(100vh - 220px), 400px);
    margin: 0;
    padding: 0;
    outline: 12px solid #fdfefd;

    /* Poll / quiz / flashcard preview: drop the list “frame” (keep it for w2grid only) */
    &:has(.usolver-container) {
        outline: none;
    }

    & .os-content {
        padding: 0;
        margin: 0;
    }
}

/* Toolbar row in #bookProfToolsToolbarHost */
.book-prof-embed-toolbar-row {
    margin: 0;
}

.book-prof-embed-toolbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;

    & > .hamburger-menu,
    & > .book-level-up {
        flex-shrink: 0;
        margin-right: 4px;
    }

    /* Match .content-header .book-controls .btn (e.g. #myCourses): flat chrome, hover only */
    & .book-prof-embed-ai-assistant,
    & .book-prof-embed-my-dashboard {
        flex-shrink: 0;
        border: 1px solid transparent;
        background-color: transparent;
        color: #495057;
        padding: 6px 10px;
        height: 36px;
        border-radius: 4px;
        transition: all 0.2s ease;
        font-size: calc(12px * var(--bookviewer-font-scale, 1));
        box-shadow: none;

        &:hover {
            background-color: #e9ecef;
            border-color: #adb5bd;
            color: #495057;
        }

        &.active {
            border-color: #a9bfdc;
            background: #eaf2ff;
            color: #2f4f79;
        }

        &:focus,
        &:active:focus,
        &.focus,
        &:active.focus {
            outline: none !important;
            outline-offset: 0;
            -webkit-box-shadow: none;
            box-shadow: none;
            background-color: transparent;
            border-color: transparent;
            color: #495057;
        }

        &:focus-visible {
            outline: none !important;
        }

        &.active:focus,
        &.active:active:focus,
        &.active.focus,
        &.active:active.focus {
            background: #eaf2ff;
            border-color: #a9bfdc;
            color: #2f4f79;
        }

        & .glyphicon {
            font-size: calc(18px * var(--bookviewer-font-scale, 1));
        }
    }

    & .book-prof-embed-ai-assistant {
        margin-left: auto;

        & .ai-toggle-brand {
            display: inline-block;
            font-size: 21px;
            line-height: 1;
            vertical-align: -2px;
        }

        &.active .ai-toggle-brand {
            color: #2f4f79;
        }
    }

    & .book-prof-embed-radio-group {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }
}

.book-prof-embed-radio {
    margin: 0;
    cursor: pointer;

    & input {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        border: 0;
    }
}

.w2ui-grid .w2ui-grid-empty-msg {
    top: 30px;
    background-color: rgb(255 255 255 / 51%);
    > div {
        font-size: 16px;
        line-height: 1.7;
    }
}
