@import (once) "../../include/vars";
@import (once) "../../include/mixins";

.calendar {
    display: block;
    position: relative;
    width: 280px;
    border: 1px solid @borderColor;
    overflow: hidden;
    user-select: none;
    background-color: @white;
}

.calendar-header, .calendar-content, .calendar-footer {
    position: relative;
    display: block;
    background-color: @white;
    color: @dark;
}

.calendar-header {
    padding: 1rem;
    background-color: @brandColor2;
    color: @white;
    user-select: none;

    .header-year {
        font-size: .75rem;
        line-height: 1;
    }
    .header-day {
        font-size: 1.325rem;
    }
}

.calendar-content {
    padding: 1px;
    width: 278px;

    .calendar-toolbar, .days-wrapper {
        display: flex;
        position: relative;
    }

    .calendar-toolbar {
        flex-flow: row nowrap;
        justify-content: space-between;
        align-items: center;
        padding: .5rem 0;
        width: 100%;

        .prev-month, .prev-year, .next-month, .next-year, .next-year-group, .prev-year-group {
            padding: .5rem 0;
            cursor: pointer;
            text-align: center;
            width: 30px;
            display: block;
            position: relative;
            flex-shrink: 0;
        }

        .curr-month, .curr-year {
            padding: .5rem 0;
            width: 100%;
            text-align: center;
            cursor: pointer;
            font-size: 14px;
        }
    }

    .week-days, .days {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        grid-gap: 0;
    }

    &.-week-numbers {
        .week-days, .days {
            grid-template-columns: repeat(8, 1fr);
        }
    }

    .week-day, .week-number, .day {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .week-day, .week-number {
        font-weight: 700;
        background-color: @light;
    }

    .week-day {
        border-bottom: 1px solid @borderColor;
    }

    .week-number {
        border-right: 1px solid @borderColor;
    }

    .week-days .week-number {
        border-right: none;
    }

    .day, .week-day, .week-number {
        height: 39px;
        cursor: pointer;
        font-size: 14px;
        position: relative;
        user-select: none;
        margin: 0;
    }

    .day {
        &.selected {
            box-shadow: inset 0 0 0 1px rgba(red(@lightCyan), green(@lightCyan), blue(@lightCyan), 1)!important;

            &::after {
                border-top: 20px solid @lightCyan;
                border-left: 20px solid transparent;
                right: 0;
                top: 0;
            }

            &::before {
                right: 1px!important;
                top: 1px!important;
            }
        }

        &.showed {
            font-weight: bold;
        }
    }

    .outside {
        color: @gray;
        font-size: 12px;
    }

    .today {
        background-color: rgba(red(@green), green(@green), blue(@green), .5);
        color: @white;
        font-weight: bold;
    }

    .coincidental {
        box-shadow: inset 0 0 12px rgba(red(@gray), green(@gray), blue(@gray), .4);
    }

    .excluded {
        background-color: @light;
    }

    .day {
        border: 1px solid @transparent;

        &:hover {
            border-color: @borderColor;
        }
    }
}

.calendar-footer {
    padding: .5rem;
    border-top: 1px solid @borderColor;
    display: flex;
    flex-flow: row nowrap;
    justify-content: center;
    align-items: center;

    & > * {
        margin: 0 2px;
        font-size: .75rem;
        height: 32px;
        line-height: 32px;
        padding: 0 8px;
    }
}

.calendar {
    &.compact {
        width: 220px;

        .calendar-content {
            width: 100%;
        }

        .calendar-header {
            padding: .5rem;
            line-height: 1.2;
            .header-year {
                font-size: .65rem;
            }
            .header-day {
                font-size: 1rem;
            }
        }
        .calendar-toolbar {
            & > * {
                padding: 0!important;
                font-size: 14px;
            }
        }
        .calendar-footer {
            .button {
                height: 24px;
                line-height: 24px;
                padding: 0 .25rem;
            }
        }
        .day, .week-number {
            height: 30px;
            line-height: 30px;
            width: 30px;
            margin: 0;
            font-size: 12px;
        }
    }
}

.calendar {
    .calendar-time {
        display: block;
        padding: 5px 10px 10px;
        border-top: 1px solid @borderColor;
        background: @light;

        .calendar-time__inner {
            display: flex;
            flex-flow: row nowrap;
            align-items: center;
            justify-content: space-between;
        }

        .calendar-time__inner {
            .button {
                &.spinner-button-minus {
                    border-left: 1px solid @borderColor;
                    border-right: 1px solid @borderColor;
                }
            }

            input {
                text-align: center;
            }

            .minutes {
                margin-left: 2px
            }
        }

        .calendar-time__inner-row {
            display: flex;
            flex-flow: row nowrap;
            justify-content: space-between;
            width: 100%;
        }

        .calendar-time__inner-cell {
            display: block;
            width: 50%;
        }
    }

    &.compact {
        .calendar-time__inner-cell {
            display: block;
            width: 50%;

            span {
                font-size: 12px;
            }
        }
    }
}

.calendar {
    .calendar-content {
        .months,
        .years
        {
            display: flex;
            flex-flow: row wrap;
        }

        .months,
        .years
        {
            .month, .year {
                display: flex;
                align-items: center;
                justify-content: center;
                flex-shrink: 0;
                flex-basis: 33.33%;
                height: 68px;
                font-size: 14px;
                cursor: pointer;

                &:hover {
                    border-color: @borderColor;
                }
            }
        }

        .months, .years {
            padding: 1px;
        }

        .calendar-toolbar {
            border-bottom: 1px solid @borderColor;
        }
    }

    &.compact {
        .months, .years {
            .month, .year {
                height: 52px;
            }
        }
    }
}

.wide-calendar(){
    flex-flow: row nowrap;
    width: 560px;
    .clear();

    &.calendar-picker {
        width: 460px;
    }

    .calendar-header, .calendar-footer {
        position: absolute;
        top: 0;
        height: 100%;
        min-height: 100%;
    }

    .calendar-header {
        left: 0;
    }

    .calendar-footer {
        right: 0;
    }

    .calendar-header {
        width: 180px;
    }

    .calendar-footer {
        flex-flow: column nowrap;
        justify-content: flex-start;
        align-items: stretch;
        border-top: none;
        border-left: 1px solid @borderColor;
        width: 100px;

        * > {
            width: 100%;
            margin: 2px 0;
        }
    }

    .calendar-content {
        margin: 0 96px 0 180px;
    }

    &.compact {
        width: 454px!important;

        &.calendar-picker {
            width: 354px!important;
        }

        .calendar-header {
            width: 120px;
        }
        .calendar-content {
            margin: 0 96px 0 120px;
            width: 234px;
        }
    }
}

.calendar-wide {
    .wide-calendar();
}

.calendar {
    .day, .month, .year {
        transform: scale(1);
        transition: @transition-transform;
    }

    .to-animate {
        transform: scale(0);
    }
}

.calendar {
    .days .day, .months .month, .years .year {
        border: 1px solid @light;
    }
}

.calendar {
    .events {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        display: flex;
        flex-flow: row wrap;
        height: auto;

        .event {
            width: 4px;
            height: 4px;
            background-color: red;
            margin: 1px;
        }
    }
}