@use "../../wwwroot/scss/variables" as *;

.picker-panel {
    --bb-picker-panel-body-width: 320px;
    --bb-picker-hover-color: #409eff;
    --bb-picker-panel-side-width: 0;
    --bb-picker-panel-today-color: #fff;
    --bb-picker-panel-today-bg: #409eff;
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
    background-color: var(--bs-body-bg);
    border-radius: var(--bs-border-radius);
    line-height: 30px;
    display: inline-block;

    &.is-sidebar {
        --bb-picker-panel-side-width: 110px;
    }

    @include pick-side;

    .picker-panel-body {
        display: flex;

        .picker-panel-sidebar {
            width: var(--bb-picker-panel-side-width);
        }

        .picker-panel-body-main {
            width: var(--bb-picker-panel-body-width);
            overflow: hidden;
            display: flex;

            .picker-panel-body-main-wrapper {
                display: flex;
                transition: transform .3s ease-in-out;

                &.is-open {
                    transform: translateX(calc(0px - var(--bb-picker-panel-body-width)));
                }
            }

            .picker-panel-header {
                margin: 12px;
                display: flex;
                align-items: center;

                .pick-panel-arrow-left,
                .pick-panel-arrow-right {
                    margin: 0 6px;
                }

                .picker-panel-icon-btn {
                    color: var(--bs-body-color);
                    border: 0;
                    background: transparent;
                    cursor: pointer;
                    outline: none;
                    padding: 0 6px;

                    &:hover {
                        color: var(--bb-picker-hover-color);
                    }
                }

                .picker-panel-header-bar {
                    .picker-panel-header-label {
                        font-size: 14px;
                    }
                }

                .picker-panel-header-label {
                    font-size: 16px;
                    font-weight: 500;
                    padding: 0 4px;
                    text-align: center;
                    cursor: pointer;
                    user-select: none;
                    white-space: nowrap;

                    &:hover {
                        color: var(--bb-picker-hover-color);
                    }
                }
            }

            .picker-panel-content {
                width: 290px;
                position: relative;
                margin: 15px;

                table {
                    table-layout: fixed;
                    width: 100%;
                    user-select: none;

                    .date-table-row {
                        font-size: 12px;
                    }

                    td {
                        text-align: center;

                        .cell {
                            display: block;
                            margin: 0 auto;
                            cursor: pointer;

                            &:has(.bb-picker-body-lunar-text):hover {
                                color: var(--bb-picker-panel-today-color);

                                &:before {
                                    content: "";
                                    position: absolute;
                                    width: 33px;
                                    height: 33px;
                                    border-radius: var(--bs-border-radius);
                                    background-color: var(--bb-picker-panel-today-bg);
                                    top: 3px;
                                    left: -3.5px;
                                    opacity: .8;
                                }

                                .bb-picker-body-lunar-text {
                                    color: var(--bb-picker-panel-today-color);
                                }
                            }

                            span.is-holiday, span.is-workday {
                                background-color: #c0c4cc;
                                color: var(--bb-picker-panel-today-color);
                                height: 14px;
                                width: 15px;
                                font-size: 9px;
                                border-radius: 3px;
                                top: -1px;
                                right: -9px;
                                line-height: 14px;
                                opacity: .8;
                            }
                        }

                        &.today {
                            .cell {
                                color: var(--bb-picker-hover-color);
                                font-weight: 700;
                            }
                        }

                        &.current:not(.disabled),
                        &.start:not(.disabled),
                        &.end:not(.disabled) {
                            .cell {
                                color: var(--bb-picker-panel-today-color);

                                &:not(:has(.bb-picker-body-lunar-text)) {
                                    background-color: var(--bb-picker-panel-today-bg);
                                }

                                &:has(.bb-picker-body-lunar-text) {
                                    &:before {
                                        content: "";
                                        position: absolute;
                                        width: 33px;
                                        height: 33px;
                                        border-radius: var(--bs-border-radius);
                                        background-color: #409eff;
                                        top: 3px;
                                        left: -3.5px;
                                    }
                                }
                            }
                        }

                        &:not(.next-month):not(.prev-month):not(.disabled) {
                            &:not(.current):not(.start):not(.end):not(.range) {
                                .cell {
                                    &.is-solar-term:not(:hover) {
                                        .bb-picker-body-lunar-text {
                                            color: var(--bs-success);
                                        }
                                    }

                                    &.is-festival:not(:hover) {
                                        .bb-picker-body-lunar-text {
                                            color: var(--bs-info);
                                        }
                                    }
                                }
                            }

                            .cell {
                                span.is-holiday {
                                    background-color: var(--bs-danger);
                                }

                                span.is-workday {
                                    background-color: var(--bs-black);
                                }
                            }
                        }

                        &.range {
                            position: relative;

                            &.start:before {
                                border-top-left-radius: 40%;
                                border-bottom-left-radius: 40%;
                                left: 6px;
                            }

                            &.end:before {
                                border-top-right-radius: 40%;
                                border-bottom-right-radius: 40%;
                                right: 6px;
                            }

                            &:before {
                                content: "";
                                position: absolute;
                                background-color: #f2f6fc;
                                top: 4px;
                                bottom: 4px;
                                left: 0;
                                right: 0;
                            }
                        }

                        &.disabled {
                            .cell {
                                cursor: not-allowed;
                                color: #c0c4cc;
                            }
                        }
                    }
                }

                .year-table, .month-table {
                    margin-block-start: 29px;

                    tr {
                        border-top: 1px solid var(--bs-border-color);
                    }
                }

                .year-table td {
                    padding: 13px 0;

                    .cell {
                        width: 48px;
                        height: 24px;
                        line-height: 24px;
                        border-radius: 16px;
                    }
                }

                .month-table td {
                    padding: 27px 0;

                    .cell {
                        width: 60px;
                        border-radius: 18px;
                    }
                }

                .date-table {
                    th {
                        padding: 5px;
                        font-weight: 400;
                        border-bottom: 1px solid var(--bs-border-color);
                        text-align: center;
                    }

                    td {
                        padding: 7px 0;

                        &.next-month, &.prev-month {
                            color: #c0c4cc;
                        }

                        &:not(.prev-month):not(.next-month):hover {
                            color: #409eff;
                        }

                        .cell {
                            width: 24px;
                            height: 24px;
                            margin: 0 auto;
                            line-height: 24px;
                            border-radius: 50%;
                            cursor: pointer;
                            position: relative;
                            display: flex;
                            flex-direction: column;

                            .bb-picker-body-lunar-text {
                                top: 22px;
                                white-space: nowrap;
                                line-height: 9px;
                                height: 9px;
                                font-size: 9px;
                            }

                            span {
                                position: absolute;
                                width: 100%;
                            }
                        }
                    }
                }
            }
        }
    }

    .clock-panel-body {
        width: var(--bb-picker-panel-body-width);
    }
}

.popover-body {
    .picker-panel {
        box-shadow: none;
    }
}

.picker-panel-time {
    display: flex;
    justify-content: space-between;
    flex-wrap: nowrap;
    padding: 4px 1rem;
    border-top: var(--bs-border-width) solid var(--bs-border-color);
    position: relative;

    .form-control {
        font-size: 14px;
        width: 178px;
        cursor: pointer;
        padding: 3px 8px;
        text-align: center;
    }

    .bb-time-picker {
        position: absolute;
        bottom: 2.5rem;
        right: 1rem;
    }

    &:not(.show) .bb-time-picker {
        display: none;
    }
}

.picker-panel-footer {
    border-top: var(--bs-border-width) solid var(--bs-border-color);
    padding: 4px;
    background-color: var(--bs-body-bg);
    position: relative;
    display: flex;
    border-bottom-left-radius: var(--bs-border-radius);
    border-bottom-right-radius: var(--bs-border-radius);

    .picker-panel-link-btn {
        padding: 4px 12px;
        font-size: 0.75rem;
        border-radius: var(--bs-border-radius);
        border: var(--bs-border-width) solid var(--bs-border-color);
        color: var(--bs-body-color);
        transition: border-color .3s linear, color .3s linear;

        &:hover {
            border-color: #409eff;
            color: #409eff;
        }

        &:last-child {
            margin-inline-start: .25rem;
        }
    }

    .picker-timer {
        cursor: pointer;

        &:hover {
            color: #409eff;
        }
    }
}
