// The only class we need for icons is .icon
// Standardize the size, padding and alignment for all icons in Moodle.

// Size of default icons.
$icon-width: 20px;
$icon-height: 20px;
// Size of big icons.
$icon-medium-width: 24px;
$icon-medium-height: 24px;
// Size of big icons.
$icon-big-width: 60px;
$icon-big-height: 60px;
// Size of icon boxes.
$icon-box-width: 48px;
$icon-box-height: 48px;

// stylelint-disable
$iconsizes: () !default;
$iconsizes: map-merge((0: 0,
        1: ($icon-width * .25),
        2: ($icon-width * .5),
        3: $icon-width,
        4: ($icon-width * 1.5),
        5: ($icon-width * 2),
        6: ($icon-width * 2.5),
        7: ($icon-width * 3)), $iconsizes);
// stylelint-enable

.icon {
    width: $icon-width;
    height: $icon-height;
    line-height: 18px;
    // vertical-align: middle;
    margin: 0;
    padding: 0;
    box-sizing: content-box;

    .sup & {
        width: 16px;
        height: 16px;
        font-size: 12px;
    }

    &.itemicon {
        margin-right: 0.25rem;
    }

    &.spacer {
        display: none;
    }

    &.iconsize-big {
        width: $icon-big-width;
        height: $icon-big-height;
        font-size: $icon-big-height;
    }
}

.icon-box {
    line-height: 1.5;
}

        // Mainly for icons in page title
        .iconlarge {
            font-size: 40px;
            width: 40px;
            height: 40px;
        }

        h2 .icon.iconlarge {
            margin-right: .5rem;
        }

.action-menu-item a:first-of-type>.icon {
    margin-left: 0.5rem;
}

.action-menu-item a:hover {
    text-decoration: none;
}

// YUI 2 Tree View icons must not have a margin left.
.ygtvcell .icon {
    margin-left: 0 !important; /* stylelint-disable-line declaration-no-important */

    .theme-dark & {
        filter: invert(1);
    }
}

// In the navigation, tree icons should not have margins.
.block_navigation,
.block_settings {
    .tree_item .icon {
        margin-left: 0;
    }
}

[data-action=toggle-drawer] .icon {
    margin: 0;
}

// Apply in special cases where the default icons styles does not work properly. Eg file picker buttons.
.icon-no-spacing a>.icon {
    margin: 0;
}

.icon-no-margin {
    .icon {
        margin-left: 0;
        margin-right: 0;
        margin-top: 0;
        margin-bottom: 0;

        line-height: 20px;
    }
}

.completion-dialog {
    font-size: $font-size-xs;

    .rui-icon {
        margin-right: 5px;
        width: 14px;
        height: 14px;
        filter: invert(1);
    }
}


.icon-large>.icon {
    width: ($icon-width * 2);
    height: ($icon-height * 2);
}

@each $size,
$length in $iconsizes {
    .icon-size-#{$size} {
        .icon {
            height: $length !important;
            /* stylelint-disable-line declaration-no-important */
            width: $length !important;
            /* stylelint-disable-line declaration-no-important */
            font-size: $length !important;
            /* stylelint-disable-line declaration-no-important */
        }
    }
}

.helplink .icon {
    margin-right: 0.5rem;
}

.action-icon + a {
    margin-left: 0.5rem;
}

.dropdown-item.action-icon {
    border-radius: $btn-border-radius-lg;
}

.icon-req {
    padding: 4px;
    position: relative;
    top: 0;

    width: auto;
    height: auto;
    background: $red-100;
    border-radius: $btn-border-radius;

    font-size: 8px;
    color: $red-600!important;

    .fdescription & {
        background-color: transparent;
        color: $yellow-700;
    }
}

.icon-info {
    padding: 7px;
}

// Moodle 4.x.
.icons-collapse-expand {
    display: flex;
    align-items: center;

    img {
        .theme-dark & {
            filter: invert(1);
        }
    }

    .expanded-icon {
        display: flex;
        align-items: center;
        padding: 0!important;
    }

    .collapsed-icon {
        display: none;
    }

    &.collapsed {
        .expanded-icon {
            display: none;
        }

        .collapsed-icon {
            display: flex;
            align-items: center;
            line-height: 0;
        }
    }
}

.dir-rtl .icons-collapse-expand.collapsed .collapsed-icon {
    transform: scaleX(1);
}

.rui-adv-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;

    background-color: $gray-100;
    color: $gray-600;

    font-size: 10px;
    font-weight: $font-weight-bold;

    width: 16px;
    height: 16px;
    border-radius: 12px;

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

.activityiconcontainer {
    //margin-top: 5px;
    margin-right: 12px;
    width: $activity-iconcontainer-width;
    height: $activity-iconcontainer-height;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background-color: $gray-100;
    border-radius: $activity-iconcontainer-width;
    padding: 0.7rem;

    &.small {
        width: $activity-iconcontainer-width * 0.5;
        height: $activity-iconcontainer-height * 0.5;
    }

    a {
        line-height: 0;
    }
}

@each $type, $value in $activity-icon-colors {
    .activityiconcontainer.#{$type} {
        background-color: $value;
        .activityicon,
        .icon {
            margin: 0;
            height: 24px;
            width: 24px;
            filter: brightness(0) invert(1);
        }
    }
}

.icon-box {
    width: $icon-box-width;
    height: $icon-box-height;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background-color: $gray-100;
    border-radius: 12px;
    padding: 0.7rem;

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

    .icon {
        margin: 0;
        height: $icon-medium-width;
        width: $icon-medium-height;
    }
}


// Make activtity colours available for custom modules.
:root {
    @each $type,
    $value in $activity-icon-colors {
        --activity#{$type}: #{$value};
    }
}

.movecategory {
    .icon {
        background-color: $white;
        border-radius: $btn-border-radius-lg;
        box-shadow: $box-shadow-md;
        padding: 10px;
        width: 16px;
        height: 16px;

        transition: $transition-base;

        &:hover {
            box-shadow: $box-shadow;
        }
    
        .theme-dark & {
            filter: invert(1);
            box-shadow: none;
        }
    }
}

.movefield {
    .icon {
        background-color: $white;
        border-radius: $btn-border-radius-lg;
        box-shadow: $box-shadow;
        padding: 8px;
        width: 14px;
        height: 14px;

        transition: $transition-base;

        &:hover {
            box-shadow: $box-shadow-md;
        }
    
        .theme-dark & {
            filter: invert(1);
            box-shadow: none;
        }
    }
}


.generaltable {
    .itemicon {
        padding: 3px;
        border-radius: 30px;
        background-color: $gray-100;
        box-sizing: border-box;
    }
}