/**=====================
    Calendar scss
==========================**/
.flatpickr-day {

    &.selected,
    &.startRange,
    &.endRange,
    &.selected.inRange,
    &.startRange.inRange,
    &.endRange.inRange,
    &.selected:focus,
    &.startRange:focus,
    &.endRange:focus,
    &.selected:hover,
    &.startRange:hover,
    &.endRange:hover,
    &.selected.prevMonthDay,
    &.startRange.prevMonthDay,
    &.endRange.prevMonthDay,
    &.selected.nextMonthDay,
    &.startRange.nextMonthDay,
    &.endRange.nextMonthDay {
        background: transparent;
        border-color: var(--theme-color);
        color: var(--theme-color);
    }
}

.flatpickr-day {

    &.selected,
    &.startRange,
    &.endRange {
        &.startRange {
            +.endRange {
                &:not(:nth-child(7n+1)) {
                    box-shadow: none;
                    border-color: var(--theme-color);
                    color: var(--theme-color);
                    background-color: transparent;
                }
            }
        }
    }
}

.rangeMode {
    .flatpickr-day {
        margin: 0;
    }
}

.flatpickr-day {

    &.selected,
    &.startRange,
    &.endRange {

        &.endRange,
        &.startRange {
            border-radius: 4px;
        }
    }
}

.flatpickr-calendar {
    z-index: 3;
    width: 324.875px;
    padding: 16px;

    body.dark & {
        background: #252934;
        box-shadow: 1px 0 0 #454851, -1px 0 0 #454851, 0 1px 0 #454851, 0 -1px 0 #454851, 0 3px 13px rgba(0, 0, 0, 0.08);
    }

    &.open {
        z-index: 10;
    }

    &:before,
    &:after {
        display: none;
    }

    .flatpickr-innerContainer {
        font-size: 14px;
        border-radius: 8px;
        @include flex_common;
        overflow: visible;
    }

    .flatpickr-weekdays {
        padding: 0;

        .flatpickr-weekdaycontainer {
            display: grid;
            grid-template-columns: repeat(7, 1fr);

            .flatpickr-weekday {
                color: var(--theme-color);
                font-size: 16px;
                @include flex_common;

                @media (max-width: 480px) {
                    font-size: 13px;
                }
            }
        }
    }

    .flatpickr-day {
        @include pseudowh($width: 37px, $height: 35px);
        line-height: 1.3;
        color: $title-color;
        background-color: $section-bg;
        max-width: unset;
        font-size: 16px;
        border-radius: 4px;
        @include flex_common;
        border-color: $border-color;

        @media (max-width: 480px) {
            font-size: 13px;
            max-width: 33px;
            height: 32px;
            line-height: 32px;
        }

        body.dark & {
            background-color: #171b27;
            color: rgba($white, 0.8);
            border-color: #454851;
        }

        &:hover {
            background-color: rgba($primary-color, 0.10);
            color: var(--theme-color);
            font-weight: 600;

            body.dark & {
                background-color: rgba($primary-color, 0.10);
                color: var(--theme-color);
                border-color: transparent;
            }
        }

        &.today {
            background-color: var(--theme-color);
            color: $white;
            border: none;

            body.dark & {
                background-color: var(--theme-color);
                color: $white;
            }
        }

        &.selected {
            color: $white;
            border-color: var(--theme-color);
            background-color: var(--theme-color);

            body.dark & {
                color: $white;
                border-color: var(--theme-color);
                background-color: var(--theme-color);
            }
        }

        &.prevMonthDay,
        &.flatpickr-disabled,
        &.flatpickr-disabled:hover,
        &.notAllowed,
        &.notAllowed.prevMonthDay,
        &.notAllowed.nextMonthDay {
            color: $light-color;
            user-select: none;
            position: relative;
            z-index: 0;
            overflow: hidden;

            body.dark & {
                color: $light-color;
                border-color: rgba(69, 72, 81, 0.8);
            }

            &:hover {
                background-color: $section-bg;
                font-weight: 400;

                body.dark & {
                    background-color: #171b27;
                    border-color: rgba(69, 72, 81, 0.8);
                    color: $light-color;
                }
            }

            &::before {
                @include pos;
                @include pseudowh($width: 100%, $height: 1px);
                top: 50%;
                left: 50%;
                border-top: 1px solid rgba($danger-color, 0.15);
                transform: translate(-50%, -50%) rotate(225deg) scale(1.5);
            }
        }

        &.inRange {
            background-color: $white;
            box-shadow: none;
            position: relative;
            z-index: 0;
            overflow: hidden;

            &::before {
                @include pos;
                top: 0;
                left: 0;
                @include pseudowh;
                background-color: var(--theme-color);
                opacity: 0.3;
                z-index: -1;
            }

            &.today {
                background-color: var(--theme-color);
            }
        }
    }

    .dayContainer {
        width: unset;
        min-width: unset;
        max-width: unset;
        gap: 8px;
        padding: 0;
        grid-template-columns: repeat(7, 1fr);
        display: grid;

        @media (max-width: 480px) {
            padding: 0;
        }
    }

    .flatpickr-months {
        margin-bottom: 16px;

        .flatpickr-month {
            color: $title-color;
        }

        .flatpickr-current-month {
            padding: 0;
            gap: 10px;
            @include flex_common;

            input {
                &.cur-year {
                    font-size: 16px;

                    @media (max-width: 480px) {
                        font-size: 14px;
                    }
                }
            }
        }

        .flatpickr-prev-month,
        .flatpickr-next-month {
            background-color: $section-bg;
            border-radius: 100%;
            padding: 8px;
            @include pseudowh($width: 30px, $height: 30px);
            top: 18px;
            @include flex_common;

            body.dark & {
                background-color: #171b27;
                border-color: rgba(69, 72, 81, 0.8);
                color: $light-color;
                fill: rgba(255, 255, 255, 0.9);
            }

            &:hover {
                svg {
                    fill: $title-color;

                    body.dark & {
                        fill: #fff;
                    }
                }
            }

            svg {
                @include pseudowh($width: 12px, $height: 12px);
            }
        }

        .flatpickr-prev-month {
            left: 16px !important;

            [dir="rtl"] & {
                left: unset;
                right: 16px !important;
            }
        }

        .flatpickr-next-month {
            right: 16px !important;

            [dir="rtl"] & {
                right: unset;
                left: 16px !important;
            }

        }

        .flatpickr-monthDropdown-months {
            background-color: $section-bg;
            border-radius: 6px;
            font-size: calc(14px + (16 - 14) * ((100vw - 320px) / (1920 - 320)));
            padding: 9px 12px;
            appearance: unset;

            body.dark & {
                background-color: #171b27;
                color: $white;
            }
        }

        .numInputWrapper {
            background-color: $section-bg;
            border-radius: 6px;
            font-size: 14px;
            padding: 6px 12px;
            width: 80px;

            body.dark & {
                background-color: #171b27;
                color: $white;
            }
        }
    }

    .numInputWrapper {
        &:hover {
            span {
                border: none;
            }
        }

        span {
            &:hover {
                background-color: unset;
                border: none;
            }

            &.arrowUp {
                &:after {
                    top: 55%;
                }
            }

            &.arrowDown {
                &:after {
                    top: 20%;
                }
            }
        }
    }

    &.hasTime {
        .flatpickr-time {
            border: none;
            line-height: unset;
            height: 70px !important;
            max-height: 70px !important;
            gap: 10px;

            &:after {
                display: none;
            }

            .numInputWrapper {
                height: 100%;
                position: relative;
                border-radius: 12px;
                z-index: 0;
                width: 30%;
                overflow: hidden;
                background-color: transparent;

                &::before {
                    @include pos;
                    top: 0;
                    left: 0;
                    @include pseudowh;
                    background-color: var(--theme-color);
                    opacity: .1;
                    z-index: -1;
                }

                &:after {
                    @include pos;
                    top: 0;
                    border-radius: 12px;
                    left: 0;
                    @include pseudowh;
                    border: 1px solid var(--theme-color);
                    opacity: .8;
                    z-index: -1;
                }

                input {

                    &:hover,
                    &:focus {
                        background: transparent;

                    }
                }

                span {
                    right: 16px;

                    [dir="rtl"] & {
                        right: unset;
                        left: 16px;
                    }

                    &.arrowUp {
                        &:after {
                            border-bottom-color: var(--theme-color);
                            border-width: 5px;
                            top: unset;
                            bottom: 13%;
                        }
                    }

                    &.arrowDown {
                        &:after {
                            border-top-color: var(--theme-color);
                            border-width: 5px;
                            top: 13%;
                        }
                    }
                }
            }

            input {
                text-align: left;
                padding-left: 20px;
                font-size: 18px;
                color: var(--theme-color);
                font-weight: 500;

                [dir="rtl"] & {
                    text-align: right;
                    padding-right: 20px;
                    padding-left: unset;
                }
            }

            .flatpickr-time-separator {
                width: 2%;
                color: var(--theme-color);
                font-size: 24px;
                @include flex_common;
            }

            .flatpickr-am-pm {
                height: 100%;
                position: relative;
                z-index: 0;
                width: 29%;
                font-size: 18px;
                background-color: transparent;
                overflow: hidden;
                color: var(--theme-color);
                @include flex_common;
                border-radius: 12px;

                &::before {
                    @include pos;
                    top: 0;
                    left: 0;
                    @include pseudowh;
                    background-color: var(--theme-color);
                    opacity: .1;
                    z-index: -1;
                }

                &:after {
                    @include pos;
                    top: 0;
                    border-radius: 12px;
                    left: 0;
                    @include pseudowh;
                    border: 1px solid var(--theme-color);
                    opacity: .8;
                    z-index: -1;
                }
            }
        }

    }
}

.main-inline-calender {
    &.input-group {
        flex-direction: column;

        .form-control {
            width: 100%;
            border-radius: 6px !important;
            color: var(--theme-color);
            padding: 0;
            font-size: 18px;
            font-weight: 500;
            line-height: 23px;

            &:focus {
                border: none;
            }

            &:focus,
            &:disabled {
                box-shadow: unset;
                border: none;
                background-color: unset;
            }
        }

        .form-control[readonly] {
            box-shadow: unset;
            border: none;
            background-color: unset;
        }

        .flatpickr-calendar {
            &.inline {
                width: 100%;
                border-radius: 6px !important;

                @media (max-width: 575.98px) {
                    max-width: 410px;
                    min-width: 400px;
                    @include center(horizontal);
                }

                @media (max-width: 480px) {
                    min-width: 310px;
                    max-width: min-content;
                }

                @media (max-width: 360px) {
                    min-width: 270px;
                    max-width: min-content;
                }
            }
        }

        .flatpickr-innerContainer {
            display: block;
        }

        .flatpickr-rContainer {
            display: block;

            .flatpickr-weekdays {
                width: 100%;
            }

            .flatpickr-days {
                width: 100%;

                .dayContainer {
                    width: 100%;
                    max-width: none;
                    min-width: unset;
                    gap: 5px;

                    @media (max-width: 575.98px) {
                        gap: 14px;
                    }

                    @media (max-width: 480px) {
                        gap: 3px;
                        padding: 4px;
                    }

                    @media (max-width: 360px) {
                        gap: 0;
                    }


                    .flatpickr-day {
                        border-radius: 4px;
                        width: 100%;
                        color: $title-color;
                        border-color: transparent;

                        &.prevMonthDay {
                            user-select: none;
                            cursor: default;
                            opacity: 0.6;

                            &:hover {
                                color: $title-color;
                                border-color: transparent;
                            }
                        }

                        &.nextMonthDay {
                            &:hover {
                                background-color: rgba(254, 120, 46, 0.1);
                            }

                            &::before {
                                content: none;
                            }
                        }

                        &:hover {
                            color: var(--theme-color);
                        }

                        &.selected,
                        &.today {
                            color: $white;
                        }
                    }
                }
            }
        }
    }
}

.inline-time-picker {
    @media (max-width: 575.98px) {
        max-width: 410px;
        min-width: 400px;
        margin-inline: auto;
    }

    @media (max-width: 480px) {
        min-width: 310px;
        max-width: min-content;
    }

    @media (max-width: 360px) {
        min-width: 270px;
        max-width: min-content;
    }
}

.inline-picker-btn {
    @media (max-width: 575.98px) {
        max-width: 410px;
        min-width: 400px;
        margin-inline: auto;
    }

    @media (max-width: 480px) {
        min-width: 310px;
        max-width: min-content;
    }

    @media (max-width: 360px) {
        min-width: 270px;
        max-width: min-content;
    }
}