@import '../../style/themes/index';

@drawer-prefix-cls: ~'@{acud-prefix}-drawer';
@picker-prefix-cls: ~'@{acud-prefix}-picker';

.@{drawer-prefix-cls} {
    @drawer-header-close-padding: ceil(((@drawer-header-close-size - @font-size-lg) / 2));
    position: fixed;
    z-index: @drawer-zindex-modal;
    width: 0%;
    height: 100%;
    transition: transform @animation-duration-slow @ease-base-out,
        height 0s ease @animation-duration-slow, width 0s ease @animation-duration-slow;
    outline: none;

    >* {
        transition: transform @animation-duration-slow @ease-base-out,
            box-shadow @animation-duration-slow @ease-base-out;
    }

    &-content-wrapper {
        position: absolute;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    &-left,
    &-right {
        top: 0;
        width: 0%;
        height: 100%;

        .@{drawer-prefix-cls}-content-wrapper {
            height: 100%;
        }

        &.@{drawer-prefix-cls}-open {
            width: 100%;
            transition: transform @animation-duration-slow @ease-base-out;
        }
    }

    &-left {
        left: 0;

        .@{drawer-prefix-cls} {
            &-content-wrapper {
                left: 0;
            }
        }

        &.@{drawer-prefix-cls}-open {
            .@{drawer-prefix-cls}-content-wrapper {
                box-shadow: @shadow-2;
            }
        }
    }

    &-right {
        right: 0;

        .@{drawer-prefix-cls} {
            &-content-wrapper {
                right: 0;
            }
        }

        &.@{drawer-prefix-cls}-open {
            .@{drawer-prefix-cls}-content-wrapper {
                box-shadow: @shadow-2;
            }

            &.no-mask {
                right: 1px;
                transform: translateX(1px);
            }
        }
    }

    &-top,
    &-bottom {
        left: 0;
        width: 100%;
        height: 0%;

        .@{drawer-prefix-cls}-content-wrapper {
            width: 100%;
        }

        &.@{drawer-prefix-cls}-open {
            height: 100%;
            transition: transform @animation-duration-slow @ease-base-out;
        }
    }

    &-top {
        top: 0;

        &.@{drawer-prefix-cls}-open {
            .@{drawer-prefix-cls}-content-wrapper {
                box-shadow: @shadow-2;
            }
        }
    }

    &-bottom {
        bottom: 0;

        .@{drawer-prefix-cls} {
            &-content-wrapper {
                bottom: 0;
            }
        }

        &.@{drawer-prefix-cls}-open {
            .@{drawer-prefix-cls}-content-wrapper {
                box-shadow: @shadow-2;
            }

            &.no-mask {
                bottom: 1px;
                transform: translateY(1px);
            }
        }
    }

    &.@{drawer-prefix-cls}-open .@{drawer-prefix-cls}-mask {
        height: 100%;
        opacity: 1;
        transition: none;
        animation: acudDrawerFadeIn @animation-duration-slow @ease-base-out;
        pointer-events: auto;
    }

    &-title {
        display: inline-block;
        vertical-align: middle;
        font-size: @T4;
        color: @G2;
        margin: 0;
        font-weight: @font-weight-500;
        line-height: 6*@P;
    }

    .@{drawer-prefix-cls}-back {
        height: 4*@P;
        vertical-align: middle;
        cursor: pointer;
        font-size: @T4;
        transition: color @animation-duration-slow;
        .basic-tp-config(@drawer-back-icon-tp);
        margin-right: @P;
        svg {
            vertical-align: top;
        }
    }

    &-content {
        width: 100%;
        height: 100%;
        position: relative;
        z-index: 1;
        overflow: auto;
        background-color: #fff;
        background-clip: padding-box;
        border: 0;
    }

    &-close {
        position: absolute;
        top: 0;
        right: 0;
        z-index: @drawer-zindex-popup-close;
        display: block;
        padding: @drawer-close-icon-padding;
        font-weight: 700;
        font-size: @font-size-lg;
        font-style: normal;
        line-height: 1;
        text-align: center;
        text-transform: none;
        text-decoration: none;
        background: transparent;
        border: 0;
        outline: 0;
        cursor: pointer;
        transition: color @animation-duration-slow;
        text-rendering: auto;
        --scroll-bar: 0;
        .basic-tp-config(@drawer-close-icon-tp);

        .@{drawer-prefix-cls}-header-no-title & {
            margin-right: var(--scroll-bar);
            /* stylelint-disable-next-line function-calc-no-invalid */
            padding-right:~'calc(@{drawer-header-close-padding} - var(--scroll-bar))';
        }
    }

    &-header {
        position: relative;
        padding: @drawer-default-padding;
        color: @G2;
        height: @drawer-header-height;
        background: #fff;
        border-bottom: 1px solid @G9;
        border-radius: 0;

        &+.@{drawer-prefix-cls}-body {
            padding-top: 6*@P;
        }
    }

    &-header-no-title {
        color: @G2;
        background: #fff;
    }

    &-wrapper-body {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        width: 100%;
        height: 100%;
    }

    &-body {
        flex-grow: 1;
        padding: @drawer-default-padding;
        overflow: auto;
        font-size: @T3;
        color: @G2;
        font-weight: @font-weight-400;
        line-height: @drawer-t3-line-height;
        word-wrap: break-word;
    }

    &-footer {
        flex-shrink: 0;
        padding: @drawer-default-padding;
        border-top: 1px solid @G9;
    }

    &-mask {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 0;
        background-color: rgba(0, 0, 0, 0.5);
        opacity: 0;
        filter: ~'alpha(opacity=45)';
        transition: opacity @animation-duration-slow linear, height 0s ease @animation-duration-slow;
        pointer-events: none;
    }

    &-open {
        &-content {
            box-shadow: @shadow-2;
        }
    }

    &-footer {
        height: 16 * @P;
    }

    //   // =================== Hook Components ===================
    //   .@{picker-prefix-cls} {
    //     &-clear {
    //       background: @popover-background;
    //     }
    //   }
}

@keyframes acudDrawerFadeIn {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}
