@import '../abstracts/variables';

.picker-datepicker-toolbar {
    align-items: flex-start;
    flex-direction: column;

    .button-year {
        font-size: 1rem;
        font-weight: 400;
        line-height: 1.75;
        letter-spacing: 0.00938em;
    }

    .button-date {
        font-size: 2.125rem;
        font-weight: 400;
        line-height: 1.17;
        letter-spacing: 0.00735em;
        text-transform: none;
    }
}

.picker-datepicker-toolbar-landscape {
    padding: 16px;
}

.picker-datepicker-date-landscape {
    margin-right: 16px;
    margin-inline-end: 16px;
    margin-inline-start: unset;
}


.picker-calendar-header-switch {
    display: flex;
    margin-top: 4px;
    align-items: center;
    margin-bottom: 8px;
    justify-content: space-between;

    & > .icon-button {
        z-index: 1;
        padding: 8px;
        margin: 6px;
        background-color: var(--palette-surface);

        &:hover {
            background-color: var(--palette-action-default-hover);
        }
    }

    & .picker-calendar-header-transition {
        width: 100%;
        height: 23px;
        overflow: hidden;

        &:hover {
            & .typography {
                cursor: pointer;
                font-weight: 500;
            }
        }
    }
}


.picker-calendar-header-day {
    display: flex;
    max-height: 16px;
    align-items: center;
    justify-content: center;

    .day-label {
        color: var(--palette-text-secondary);
        width: 36px;
        margin: 0 2px;
        text-align: center;
    }
}

.picker-year-container {
    height: 300px;
    overflow-y: auto;

    .picker-year {
        cursor: pointer;
        height: 40px;
        display: flex;
        outline: none;
        align-items: center;
        justify-content: center;
        user-select: none;
        animation: animation-fadein 500ms;
        transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;

        &:hover {
            background-color: var(--palette-action-default-hover);
        }

        & .picker-year-selected {
            margin: 10px 0;
            font-weight: 500;
        }
    }
}

.picker-month-container {
    width: 310px;
    display: flex;
    flex-wrap: wrap;
    align-content: stretch;

    .picker-month {
        flex: 1 0 33.33%;
        cursor: pointer;
        height: 60px;
        display: flex;
        outline: none;
        transition: font-size 100ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
        align-items: center;
        justify-content: center;
        transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;

        &:hover {
            background-color: var(--palette-action-default-hover);
        }

        & .picker-month-selected {
            font-weight: 500;
        }

        &.disabled {
            color: var(--palette-text-disabled);
            pointer-events: none;
        }
    }
}


.picker-slide-transition {
    display: block;
    position: relative;
}

.picker-slide-transition > * {
    top: 0;
    left: 0;
    right: 0;
    position: absolute;
}

.picker-calendar-transition {
    margin-top: 12px;
    min-height: 216px;
}

.picker-calendar-progress-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.picker-calendar-content {
    display: grid;
    --selected-day: 0;
    grid-column-gap: 10px;
    grid-template-columns: auto;
}

@media(min-width: $breakpoint-sm) {
    .picker-calendar-content:not(.picker-calendar-content-1) {
        grid-template-columns: repeat(2, minmax(auto, 1fr));

        .picker-calendar-header-1,
        .picker-calendar-header-3,
        .picker-calendar-header-5,
        .picker-calendar-header-7,
        .picker-calendar-header-9,
        .picker-calendar-header-11 {
            .picker-nav-button-next {
                visibility: hidden;
            }

            .picker-nav-button-prev {
                visibility: visible;
            }
        }

        .picker-calendar-header-2,
        .picker-calendar-header-4,
        .picker-calendar-header-6,
        .picker-calendar-header-8,
        .picker-calendar-header-10,
        .picker-calendar-header-12 {
            .picker-nav-button-next {
                visibility: visible;
            }

            .picker-nav-button-prev {
                visibility: hidden;
            }
        }
    }
}

@media(min-width: $breakpoint-md) {
    .picker-calendar-content:not(.picker-calendar-content-1):not(.picker-calendar-content-2) {
        grid-template-columns: repeat(3, minmax(auto, 1fr));

        .picker-calendar-header-1,
        .picker-calendar-header-4,
        .picker-calendar-header-7,
        .picker-calendar-header-10 {
            .picker-nav-button-next {
                visibility: hidden;
            }

            .picker-nav-button-prev {
                visibility: visible;
            }
        }

        .picker-calendar-header-2,
        .picker-calendar-header-5,
        .picker-calendar-header-8,
        .picker-calendar-header-11 {
            .picker-nav-button-next, .picker-nav-button-prev {
                visibility: hidden;
            }
        }

        .picker-calendar-header-3,
        .picker-calendar-header-6,
        .picker-calendar-header-9,
        .picker-calendar-header-12 {
            .picker-nav-button-next {
                visibility: visible;
            }

            .picker-nav-button-prev {
                visibility: hidden;
            }
        }
    }
}

:not(.picker-hidden) {
    .picker-calendar-header-last {
        .picker-nav-button-next {
            visibility: inherit !important;
        }
    }
}

.picker-hidden {
    .picker-nav-button-next, .picker-nav-button-prev {
        visibility: hidden !important;
    }
}

.picker-calendar-container {
    display: flex;
    width: 310px;
    flex-direction: column;
}

.picker-calendar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;

    .day {
        color: var(--palette-text-primary);
        width: 36px;
        height: 36px;
        margin: 0 2px;
        padding: 0;
        font-size: 0.75rem;
        font-weight: 500;

        &:hover {
            background-color: var(--palette-action-default-hover);
        }

        &.hidden {
            opacity: 0;
            pointer-events: none;
        }

        &.current {
            font-weight: 600;
        }

        &.selected {
            font-weight: 500;
        }

        .typography {
            margin-top: 2px;
        }

        &.disabled {
            color: var(--palette-text-disabled);
            pointer-events: none;
        }

        &.range {
            margin: 0;
            width: 40px;
            transition: none;

            &.range-start-selected {
                border-radius: 50% 0% 0% 50%;
            }

            &.range-end-selected {
                border-radius: 0% 50% 50% 0%;
            }

            &.range-between {
                border-radius: 0;
                background-color: var(--palette-action-default-hover);
            }

            &.range-selection:hover {
                &.range-start-selected {
                    border-radius: 50%;
                }

                &:not(.range-start-selected) {
                    border-radius: 0% 50% 50% 0%;
                }
            }

            &.range-selection:not(:hover):not(.range-start-selected) {
                border-radius: 0;
                background: linear-gradient(var(--palette-action-default-hover) 100%, var(--palette-action-default-hover) 100%, transparent 0%);
                background-size: 100% calc(100% * (var(--selected-day) - var(--day-id)));
            }
        }
    }
}

@each $color in $palette-colors {
    .range-selection-#{$color} {
        &:hover {
            color: var(--palette-#{$color}-text) !important;
            background-color: var(--palette-#{$color}) !important;
        }
    }
}

.picker-calendar-week {
    display: flex;
    margin: 0 5px;
    justify-content: center;
    align-items: center;

    .picker-calendar-week-text {
        width: 15px;
        margin-top: 2px !important;
        color: var(--palette-text-disabled);
    }
}

.application-layout-rtl {
    .picker-calendar .day.range {
        &.range-start-selected {
            border-radius: 0% 50% 50% 0%;
        }

        &.range-end-selected {
            border-radius: 50% 0% 0% 50%;
        }

        &.range-selection:hover {
            &:not(.range-start-selected) {
                border-radius: 50% 0% 0% 50%;
            }
        }
    }
}