/**
 * Copyright (c) Enalean, 2016-Present. All Rights Reserved.
 *
 * This file is a part of Tuleap.
 *
 * Tuleap is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */

$flatpickr-day-hover: #f3f3f3;
$flatpickr-day-dimmed: #d0d0d0;
$flatpickr-animation: 100ms ease-in-out show-flat-pickr;
$datepicker-arrow-size: 10px;

@keyframes show-flat-pickr {
    0% {
        transform: translateY(-10px);
        opacity: 0;
        box-shadow: 0 0 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
        box-shadow: var(--tlp-flyover-shadow);
    }
}

.flatpickr-calendar {
    animation: $flatpickr-animation;
    border: 0;
    border-radius: var(--tlp-large-radius);
    box-shadow: var(--tlp-flyover-shadow);
    font-family: var(--tlp-font-family);

    &::before {
        display: none;
    }

    &::after {
        margin: 0 #{-$datepicker-arrow-size};
        border-width: $datepicker-arrow-size;
    }

    // stylelint-disable-next-line selector-class-pattern
    &.arrowTop::after {
        border-bottom-color: var(--tlp-main-color);
    }
}

.flatpickr-months {
    align-items: center;
    justify-content: space-around;
    border-radius: var(--tlp-large-radius) var(--tlp-large-radius) 0 0;
    background: var(--tlp-main-color);
    color: var(--tlp-white-color);

    .flatpickr-prev-month,
    .flatpickr-next-month {
        display: flex;
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        align-items: center;
        justify-content: center;
        width: 25px;
        height: 25px;
        float: none;
        border-radius: 50%;
        color: var(--tlp-white-color);
        font-size: 16px;

        &:hover {
            background: var(--tlp-white-color);
            color: var(--tlp-main-color);
        }

        > .fa {
            line-height: 25px;
        }
    }

    .flatpickr-month {
        flex: 0 0 75%;
        height: 40px;
    }
}

.flatpickr-current-month {
    left: 10px;
    width: 100%;

    // stylelint-disable selector-no-qualifying-type
    span.cur-month {
        // stylelint-enable
        margin: 0;
        color: var(--tlp-white-color);
        font-weight: 600;

        &:hover {
            background: none;
        }
    }

    // stylelint-disable-next-line selector-class-pattern
    .numInputWrapper {
        margin-left: 5px;

        &:hover {
            background: transparent;
        }

        // stylelint-disable selector-no-qualifying-type
        input.cur-year {
            // stylelint-enable
            padding: 0 10px 0 0;
            color: var(--tlp-white-color);
            font-family: var(--tlp-font-family);
            font-size: 20px;

            &:hover {
                background: none;
            }
        }
    }
}

.flatpickr-weekdays {
    background: var(--tlp-main-color);
    color: var(--tlp-white-color);
}

// stylelint-disable-next-line selector-no-qualifying-type
span.flatpickr-weekday {
    background: var(--tlp-main-color);
    color: var(--tlp-white-color-transparent-30);
    font-weight: 600;
}

.flatpickr-weekwrapper {
    flex: 1 1 auto;

    .flatpickr-weekday {
        color: var(--tlp-main-color);
    }

    // stylelint-disable selector-no-qualifying-type
    span.flatpickr-day {
        // stylelint-enable
        color: var(--tlp-main-color);

        &:hover {
            color: var(--tlp-main-color);
        }
    }
}

.flatpickr-day {
    max-width: 40px;
    height: 40px;
    color: #050505;
    line-height: 38px;

    &:hover {
        border-color: transparent;
        background: var(--tlp-main-color-hover-background);
        color: var(--tlp-main-color);
    }

    &.today {
        border-color: var(--tlp-main-color);

        &:hover {
            border-color: var(--tlp-main-color);
            background: var(--tlp-main-color-hover-background);
            color: var(--tlp-main-color);
        }
    }

    // stylelint-disable selector-class-pattern
    &.prevMonthDay,
    &.nextMonthDay {
        // stylelint-enable
        color: var(--tlp-dimmed-color);

        &:hover {
            border-color: transparent;
            background: var(--tlp-main-color-hover-background);
        }
    }

    /* stylelint-disable selector-class-pattern */
    &.selected,
    &.prevMonthDay.selected,
    &.nextMonthDay.selected {
        /* stylelint-enable */
        border-color: transparent;
        background: var(--tlp-main-color);
        color: var(--tlp-white-color);
        font-weight: 600;

        &:hover {
            border-color: transparent;
            background: var(--tlp-main-color-transparent-20);

            &.today {
                color: var(--tlp-white-color);
            }
        }
    }
}
