// (C) 2007-2025 GoodData Corporation
@use "react-day-picker/src/style.css";
@use "sass:color";
@use "mixins";
@use "Datepicker/_variables" as datepicker-variables;
@use "variables";

/* ==========================================================================
   Datepicker
   ========================================================================== */
.gd-datepicker {
    position: relative;

    .input-text {
        position: relative;
        padding-left: 36px;

        @include mixins.transition("padding-left", 0);
    }

    &.small {
        .input-text {
            padding-left: 30px;
        }

        .gd-datepicker-icon {
            left: 8px;
            line-height: 28px;
            font-size: 15px;
        }
    }

    &.gd-datepicker-focused {
        .input-text,
        .gd-datepicker-icon {
            z-index: 11;
        }
    }
}

.gd-datepicker-icon {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 10px;
    line-height: 30px;
    color: variables.$gd-palette-primary-base;
    font-size: 18px;

    @include mixins.transition("color", 0.25s, ease-in-out);
}

.gd-datepicker-OverlayWrapper {
    z-index: 10;
}

.gd-datepicker-OverlayWrapper-xx-tl,
.gd-datepicker-OverlayWrapper-xx-bl {
    left: 0;
}

.gd-datepicker-OverlayWrapper-xx-tr,
.gd-datepicker-OverlayWrapper-xx-br {
    right: 0;
    left: auto;
}

.gd-datepicker-OverlayWrapper-tl-xx,
.gd-datepicker-OverlayWrapper-tr-xx {
    top: auto;
    bottom: 100%;

    @include mixins.box-shadow(
        0 0 5px 0
            var(
                --gd-shadow-color-from-theme,
                color.adjust(datepicker-variables.$gd-datepicker-shadow-color, $alpha: -0.85)
            )
    );
}

.gd-datepicker-picker {
    --rdp-cell-size: 32px;
    --rdp-background-color: none;
    --rdp-accent-color: none;
    --rdp-accent-color-dart: none;
    --rdp-background-color-dark: none;
    --rdp-accent-color-dark: none;

    position: absolute;
    padding: 18px 15px 15px;
    background: variables.$gd-color-white;
    user-select: none;
    text-align: left;

    @include mixins.box-shadow(
        0 2px 5px 0
            var(
                --gd-shadow-color-from-theme,
                color.adjust(datepicker-variables.$gd-datepicker-shadow-color, $alpha: -0.85)
            )
    );

    //CSS for new DATEPICKER
    .rdp-button {
        line-height: 16px;
    }

    .rdp-months {
        position: unset;
    }

    .rdp-nav {
        position: absolute;
        top: 18px;
        height: 29px;
        right: 0;
        left: 0;
        padding: 0 0.5rem;
        display: flex;
        justify-content: space-between;

        button {
            width: 29px;
            height: 29px;
            cursor: pointer;

            &:hover {
                color: variables.$gd-color-state-blank;
            }
        }
    }

    .rdp-button_previous {
        left: 0.8em;
        display: block;
        width: 2em;
        height: 2em;
        text-align: center;
        color: variables.$gd-palette-primary-base;
        padding-top: 0.15em;
        font-family: variables.$gd-font-indigo;
        font-size: 18px;
    }

    .rdp-button_next {
        right: 1em;
        display: block;
        width: 2em;
        height: 2em;
        text-align: center;
        color: variables.$gd-palette-primary-base;
        padding-top: 0.15em;
        font-family: variables.$gd-font-indigo;
        font-size: 18px;
    }

    .rdp-chevron {
        fill: currentColor;
    }

    .rdp-month_caption {
        display: flex;
        justify-content: center;
        margin-bottom: 10px;
        height: 29px;
    }

    .rdp-caption_label {
        font-family: variables.$gd-font-primary;
        font-size: 17px;
        text-align: center;
        font-weight: normal;
        color: variables.$gd-color-dark;
    }

    .rdp-month_grid {
        margin-top: 10px;
    }

    .rdp-weekday {
        display: table-cell;
        color: var(--gd-palette-complementary-8-from-theme, variables.$default-gd-color-state-blank);
        cursor: help;
        font-family: variables.$gd-font-primary;
        font-weight: 400;
        font-size: 13px;
        text-transform: none;
        text-align: center;

        span {
            text-decoration: none;
            border-bottom: none;
        }
    }

    .rdp-day {
        padding: 0.3125em 0.55em;
        color: variables.$gd-color-text;
        font-family: variables.$gd-font-primary;
        font-size: 14px;
        font-weight: 700;
        border-radius: 0;

        &:not([disabled]):not(.rdp-selected):hover {
            background: datepicker-variables.$gd-datepicker-hover-bgcolor;
            cursor: pointer;
        }

        button {
            position: relative;
            left: 50%;
            transform: translateX(-50%);
            text-align: center;
        }
    }

    .rdp-disabled {
        color: variables.$gd-color-disabled;
        cursor: default;
        font-weight: 400;
    }

    .rdp-outside {
        color: variables.$gd-medium-gray;
        cursor: default;
        font-weight: 400;
        opacity: 1;

        &.rdp-selected {
            font-weight: 700;
        }
    }

    .rdp-selected:not(.rdp-disabled) {
        color: variables.$gd-color-text-light;
        background: variables.$gd-palette-primary-base;
    }

    //CSS for old DATEPICKER due to RAIL-4460

    .DayPicker {
        position: relative;
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        user-select: none;
    }

    .DayPicker-Month {
        display: table;
        border-spacing: 0;
        border-collapse: collapse;
        user-select: none;
    }

    .DayPicker-NavBar {
        position: absolute;
        right: 0;
        left: 0;
        padding: 0 0.5rem;
    }

    .DayPicker-NavButton {
        position: absolute;
        width: 1.5rem;
        height: 1.5rem;
        cursor: pointer;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }

    .DayPicker-NavButton--prev,
    .DayPicker-NavButton--next {
        position: absolute;
        top: -0.25em;
        box-sizing: content-box;
        width: 2em;
        height: 2em;
        text-align: center;

        &::before {
            display: block;
            color: variables.$gd-palette-primary-base;
            padding-top: 0.15em;
            font-family: variables.$gd-font-indigo;
            font-size: 18px;
        }

        &:hover::before {
            color: variables.$gd-color-state-blank;
        }
    }

    .DayPicker-NavButton--prev {
        left: 0.15em;

        &::before {
            content: "\e630";
        }
    }

    .DayPicker-NavButton--next {
        right: 0.35em;

        &::before {
            content: "\e631";
        }
    }

    .DayPicker-NavButton--next:hover,
    .DayPicker-NavButton--prev:hover {
        color: variables.$gd-palette-primary-base;
        cursor: pointer;
    }

    .DayPicker-Caption {
        display: table-caption;
        color: variables.$gd-color-dark;
        cursor: default;
        margin-left: 0.25em;
        margin-right: 0.25em;
        margin-bottom: 1em;
        font-family: variables.$gd-font-primary;
        font-size: 17px;
        text-align: center;
    }

    .DayPicker-Weekdays {
        display: table-header-group;
    }

    .DayPicker-WeekdaysRow {
        display: table-row;
    }

    .DayPicker-Weekday {
        display: table-cell;
        color: var(--gd-palette-complementary-8-from-theme, variables.$default-gd-color-state-blank);
        cursor: help;
        padding-bottom: 0.5em;
        font-family: variables.$gd-font-primary;
        font-weight: 400;
        font-size: 13px;
        text-align: center;

        abbr {
            text-decoration: none;
            border-bottom: none;
        }
    }

    .DayPicker-Body {
        display: table-row-group;
    }

    .DayPicker-Week {
        display: table-row;
    }

    .DayPicker-Day {
        display: table-cell;
        padding: 0.3125em 0.55em;
        color: variables.$gd-color-text;
        font-family: variables.$gd-font-primary;
        font-size: 14px;
        font-weight: 700;
        text-align: center;

        &:hover {
            background: datepicker-variables.$gd-datepicker-hover-bgcolor;
            cursor: pointer;
        }
    }

    .DayPicker--interactionDisabled .DayPicker-Day {
        cursor: default;
    }

    .DayPicker-Day--disabled {
        color: variables.$gd-color-disabled;
        cursor: default;
        font-weight: 400;
    }

    .DayPicker-Day--outside {
        color: variables.$gd-color-disabled;
        cursor: default;
        font-weight: 400;
    }

    .DayPicker-Day--selected:not(.DayPicker-Day--disabled):not(.DayPicker-Day--outside) {
        color: variables.$gd-color-text-light;
        background: variables.$gd-palette-primary-base;
    }
}
