@import '../../../../../../styles/definitions/colors';
@import '../../../../../../styles/definitions/mixins';

// Local Variables
$overlay-padding-x: 30px;
$overlay-padding-y: 15px;
$overlay-border-color: $mid-gray;
$overlay-bg-color: $white;
$overlay-boxshadow: 0 0 6px 3px rgba($deep-gray, 0.15);
$product-spacing: 20px;

// Component Styles
.headerCartOverlay {
    &_wrapper {
        position: relative;
        box-shadow: $overlay-boxshadow;

        &::after {
            $size: 20px;
            display: block;
            position: absolute;
            top: -4px;
            right: 15px;
            width: $size;
            height: $size;
            background-color: $overlay-bg-color;
            box-shadow: $overlay-boxshadow;
            transform: rotate(-45deg);
            z-index: 0;
            opacity: 1;
            transition: opacity 0.2s ease-out;

            @include media-md-up {
                content: '';
            }
        }

        &.enter:not(.enter-active),
        &.exit-active {
            &::after {
                opacity: 0;
                transition-delay: 0.2s;
            }
            .headerCartOverlay_mask {
                max-height: 0;
            }
        }
    }

    &_mask {
        max-height: var(--cart-overlay-height, none);
        transition: max-height var(--cart-overlay-transition-durantion, 500ms) ease;
        overflow: hidden;
    }

    &_main {
        position: relative;
        display: flex;
        flex-direction: column;
        z-index: 1;
        background-color: $overlay-bg-color;
        max-height: var(--cart-overlay-height, none);
    }

    &_loading {
        display: flex;
        padding: 18px $overlay-padding-x;
    }

    &_preloader {
        position: relative;
        flex-grow: 1;
        background-color: transparent;
    }

    &_header {
        padding: 18px $overlay-padding-x;
        border-bottom: 1px solid $overlay-border-color;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
    }

    &_message {
        border: 1px solid;
        padding: 10px 15px;
        border-radius: 3px;
        display: flex;
        align-items: center;

        &--error {
            border-color: rgba($error-color, 0.3);
            color: $error-color;
        }
        &--success {
            border-color: rgba($success-color, 0.3);
            color: $success-color;
        }

        &Icon {
            width: 25px;
            height: 25px;
            margin-right: 15px;
            flex-shrink: 0;

            &--error {
                fill: $error-color;
            }
            &--success {
                circle {
                    fill: $success-color;
                }
                path {
                    fill: $white;
                }
            }
        }
    }

    &_message + &_itemsList {
        margin-top: $overlay-padding-y;
    }

    &_cartEmpty {
        padding-top: 10px;
    }

    &_title {
        @include title-1;
        display: flex;
        align-items: center;
        margin-bottom: 0;

        &Icon {
            width: 32px;
            margin-right: 20px;

            circle {
                fill: $success-color;
            }
            path {
                fill: $white;
            }
        }
    }

    &_close {
        padding: 0;
        fill: $dark-gray;
    }

    &_content {
        padding: $overlay-padding-y $overlay-padding-x 0;
        flex-shrink: 2;
        overflow-y: auto;

        &--no-footer,
        &--with-scrollbar {
            padding-bottom: $overlay-padding-y;
        }
    }

    &_cart {
        @include text-5;
        overflow-y: auto;
        min-height: 50px;

        &Title {
            font-weight: 700;
        }

        &Description {
            margin: 0;
        }

        &Title + &Description {
            margin-top: 8px;
        }

        &--active {
            padding-top: 0;
        }
    }

    &_itemsList,
    &_addonList {
        @extend %reset-list;
    }

    &_product {
        $product-spacing: 20px;
        border-bottom: 1px solid $overlay-border-color;
        padding: $product-spacing 0;

        &:first-child {
            padding-top: 0;
        }

        &:last-child {
            border-bottom: none;
            padding-bottom: 0;
        }
    }

    &_bundle {
        border-bottom: 1px solid $overlay-border-color;
        padding: $product-spacing 0;

        &:first-child {
            padding-top: 0;
        }

        &:last-child {
            border-bottom: none;
            padding-bottom: 0;
        }
    }

    &_bundleHeader {
        display: flex;
        align-items: flex-start;
        gap: 12px;
    }

    &_bundleIcon {
        width: 32px;
        height: 32px;
        border-radius: 6px;
        border: 1px solid $overlay-border-color;
        object-fit: cover;
        flex-shrink: 0;
    }

    &_bundleIconFallback {
        width: 32px;
        height: 32px;
        border-radius: 6px;
        border: 1px solid $overlay-border-color;
        background: $white;
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        flex-shrink: 0;

    }

    &_bundleIconFallbackSvg {
        display: block;
    }

    &_bundleInfo {
        min-width: 0;
        flex: 1;
    }

    &_bundleTitleRow {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 4px;
    }

    &_bundleName {
        @include title-4;
        margin-bottom: 0;
        line-height: 1.2;
        flex: 1;
        min-width: 0;
    }

    &_bundleBadge {
        border-radius: 2px;
        display: inline-block;
        vertical-align: middle;
        font-size: 10px;
        line-height: 1em;
        padding: 4px;
        text-align: center;
        text-transform: uppercase;
        font-weight: bold;
        -webkit-font-smoothing: antialiased;
        box-shadow: rgb(0, 96, 128) 0px 0px 0px 1px;
        background-color: rgb(0, 96, 128);
        color: rgb(255, 255, 255);
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        align-self: flex-start;
        margin-top: 4px;
    }

    &_bundleProvider {
        @include text-5;
        opacity: 0.8;
        margin-bottom: 2px;
    }

    &_bundleDescription {
        @include text-5;
        opacity: 0.8;
        margin-bottom: 4px;
    }

    &_addon {
        margin-top: 10px;
    }

    &_footer {
        background-color: $overlay-bg-color;
        padding: 15px $overlay-padding-x;
        flex-shrink: 0;

        &Button {
            width: 100%;
            max-width: 360px;
            margin: 0 auto;
        }

        &--with-box-shadow {
            box-shadow: $overlay-boxshadow;
        }
    }
}
