@use '../../../../shared/styles/variables' as *;

.history-period-control {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.history-period-control__top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-period-tabs {
    padding: 2px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-bg) 80%, transparent);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 2px;
}

.history-period-tabs__item {
    height: 32px;
    padding: 0 16px;

    border: none;
    border-radius: 999px;
    background: transparent;

    color: $gray50;
    font-size: 14px;
    font-weight: 550;
    cursor: pointer;

    transition: 0.2s ease;

    &:hover {
        color: $blue;
        background: $gray30;
    }

    &.is-active {
        background: $color-bg;
        color: $blue;
    }
}

.history-date-picker {
    position: relative;
}

.history-date-picker__trigger {
    height: 36px;
    padding: 0 14px;
    text-wrap: nowrap;

    border: none;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-bg) 80%, transparent);
    backdrop-filter: blur(10px);

    display: inline-flex;
    align-items: center;
    gap: 8px;

    color: var(--gray50);
    font-size: 14px;
    font-weight: 500;

    cursor: pointer;
    transition: 0.2s ease;

    svg {
        color: $gray50;
        transition: .2s ease;
    }

    &:hover,
    &.is-active {
        background: $color-bg;
        color: $blue;
        box-shadow: inset 0 0 0 1px rgba($color-primary-rgb, 0.16);

        svg {
            color: $blue;
        }
    }
}

.history-date-picker__dropdown {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 120;

    min-width: 100%;
    width: max-content;
    border-radius: 18px;
    background: $color-surface;
    padding: 12px;

    border: 1.5px solid $gray20;
    box-shadow: none;

    button{
        transition: .18s ease;
    }

    .rdp-root {
        --rdp-accent-color: #{$blue};
        --rdp-accent-background-color: #{$color-primary-soft};
        --rdp-day_button-border-radius: 12px;
        --rdp-day_button-height: 34px;
        --rdp-day_button-width: 34px;
        --rdp-day-height: 36px;
        --rdp-day-width: 36px;
        --rdp-selected-border: 0;

        margin: 0;
        font-family: inherit;
    }

    .rdp-months {
        max-width: 100%;
        gap: 18px;
    }

    .rdp-month {
        width: 100%;
    }

    .rdp-month_caption {
        margin-bottom: 8px;
    }

    .rdp-caption_label {
        color: $color-text-strong;
        font-size: $font-size-14;
        font-weight: 700;
    }

    .rdp-nav {
        gap: 4px;
    }

    .rdp-button_previous,
    .rdp-button_next,
    .rdp-nav button {
        width: 28px;
        height: 28px;
        border-radius: 8px;

        color: $blue;

        &:hover {
            background: $color-surface-hover;
        }
    }

    .rdp-weekday {
        color: $color-text-muted;
        font-size: $font-size-12;
        font-weight: 600;
    }

    .rdp-day_button {
        border: none;

        color: $color-text-heading;
        font-size: $font-size-12;
        font-weight: 600;

        &:hover {
            background: $color-surface-hover;
        }
    }

    .rdp-selected {
        .rdp-day_button {
            background: $blue;
            color: $color-text-inverse;
        }
    }

    .rdp-range_middle {
        background-color: transparent;
        .rdp-day_button {
            background: $color-primary-soft;
            color: $blue;
            border-radius: 0;
        }
    }

    .rdp-range_start {
        .rdp-day_button {
            background: $blue;
            color: $color-text-inverse;
            border-radius: 12px;
        }
    }

    .rdp-range_end {
        .rdp-day_button {
            background: $blue;
            color: $color-text-inverse;
            border-radius: 12px;
        }
    }

    .rdp-range_start.rdp-range_end {
        .rdp-day_button {
            border-radius: 12px;
        }

        .rdp-today {
            .rdp-day_button {
                font-weight: 700;
            }
        }
    }

    .rdp-outside {
        opacity: 0.35;
    }
}

.history-range {
    width: 100%;
    padding: 0 60px;
}

.history-range__labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;

    color: $blue;
    font-size: 14px;
    font-weight: 500;
}

.history-range__track {
    position: relative;
    height: 24px;
}

.history-range__line {
    position: absolute;
    left: 0;
    right: 0;
    top: 10px;

    height: 4px;
    border-radius: 999px;
    background: rgba($color-primary-rgb, 0.16);
}

.history-range__active {
    position: absolute;
    top: 10px;

    height: 4px;
    border-radius: 999px;
    background: $blue;
}

.history-range__track input {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 24px;
    margin: 0;

    appearance: none;
    background: transparent;
    pointer-events: none;
}

.history-range__track input::-webkit-slider-thumb {
    appearance: none;
    pointer-events: auto;

    width: 16px;
    height: 16px;

    border: none;
    border-radius: 50%;
    background: $blue;

    cursor: pointer;
}

.history-range__track input::-moz-range-thumb {
    pointer-events: auto;

    width: 16px;
    height: 16px;

    border: none;
    border-radius: 50%;
    background: $blue;

    cursor: pointer;
}
