// Toolbar
$toolbar-height: 42px;

// Plannable events
$plannable-events-title-height: 50px;
$plannable-events-height: calc(100% - $plannable-events-title-height);
$plannable-events-container-width: 300px;

// Resource planner defaults
$resource-planner-container-width: calc(100% - $plannable-events-container-width - $padding-default);
$resource-planner-error-color: color(text-color-error);
$resource-planner-warning-color: color(text-color-warning);

// Resources
$resource-planner-resource-height: 50px;

.classlist-resource-planner {
    .dbqdclrp-container {
        display: flex;
        flex-direction: column;
        gap: $padding-default;
        height: 100%;

        .dbqdclrp-resource-planner-container {
            display: flex;
            flex-direction: row;
            gap: $padding-default;
            height: calc(100% - $toolbar-height - $padding-default);

            .dbqdclrp-resource-plannable-events-container {
                position: relative;
                display: flex;
                flex-direction: column;
                flex-shrink: 0;
                width: $plannable-events-container-width;
                height: 100%;
                background: $text-color-inverse; // There didn't seem to be a proper variable for a black background for dark mode and a white background for light mode. This color matches the Mobiscroll view background.

                // .dbqdclrp-resource-plannable-events-title {
                //     display: flex;
                //     align-items: center;
                //     height: $plannable-events-title-height;
                //     padding: $padding-default;
                //     font-weight: $font-weight-bold;
                //     font-size: $font-size-medium;
                // }

                .dbqdclrp-resource-plannable-events-header {
                    display: flex;
                    flex-direction: column;
                    margin: $margin-default;
                    gap: $padding-default;

                    .dbqdclrp-resource-plannable-events-tab-bar-container {
                        display: flex;
                        flex-wrap: wrap;
                        gap: 5px;
                        
                        .dbqdclrp-tab-bar-item {
                            @include tab-bar-item-rounded;
                        }
                    }
                }

                .dbqdclrp-resource-plannable-events,
                .dbqdclrp-resource-plannable-unfinished-events,
                .dbqdclrp-resource-plannable-cloneable-events {
                    height: $plannable-events-height;
                    flex-grow: 1;
                    padding: 0 $padding-default;
                    overflow-y: auto;
                    @include scrollbar;

                    .dbqdclrp-event { 
                        width: 100%;
                    }
                }

                .dbqdclrp-resource-plannable-events-loading-indicator {
                    position: absolute;
                    top: 0;
                    right: 0;
                    bottom: 0;
                    left: 0;
                }

                .dbqdclrp-inline-loading-indicator {
                    float: left;
                    margin-top: 10px;
                    @include loading-indicator-inline;
                }
            }

            .dbqdclrp-resource-planner-timeline-container {
                position: relative;
                flex-grow: 1;
                width: $resource-planner-container-width;
                
                .dbqdclrp-resource-planner-timeline-loading-indicator {
                    position: absolute;
                    top: 0;
                    right: 0;
                    bottom: 0;
                    left: 0;
                }
            
                .dbqdclrp-resource-planner-timeline {
                    .mbsc-timeline {

                        // Reduce width of the time columns
                        .mbsc-timeline-column,
                        .mbsc-timeline-header-column,
                        .mbsc-timeline-day {
                            width: 2.5em; 
                        }
                        
                        .mbsc-material.mbsc-calendar-title {
                            font-size: $font-size-h2;
                        }

                        .mbsc-schedule-event-title {
                            font-size: $font-size-small;
                        }

                        .mbsc-schedule-event-desc {
                            font-weight: 400;
                        }

                        .mbsc-material.mbsc-button {
                            font-size: $font-family-h2;
                            text-transform: none;
                        }

                        .mbsc-timeline-event-buffer {
                            opacity: 0.45;
                            background-image: repeating-linear-gradient(
                                45deg,
                                rgba(255, 255, 255, 0.08) 0,
                                rgba(255, 255, 255, 0.08) 6px,
                                transparent 6px,
                                transparent 12px
                            );
                        }

                        .mbsc-timeline-event-buffer-before {
                            border-right: 1px dashed rgba(255, 255, 255, 0.25);
                        }

                        .mbsc-timeline-event-buffer-after {
                            border-left: 1px dashed rgba(255, 255, 255, 0.25);
                        }

                        .dbqdclrp-travel-time-label {
                            display: flex;
                            align-items: center;
                            justify-content: center;
                            height: 100%;
                            font-size: 10px;
                            font-weight: 600;
                            color: $resource-planner-warning-color;
                            white-space: nowrap;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            padding: 0 2px;
                        }
            
                        // Set a fixed height for the timeline row. This will allow for the resource image + name and 2 rows of tags to be visible.
                        // If more rows with tags are added, they will simply be cut off due to overflow.
                        .mbsc-timeline-row {
                            height: $resource-planner-resource-height;

                            &.dbqdclrp-resource-disabled {
                                background: #7b797b;
                                color: #94a6a5;

                                .mbsc-schedule-invalid,
                                .mbsc-timeline-invalid {
                                    background: #7b797b;
                                    color: #94a6a5; 
                                }

                                .mbsc-timeline-grid-row {
                                    position: relative;

                                    &::after {
                                        content: "";
                                        position: absolute;
                                        inset: 0;
                                        pointer-events: none;
                                        background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.06) 0, rgba(255, 255, 255, 0.06) 8px, transparent 8px, transparent 16px);
                                    }
                                }
                            }
                        }

                        // Mobiscroll planner grid
                        .mbsc-timeline-grid-scroll,
                        .mbsc-schedule-grid-scroll {
                            @include scrollbar;
                        }

                        // When setting custom colors on an invalid date, the text would become invisible.
                        // This code is meant to solve that issue.
                        .mbsc-schedule-invalid {
                            background: none !important;
                            z-index: 1;
                            color: #000;
                        }
                    }

                    .dbqdclrp-resource {
                        display: flex;
                        flex-direction: column;

                        .dbqdclrp-resource-personal {
                            display: flex;
                            flex-direction: row;
                            align-items: center;
        
                            .dbqdclrp-resource-image {
                                display: flex;
                                align-items: center;
                                justify-content: center;
                                flex-shrink: 0;
                                background: $background-item-color-default;
                                border-radius: 50%;
                                width: 36px;
                                height: 36px;
                                overflow: hidden;
            
                                img {
                                    width: 100%;
                                    height: 100%;
                                    object-fit: cover;
                                    vertical-align: inherit;
                                }

                                svg {
                                    fill: $text-color-default;
                                }
                            }
            
                            .dbqdclrp-resource-name {
                                flex-grow: 1;
                                margin-left: 5px;
                                @include ellipsis(2);
                            }

                            .dbqdclrp-resource-tooltip {
                                svg {
                                    fill: $text-color-default;
                                }

                                &.dbqdclrp-resource-warning-tooltip {
                                    svg {
                                        fill: $text-color-warning;
                                    }
                                }
                            }
                        }
                    }
                        
                    .dbqdclrp-event { 
                        width: 100%;
                    }

                    // Customized day header styling in order to add the day to the header
                    .dbqdclrp-day-header {
                        font-size: 14px;
                        padding: 0 5px;

                        &.dbqdclrp-day-header-active {
                            position: relative;
                            background-color: $color-primary;
                            color: $color-white;
                            border-radius: 9px;
                        }
                    }
                }
            }

            &.dbqdclrp-plannable-events-is-collapsed {
                .dbqdclrp-resource-plannable-events-container {
                    display: none;
                }

                .dbqdclrp-resource-planner-timeline-container {
                    width: 100%;
                }
            }
        }
    }
}

// Tag styling (used for events and resources)
.dbqdclrp-event,
.dbqdclrp-resource {
    .dbqdclrp-event-tag {
        float: left;
        background: $kanban-tile-tag-background;
        color: color(text-color-default);
        padding: 2px 5px;
        font-size: $font-size-small;
        border-radius: 5px;
        margin: 0 5px 5px 0;
    }

    .dbqdclrp-event-tags {
        float: left;

        .dbqdclrp-event-tag {

            // 0 = Text
            &[data-display-mode="0"] {
                
            }
            // 1 = Image
            &[data-display-mode="1"],
            &.dbqdclrp-event-tag-extra {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 22px;
                height: 22px;
                border-radius: 50%;
                font-weight: 600;
                padding: 0;
                font-size: $font-size-small;
                overflow: hidden;
            }
        }
    }
    .dbqdclrp-event-tags.dbqdclrp-event-tags-top-left,
    .dbqdclrp-event-tags.dbqdclrp-event-tags-bottom-left {
        float: left;
        clear: both;
    }
    .dbqdclrp-event-tags.dbqdclrp-event-tags-top-right,
    .dbqdclrp-event-tags.dbqdclrp-event-tags-bottom-right {
        float: right;
    }

    .dbqdclrp-event-tags.dbqdclrp-event-tags-bottom-right {
        .dbqdclrp-event-tag {
            // 1 = Image
            &[data-display-mode="1"] {
                margin-left: -10px;

                &:first-of-type	{
                    margin-left: 0;
                }
            }

            &.dbqdclrp-event-tag-extra {
                margin-left: -10px;
                background: $kanban-tile-tag-extra-background;
                color: $text-color-default;
            }

            span {
                font-size: 10px;
            }
        }
    }
    .dbqdclrp-event-extra-tags-container {
        float: left;
        position: relative;

        .dbqdclrp-event-extra-tags {
            display: none;
            position: absolute;
            top: 22px;
            left: -11px;
            background: $kanban-tile-background;
            padding: 2px;
            border-radius: 11px;
            border: 1px solid $kanban-tile-tag-extra-background;
            box-shadow: inset 0 -1px 1px #0003, 0 1px 1px #00000014;

            .dbqdclrp-event-tag {
                float: initial;
                margin: 0 0 1px 0 !important;
            }
        }

        &:hover {
            .dbqdclkb-event-extra-tags {
                display: block;
            }   
        }
    }
}

// The event must be styled as a root style, since the Mobiscroll draggable events will be moved to the end of the <body>.
.dbqdclrp-event {
    float: left;
    cursor: pointer;
    background: $kanban-tile-background;
    border-radius: 5px;
    border-left: solid;
    border-width: 5px;
    border-color: #c0c0c0;
    padding: 10px;
    margin-top: 10px;
    box-shadow: inset 0 -1px 1px #0003, 0 1px 1px #00000014;
    &:first-of-type {
        margin: 0;
    }
    &:last-of-type {
        margin-bottom: 0px;
    }
    &:hover {
        // .dbqdclkb-dropdown-toggle {
        //     display: block;
        // }
    }
    // &.dbqdclkb-item-selected {
    //     // border: 2px solid;
    //     // border-left-width: 5px;
    //     box-shadow: 0px 0px 0px 2px inset;
    // }

    .dbqdclrp-event-name,
    .dbqdclrp-event-summary {
        float: left;
        width: 100%;
        overflow: hidden;
        span {
            color: $text-color-default;
            font-size: 13px;
            line-height: 20px;
        }
    }

    .dbqdclrp-event-name {
        span {
            font-weight: 600;
        }
    }

    .dbqdclrp-dropdown {
        .dropdown-toggle {
            display: none;
            border: 0;
            outline: 0;
            padding: 0;
            border-radius: 50%;
            width: 24px;
            height: 24px;
            position: absolute;
            top: 0;
            right: 0;
            background: $kanban-tile-background;

            svg {
                fill: $text-color-default;
            }

            &:hover {
                background: $color-white;
                color: $color-white;
                box-shadow: 0 0 5px $color-white;
                text-shadow: 0 0 5px $color-white;

                svg {
                    fill: $color-primary !important;
                    transform: scale(1.1);
                }
            }
        }
    }
    
    &:hover {
        .dbqdclrp-dropdown-toggle {
            display: block;
        }
    }
}

.dbqdclrp-resource-warnings {
    // .dbqdclrp-resource-warning-title {

    // }

    .dbqdclrp-resource-warning-list {
        padding-left: $padding-default;

        // .dbqdclrp-resource-warning-list-item {

        // }
    }
}

.dbqdclrp-event-name-prefix {
    display: inline-block;
    margin-right: 5px;
    font-weight: 800;

    &.dbqdclrp-event-name-prefix-error {
        color: $resource-planner-error-color;
    }
    
    &.dbqdclrp-event-name-prefix-warning {
        color: $resource-planner-warning-color;
    }
}

// The dropdown menu styling is purposefully added outside of the rest of the event styling, because this dropdown will be moved to and from the body element.
.dbqdclrp-dropdown-menu {
    li {
        cursor: pointer;
    }
    .dbqdclrp-disabled {
        opacity: 0.5;
        cursor: not-allowed;
        user-select: none;
    }
    .dbqdclrp-hidden {
        display: none;
    }
}

// The event must be styled as a root style, since the Mobiscroll draggable events will be moved to the end of the <body>.
.mbsc-schedule-event {

    // Make sure the inner event uses the full width, otherwise the event options might not be
    // displayed all the way at the end of the event if the outer event has a lot of width.
    .mbsc-schedule-event-inner {
        width: 100%;
    }

    .dbqdclrp-event-options {
        display: none;
        position: absolute;
        top: 3px;
        right: 6px;

        button {
            @include button-rounded-with-icon;
            background: $global-background-color-default;
            padding: 0;
            
            svg {
                fill: $text-color-default;
            }
        }
    }

    &:hover {
        .dbqdclrp-event-options {
            display: block;
        }
    }

    // Hide the time inside an event
    .mbsc-schedule-event-time,
    .mbsc-schedule-event-range {
        display: none !important;
    }
}