$courseindex-link-color: $list-group-action-color !default;
$courseindex-link-color-selected: $body-color-secondary !default;
$courseindex-link-dimmed-color: $gray-600 !default;
$courseindex-link-hover-color: $primary-color-600 !default;
$courseindex-link-hover-bg: $primary-color-200 !default;
$courseindex-item-dragging-bg: theme-color-level('info', -11) !default;
$courseindex-item-dragging-border: theme-color-level('info', -9) !default;
$courseindex-item-active-border: $gray-300 !default;
$courseindex-item-active-bg: $primary-color-100 !default;
$courseindex-link-color-active: $primary-color-500 !default;
$courseindex-item-page-bg: $primary-color-100 !default;
$courseindex-item-padding-y: 3px;
$courseindex-item-padding-x: 20px;
$courseindex-item-radius: 5px !default;
$courseindex-item-current: $primary-color-100 !default;

// Dark mode.
$dm-courseindex-link-color: $dm-list-group-action-color !default;
$dm-courseindex-link-color-active: $primary-color-600 !default;
$dm-courseindex-link-dimmed-color: $dm-gray-600 !default;
$dm-courseindex-link-hover-color: $primary-color-600 !default;
$dm-courseindex-item-active-border: $dm-gray-300 !default;
$dm-courseindex-item-active-bg: var(--primary-color-800) !default;
$dm-courseindex-item-page-bg: $dm-gray-100 !default;
$dm-courseindex-item-current: var(--primary-color-800) !default;
$dm-courseindex-item-dragging-bg: theme-color-level('info', -11) !default;
$dm-courseindex-item-dragging-border: theme-color-level('info', -9) !default;

@mixin courseindex-item-hover() {
    @include hover-focus() {
        background-color: $courseindex-item-page-bg;
        color: $courseindex-link-hover-color;

        .theme-dark & {
            background-color: $dm-courseindex-item-page-bg;
            color: $dm-courseindex-link-hover-color;
        }

        .courseindex-link,
        .courseindex-chevron {
            color: $courseindex-link-hover-color;
            cursor: pointer;

            .theme-dark & {
                color: $dm-courseindex-link-hover-color;
            }
        }

        &.dimmed {
            color: $courseindex-link-hover-color;

            .theme-dark & {
                color: $dm-courseindex-link-hover-color;
            }

            .courseindex-link,
            .courseindex-chevron {
                color: $courseindex-link-hover-color;

                .theme-dark & {
                    color: $dm-courseindex-link-hover-color;
                }
            }
        }

        &.draggable {
            cursor: pointer;
        }
    }
}

@mixin courseindex-item-dragging() {
    &.dragging {
        border: $border-width solid $courseindex-item-dragging-border;
        background-color: $courseindex-item-dragging-bg;

        .theme-dark & {
            border: $border-width solid $dm-courseindex-item-dragging-border;
            background-color: $dm-courseindex-item-dragging-bg;
        }
    }
}

.courseindex {
    margin: 1px;

    // Both activity and section items.
    .courseindex-item {
        align-items: center;

        &.courseindex-section-title a {
            display: block;

            font-size: 14px;
            font-weight: $font-weight-medium;
            color: $body-color;

            svg {
                line-height: 0;
            }

            .theme-dark & {
                color: $dm-body-color;
            }
        }

        .icons-collapse-expand {
            line-height: 1;
        }

        .courseindex-name,
        .courseindex-link {
            width: 100%;
            margin: 1px 0;
            padding: $courseindex-item-padding-y;
            border: 0;
            @include border-radius($courseindex-item-radius);
            position: relative;

            color: $body-color-light;
            font-size: $font-size-xs;

            .completion_complete & {
                text-decoration: line-through;
                opacity: .4;
            }

            .theme-dark & {
                color: $dm-body-color-light;
            }
        }

        .courseindex-link {
            @include courseindex-item-hover();
        }

        @include courseindex-item-dragging();

        &.active {
            color: $gray-400;
            background-color: $courseindex-item-active-bg;
            border-color: $courseindex-item-active-border;

            .theme-dark & {
                color: $dm-gray-400;
                background-color: $dm-gray-100;
                border-color: $dm-border-color;
            }
        }

        // Hidden elements.
        &.dimmed {
            color: $courseindex-link-dimmed-color;

            .courseindex-link,
            .courseindex-chevron {
                color: $courseindex-link-dimmed-color;
            }

            // Current page dimmed item.
            &.pageitem {
                color: $courseindex-link-color-selected;

                .theme-dark & {
                    color: $dm-courseindex-link-color-active;
                }

                a {
                    color: $courseindex-link-color-selected;

                    .theme-dark & {
                        color: $dm-courseindex-link-color-active;
                    }
                }
            }
        }

        // Restrictions icon.
        .courseindex-locked {
            display: none;
        }

        &.restrictions {
            .courseindex-locked {
                display: block;

                .rui-icon-container {
                    background-color: $yellow-200;
                    width: 16px;
                    height: 16px;
                    border-radius: 30px;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                }

                .icon {
                    width: 16px;
                    height: 16px;
                }
            }
        }

        // Current page item.
        &.pageitem {
            scroll-margin: 80px;
            border-radius: $courseindex-item-radius;
            align-items: center;

            .courseindex-link,
            .courseindex-name {
                &:before {
                    content: '';
                    position: absolute;
                    top: -2px;
                    left: -2px;
                    right: -2px;
                    bottom: -2px;
                    z-index: -1;
                    background-color: $courseindex-item-active-bg;
                    border-radius: $courseindex-item-radius;
                    color: $courseindex-link-color-active;

                    .theme-dark & {
                        background-color: $dm-courseindex-item-active-bg;
                        color: $dm-courseindex-link-color-active;
                    }
                }

                @include hover-focus() {
                    background-color: $courseindex-link-hover-bg;
                    color: $courseindex-link-hover-color;

                    .courseindex-link,
                    .courseindex-chevron {
                        color: $courseindex-link-hover-color;
                    }
                }
            }

            .theme-dark & {
                background-color: $dm-courseindex-item-page-bg;
                color: $dm-courseindex-link-color-active;
            }

            a {
                color: $courseindex-link-color-active;

                .theme-dark & {
                    color: $dm-courseindex-link-color-active;
                }
            }
        }

        // Completion.
        .completioninfo {
            line-height: 0;
            position: absolute;
            right: 2px;
            z-index: 3;

            img {
                width: 18px;
                height: 18px;
            }

            &:empty {
                display: none;
            }

            &.completion_complete {
                color: $success;
            }

            &.completion_fail {
                color: $danger;
            }
        }

        &.indented {
            margin-left: map-get($spacers, 3);
        }
    }

    // The full section collapsable.
    .courseindex-section {
        @include courseindex-item-dragging();
        border-radius: $courseindex-item-radius;

        .current-badge {
            line-height: $line-height-base;
            display: none;
        }

        &.current {
            background-color: $courseindex-item-current;

            .current-badge {
                display: inline-block;
            }
        }

        &.dropready .courseindex-item-content {
            /* Extra dropzone space */
            padding-bottom: 1em;
        }

        .courseindex-sectioncontent {
            .courseindex-item {

                .courseindex-link,
                .courseindex-name {
                    padding-left: 6px;
                    padding-right: 6px;
                }
            }
        }
    }

    .courseindex-sectioncontent {
        margin-left: 24px;
    }

    // Element visible only on editing mode.
    .d-flex-noedit {
        display: none;
    }

    &.editing {
        .d-flex-noedit {
            display: flex;
        }
    }

    // Placeholders.
    .media-list {
        .placeholder-circle {
            height: 20px;
            width: 20px;
            border-radius: $btn-border-radius;
        }

        .placeholder-rec {
            width: 50%;
            height: 20px;
            border-radius: $btn-border-radius;
            margin: 0.5rem 0;
        }
    }
}

#courseindexdrawercontrols {
    position: absolute;
    top: 35px;
    right: 0;

    @include media-breakpoint-between(xs, md) {
        top: 30px;
        right: 16px;
    }
}