/* ======================================================
   <!-- Event Calendar -->
/* ====================================================== */

// Disabled item
// ---------------------------
//
@mixin disabled-item() {
    // @include disabled-item(); 
    opacity: .4;
    pointer-events: none;
}

.custom-event-cal__wrapper {
    --custom-event-cal-wrapper-min-width: 400px;
    --custom-event-cal-body-bg: #fff;
    --custom-event-cal-border-color: #ddd;
    --custom-event-cal-border-color-hover: #333;
    --custom-event-cal-header-fs: 1.125rem;
    --custom-event-cal-default-border-color: #eee;
    --custom-event-cal-day-border-color: #ddd;
    --custom-event-cal-day-hover-bg: #f6f6f6;
    --custom-event-cal-dayselected-bg: #0b5ed7;
    --custom-event-cal-dayselected-text-color: #fff;
    --custom-event-cal-year-month-btn-border-color: #ddd;
    --custom-event-cal-year-month-btn-hover-bg: rgba(0, 58, 166, .1);
    --custom-event-cal-year-month-btn-selected-bg: rgba(0, 58, 166, 1);
    --custom-event-cal-year-month-btn-selected-color: #fff;
    --custom-event-cal-month-wrapper-w: 18.75rem;
    --custom-event-cal-year-wrapper-w: 18.75rem;
    --custom-event-cal-header-arrow-bg: #000;
    --custom-event-cal-header-text-color: #000;
    --custom-event-cal-header-prevnext-btn-bg: transparent;
    --custom-event-cal-header-prevnext-btn-color: #000;
    --custom-event-cal-header-prevnext-btn-radius: 0.25rem;
    --custom-event-cal-table-add-btn-color: #0b5ed7;
    --custom-event-cal-delete-btn-color: #ee4949;
    --custom-event-cal-footer-today-btn-bg: rgba(0, 58, 166, 1);
    --custom-event-cal-footer-today-btn-color: #fff;
    --custom-event-cal-event-default-bg: rgb(255, 240, 227);
    --custom-event-cal-table-event-font-size: 0.75rem;


    position: relative;
    min-width: var(--custom-event-cal-wrapper-min-width);
    border: 1px solid var(--custom-event-cal-border-color);


    /* Required when using onKeyDown */
    &[tabindex]:focus-visible {
        outline: none;
    }

    /* --HEADER --*/
    .custom-event-cal__header {
        font-size: var(--custom-event-cal-header-fs);
        font-weight: bold;
        padding: 10px 10px 5px 10px;
        display: flex;
        justify-content: space-between;

        .custom-event-cal__header__btns {
            .custom-event-cal__btn {
                margin-right: 1rem;
                color: var(--custom-event-cal-header-text-color);

                svg {
                    margin-left: .3rem;

                    path {
                        fill: var(--custom-event-cal-header-arrow-bg);
                    }
                }

                &.active {
                    svg {
                        transform: rotate(180deg);
                    }
                }

            }
        }

    }


    /*-- BODY --*/
    .custom-event-cal__body {
        background: var(--custom-event-cal-body-bg);
        width: 100%;
        display: flex;
        flex-wrap: wrap;
    }

    /*-- CELL --*/
    .custom-event-cal__row {
        display: flex;
        width: 100%;

        .custom-event-cal__cell {
            flex: 1;
            position: relative;
            height: auto;
            min-height: 4.75em;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            text-align: center;
            border-width: 0;
            border-color: var(--custom-event-cal-default-border-color);
            border-style: solid;
            border-top-width: 1px;
            border-right-width: 1px;

            &.disabled {
                @include disabled-item();
            }

            &.last-cell {
                border-right-width: 0;
            }

            &.last-row {
                border-bottom-width: 1px;
            }

            &.custom-event-cal__day--week {
                min-height: 2.75em;
                align-items: end;
                padding-inline-end: .75rem;
            }

            &:not(.empty):hover {
                background-color: var(--custom-event-cal-day-hover-bg);
            }

            .custom-event-cal__day__event {
                margin-bottom: 1px;
                font-size: var(--custom-event-cal-table-event-font-size);
                background-color: var(--custom-event-cal-event-default-bg);
                text-align: left;
                
                &:hover {
                    cursor: pointer;
                    opacity: .8;
                }
            }

            .custom-event-cal__cell-item.first {
                margin-top: 2.5rem;
            }
            

            /* Delete button */
            .custom-event-cal__day__eventdel {
                position: absolute;
                z-index: 1;
                right: -5px;
                top: 0;
                display: none;
                color: var(--custom-event-cal-delete-btn-color);

                svg {
                    width: 10px;
                    fill: var(--custom-event-cal-delete-btn-color);

                    path {
                        fill: var(--custom-event-cal-delete-btn-color);
                    }
                }

                &:hover {
                    svg {
                        transform: scale(1.2);
                    }
                }
            }

            &:not(.empty) .custom-event-cal__cell-item:hover {
                .custom-event-cal__day__eventdel {
                    display: block;
                }

            }


            /* Add button */
            .custom-event-cal__day__eventadd {
                position: absolute;
                z-index: 1;
                left: 0;
                bottom: -8.5px;
                display: none;
                width: 20px;
                color: var(--custom-event-cal-table-add-btn-color);
                text-align: left;
                pointer-events: none;

                > a {
                    pointer-events: auto;
                }

                svg {
                    width: 15px;
                    fill: var(--custom-event-cal-table-add-btn-color);

                    path {
                        fill: var(--custom-event-cal-table-add-btn-color);
                    }
                }

                &:hover {
                    svg {
                        transform: scale(1.2);
                    }
                }
            }

            &:hover {
                .custom-event-cal__day__eventadd {
                    display: block;
                }

            }




            /* DAY NUMBER */
            > span {
                position: absolute;
                right: .25rem;
                top: .25rem;
                display: inline-block;
                padding: .1rem;
                border-radius: 50%;
                width: 1.7rem;
                height: 1.7rem;
                line-height: 1.5;
                margin: .5rem 0;

                &.disabled {
                    opacity: .2;
                }
            }

            
            /* ITEMS */
            > div {
                position: relative;
                width: 100%;
            }
            
            &.empty > div {
                opacity: .2;
            }


            &:not(.empty) {
                cursor: pointer;
            }

            &.today {}

            &.selected {
                >span {
                    color: var(--custom-event-cal-dayselected-text-color);
                    background-color: var(--custom-event-cal-dayselected-bg);
                }
            }

        }


    }


    /*-- SELECTION --*/
    .custom-event-cal__month-wrapper {
        position: absolute;
        width: var(--custom-event-cal-month-wrapper-w);
        height: auto;
        z-index: 1;
        top: calc(1rem + 22px);
        left: 50%;
        transform: translateX(-50%);
        display: none;

        &.active {
            display: block;
        }


        .custom-event-cal__month-container {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            grid-template-rows: repeat(4, 2.5em);
            grid-gap: 10px;
        }


    }


    .custom-event-cal__year-wrapper {
        position: absolute;
        width: var(--custom-event-cal-year-wrapper-w);
        height: auto;
        z-index: 1;
        top: calc(1rem + 22px);
        left: 50%;
        transform: translateX(-50%);
        display: none;

        &.active {
            display: block;
        }

        .custom-event-cal__year-container {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            grid-template-rows: repeat(5, 2.5em);
            grid-gap: 5px;
        }
    }


    .custom-event-cal__year,
    .custom-event-cal__month {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 5px;
        font-size: 0.875em;
        border: 1px solid var(--custom-event-cal-year-month-btn-border-color);
        border-radius: 0.25rem;
        cursor: pointer;

        &:hover {
            background-color: var(--custom-event-cal-year-month-btn-hover-bg);
        }

        &.selected {
            background-color: var(--custom-event-cal-year-month-btn-selected-bg);
            color: var(--custom-event-cal-year-month-btn-selected-color);
        }

        &.disabled {
            @include disabled-item();
        }

    }




    /* --BUTTON --*/
    .custom-event-cal__btn {
        border: none;
        outline: none;
        background: none;
        padding: 0;
        margin: 0;
        box-shadow: none;
        cursor: pointer;

        /* required */
        display: inline-flex;
        align-items: center;

        svg {
            path {
                fill: var(--custom-event-cal-header-arrow-bg);
            }
        }

        &.disabled {
            @include disabled-item();
        }

        &--prev,
        &--next {
            border-radius: var(--custom-event-cal-header-prevnext-btn-radius);
            color: var(--custom-event-cal-header-prevnext-btn-color);
            background-color: var(--custom-event-cal-header-prevnext-btn-bg);

            svg {
                path {
                    fill: var(--custom-event-cal-header-prevnext-btn-color);
                }
            }

        }

        &--today {
            border: 1px solid var(--custom-event-cal-border-color);
            border-radius: 0.25rem;
            font-size: 0.875em;
            padding: .2rem 1rem;
            color: var(--custom-event-cal-footer-today-btn-color);
            background-color: var(--custom-event-cal-footer-today-btn-bg);
        }
    }


}