// Variables
$white_color: #fff;
$radius: 2rem;

@import "_mixins";
@import "frontend/_icons";
@import "frontend/_animations";

.sp-close {
    background: none;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 0;
    min-height: initial;
    border: none;
    border-radius: 0;
    margin-left: 1rem;
    transition: all .5s ease;

    &::before,
    &::after {
        content: "";
        background-color: red;
        height: 2px;
        width: 1.25rem;
        position: absolute;
        left: 0;
    }

    &::before {
        transform: rotate(45deg);
    }

    &::after {
        transform: rotate(-45deg);
    }

    &:hover,
    &:focus {
        background: none;
        transform: scale(1.1);
    }
}

.sp-message {
    background-color: var(--sp-card-bg);
    color: var(--sp-text-color);
    position: relative;
    margin: 0 0 1.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--sp-primary-color);
    border-radius: $radius;
    color: inherit;

    &.success {
        border-top-color: green;
        color: inherit;
    }

    &.warn {
        border-top-color: orange;
        color: inherit;
    }

    &.error {
        border-top-color: red;
        color: inherit;
    }

    + .sp-message {
        margin-top: -1rem;
    }
}

.sp-story-slider-wrapper {

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    position: relative;
    margin: 0 0 2rem;
    padding-bottom: calc(40px / 2);
    border-radius: $radius;
    overflow: hidden;

    .skeletons {

        .swiper-wrapper {
            gap: var(--sp-slide-gap, .25rem);

            .swiper-slide {
                flex: 1;
                margin: 0 !important;
            }
        }
    }

    .sp-story-skeleton {
        // @include skeleton-shimmer;
        background-color: #f6f7f8;
        aspect-ratio: 116 / 180;
        border-radius: $radius;
        padding: 0.75rem;
        font-size: 14px;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        line-height: 1.5;
    }

    .sp-story-avatar-skeleton {
        width: 40px;
        height: 40px;
        margin: 0 auto;
        border-radius: 50%;
        @include skeleton-shimmer;
        border: 2px solid $white_color;
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translate(-50%, 50%);
        z-index: 2;
    }

    .sp-story-name-skeleton {
        width: 60%;
        height: 12px;
        margin: 8px auto;
        @include skeleton-shimmer;
        border-radius: 4px;
        position: absolute;
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%);
    }

    .swiper {
        overflow: unset;

        &.sp-slider-partial {
            position: relative;

            &::before {
                content: "";
                background-color: var(--sp-card-bg);
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                border-radius: $radius;
            }
        }
    }

    .swiper-wrapper {
        display: flex;
    }

    .sp-story-card {
        background-color: #1a1a1a; // ok
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        aspect-ratio: 116 / 180;
        border-radius: $radius;
        padding: .75rem;
        font-size: 14px;
        flex-shrink: 0;
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        line-height: 1.5;
        // overflow: hidden;

        &:hover {
            cursor: pointer;

            .sp-story-name {
                // background-image: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 70%);
                padding-top: 3rem;
                transition: all .5s;
            }
        }

        .sp-story-avatar {
            position: absolute;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            bottom: 0;
            left: 50%;
            transform: translate(-50%, 50%);
            z-index: 1;

            img {
                width: 100%;
                height: 100%;
                border-radius: 50%;
                border: 2px solid $white_color;
                margin: 0;
            }

            .sp-story-plus {
                background-color: var(--sp-primary-color);
                border: 2px solid $white_color;
                height: 100%;
                width: 100%;
                display: flex;
                align-items: center;
                justify-content: center;
                border-radius: 100px;
                color: $white_color;

                i::after {
                    background-color: $white_color;
                }
            }
        }

        .sp-story-name {
            background: linear-gradient(180deg, rgba(#000, 0) 0%, rgba(#000, .2) 70%);
            font-weight: 600;
            color: $white_color;
            // margin: 0 -.75rem -.75rem;
            padding: 1rem .75rem calc(calc(40px / 2) + 4px) .75rem;
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            border-radius: 0 0 $radius $radius;
            text-align: center;
            text-shadow: 0 1px 4px rgba(#000, .5);
            
            span {
                @include ellipsis(2);
            }
        }

        &.sp-type-new img {
            border-color: var(--sp-primary-color);
        }
    }

    .swiper-button-next,
    .swiper-button-prev {
        height: 100%;
        top: 0;
        bottom: 0;
        margin-top: 0;
        margin-bottom: 0;
        width: 40px;
        opacity: 0;
        visibility: hidden;
        color: $white_color;

        &::before,
        &::after {
            font-size: 1.5em;
        }
    }

    .swiper-button-next {
        background: linear-gradient(90deg, rgba(#000, 0) 0%, rgba(#000, .5) 70%);
        border-radius: 0 $radius $radius 0;
        right: 0;
    }

    .swiper-button-prev {
        background: linear-gradient(90deg, rgba(#000, .5) 0%, rgba(#000, 0) 70%);
        border-radius: $radius 0 0 $radius;
        left: 0;
    }

    &:hover {

        .swiper-button-next,
        .swiper-button-prev {
            opacity: 1;
            visibility: visible;
            transition: all .5s ease;

            &.swiper-button-disabled {
                opacity: .25;
            }
        }
    }

    ////////////////////////////////
    // Avatar Layout (Instagram-style)
    ////////////////////////////////
    &.sp-story-slider--avatar {
        padding: 0;
        border-radius: 0;

        .swiper.sp-slider-partial::before {
            border-radius: $radius;
        }

        .sp-story-avatar-item {
            flex-shrink: 0;
            cursor: pointer;
            text-align: center;
        }

        .sp-story-avatar-ring {
            position: relative;
            width: 100%;
            aspect-ratio: 1 / 1;
            // height: 90px;
            margin: 0 auto .75rem;
            padding: 3px;
            border-radius: 50%;
            background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
            
            &::before {
                content: '';
                position: absolute;
                inset: 0;
                border-radius: 50%;
                background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
                opacity: 0;
            }
        }

        .sp-story-avatar-circle {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background-color: #1a1a1a; // ok
            background-size: cover;
            background-position: center;
            border: 3px solid $white_color;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            box-sizing: border-box;
            // overflow: hidden;
        }

        .sp-story-avatar-plus {
            background-color: var(--sp-primary-color);
            height: 24px;
            width: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            color: $white_color;
            position: absolute;
            bottom: 0;
            right: 0;
            border: 2px solid $white_color;

            i::after {
                background-color: $white_color;
            }
        }

        .sp-story-avatar-name {
            font-size: 12px;
            font-weight: 500;
            text-align: center;
            line-height: 1.2;
            
            span {
                @include ellipsis(2);
                // display: block;
            }
        }

        // Create story variant
        .sp-type-create {

            .sp-story-avatar-ring {
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            }

            .sp-story-avatar-circle {
                background-color: #f5f5f5; // ok
            }
        }

        // Skeleton loaders for avatar layout
        .sp-story-skeleton-avatar {
            flex-shrink: 0;
            text-align: center;
        }

        .sp-story-avatar-ring-skeleton {
            width: 100%;
            aspect-ratio: 1 / 1;
            // height: 90px;
            margin: 0 auto 8px;
            border-radius: 50%;
            @include skeleton-shimmer;
        }

        .sp-story-avatar-circle-skeleton {
            width: 100%;
            height: 100%;
            border-radius: 50%;
        }

        .sp-story-avatar-name-skeleton {
            width: 60px;
            height: 12px;
            margin: 0 auto;
            @include skeleton-shimmer;
            border-radius: 4px;
        }

        // Viewed stories (gray ring)
        .sp-story-avatar-item.viewed {

            .sp-story-avatar-ring {
                background: #c8c8c8;
                
                &::before {
                    display: none;
                }
            }
        }

        // Navigation buttons for avatar layout
        .swiper-button-next,
        .swiper-button-prev {
            background: #fff; // ok
            justify-content: center;
            border-radius: 50%;
            width: 32px;
            height: 32px;
            padding: 0;
            top: calc(50% - calc(.75rem / 2) - calc(1.2em / 2));
            transform: translateY(-50%);
            box-shadow: 0 2px 4px rgba(#000, .1);
            
            &::after {
                font-size: 16px;
                color: var(--sp-primary-color);
            }
        }

        &:hover .swiper-button-next.swiper-button-disabled, 
        &:hover .swiper-button-prev.swiper-button-disabled {
            opacity: 0;
            visibility: hidden;
        }
    }

    > .sp-message {
        margin: 0;
    }
}

////////////////////////////////
.sp-modal {
    position: fixed;
    inset: 0;
    background: #000; // ok
    z-index: 2147483640;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem 0 0 0;

    @include small-max() {
        padding-top: 0;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    &.hidden {
        display: none;
    }

    .sp-modal-header {
        display: flex;
        align-items: center;
        padding: 1rem;
        background: transparent;
        color: $white_color;
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        z-index: 10;

        @include small-max() {
            padding: 1.5rem .5rem .5rem;
        }

        .sp-modal-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            margin-right: 0.75rem;

            @include small-max() {
                margin-right: .5rem;
            }
        }

        .sp-modal-user-info {
            flex-grow: 1;

            @include small-max() {
                max-width: calc(100% - 176px);
            }

            .sp-modal-name {
                display: block;
                font-weight: 600;

                @include small-max() {
                    @include ellipsis();
                }
            }

            .sp-modal-time {
                display: block;
                font-size: 0.875em;
                opacity: .6;

                @include small-max() {
                    @include ellipsis();
                }
            }
        }

        .sp-modal-close {
            position: absolute;
            right: 1rem;
            top: 1rem;

            @include small-max() {
                right: .5rem;
                top: 1.875rem;
            }

            &::before,
            &::after {
                background-color: $white_color;
            }
        }
    }

    .sp-modal-body {
        position: relative;
        background-color: #000; // ok
        border-radius: $radius;
        overflow: hidden;
        width: calc(100dvh * (26 / 53));
        height: calc(100dvh - 120px);

        @include small-max() {
            width: 100%;
        }

        .sp-story-indicators {
            display: flex;
            gap: 4px;
            padding: 0.5rem 1.5rem;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            z-index: 10;

            .sp-segment {
                flex: 1;
                height: 4px;
                background: rgba($white_color, 0.15);
                position: relative;
                overflow: hidden;
                border-radius: 4px;

                &::before {
                    content: '';
                    display: block;
                    height: 100%;
                    width: 0%;
                    background: $white_color;
                    transition: width 0s linear;
                    position: absolute;
                    left: 0;
                    top: 0;
                }

                &.seen::before {
                    width: 100%;
                    transition: none;
                }

                &.active::before {
                    transition: width 5s linear;
                    width: 100%;
                }
            }
        }

        .sp-story-controls {
            position: absolute;
            top: 1.5rem;
            right: 0.75rem;
            display: flex;
            gap: 0.75rem;
            z-index: 15;

            @include small-max() {
                top: 1.875rem;
                gap: .5rem;
                right: calc(.5rem + 20px + .5rem);
            }

            i[class^="sp-icon--"] {

                &::after {
                    background-color: $white_color;
                }
            }

            .item {
                position: relative;

                i {
                    cursor: pointer;
                }
            }
        }

        .story-options-dropdown {
            position: absolute;
            right: 0;
            top: 100%;
            background: $white_color;
            border-radius: 1rem;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            z-index: 1000;
            min-width: 120px;
            padding: .5rem .25rem;

            ul {
                list-style: none;
                margin: 0;
                padding: 0;

                .dropdown-item {
                    color: #4d4d4d; // ok
                    padding: 0 .5rem;
                    cursor: pointer;
                    border-radius: 1rem;
                    transition: background-color .2s ease;

                    &:hover {
                        background-color: rgba(#000, .05);
                    }

                    select {
                        background: none;
                        padding: 0;
                        border: none;
                        outline: none;
                        min-height: initial;
                        height: auto;

                        &:hover,
                        &:focus {
                            background: none;
                        }
                    }
                }
            }
        }

        &.sp-anim-next {

            .sp-modal-media {
                animation: spFlipNext 0.6s cubic-bezier(0.4, 0, 0.2, 1);
            }
        }

        &.sp-anim-prev {

            .sp-modal-media {
                animation: spFlipPrev 0.6s cubic-bezier(0.4, 0, 0.2, 1);
            }
        }
    }

    .sp-modal-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1;

        .sp-footer-avatars {
            padding: 3rem 0 0.75rem;
            width: 100%;
            max-width: 720px;
            margin-left: auto;
            margin-right: auto;

            .swiper-slide {
                visibility: hidden;
                opacity: 0;

                &.swiper-slide-visible {
                    visibility: visible;
                    opacity: 1;
                }
            }

            .sp-avatar-list {

                &.centered-mode {

                    .swiper-wrapper {
                        justify-content: center;
                    }
                }
            }

            .sp-footer-avatar {
                border: 2px solid rgba($white_color, .1);
                padding: 4px;
                border-radius: 50%;
                aspect-ratio: 100 / 100;

                img {
                    width: 100%;
                    height: 100%;
                    border-radius: 50%;
                    object-fit: cover;
                }

                &.active {
                    border-color: var(--sp-primary-color);
                }

                &::after {
                    content: attr(data-tooltip);
                    position: absolute;
                    bottom: calc(100% + 6px);
                    left: 50%;
                    transform: translateX(-50%);
                    background: var(--sp-primary-color);
                    color: $white_color;
                    font-size: 0.75rem;
                    padding: 0.25rem 0.5rem;
                    white-space: nowrap;
                    border-radius: 4px;
                    opacity: 0;
                    pointer-events: none;
                    transition: opacity 0.2s ease;
                }

                &:hover::after {
                    opacity: 1;
                }
            }

            .swiper-button-prev,
            .swiper-button-next {
                top: initial;
                bottom: 1.5rem;
                margin-top: 0;
                width: calc(44px / 44 * 27);
                height: 44px;
                color: $white_color;

                @include medium-max() {
                    display: none;
                }
            }

            .swiper-button-prev,
            .swiper-rtl .swiper-button-next {
                left: 1rem;
            }

            .swiper-button-next,
            .swiper-rtl .swiper-button-prev {
                right: 1rem;
            }
        }
    }

    .sp-modal-media {
        background: #000; // ok
        text-align: center;
        height: 100%;
        display: flex;
        align-items: center;
        position: relative;

        img,
        video {
            height: auto;
            width: 100%;
        }

        video {
            background: #000; // ok
        }

        &.fill {

            img,
            video {
                height: 100%;
                width: 100%;
                position: absolute;
                left: 0;
                right: 0;
                top: 0;
                bottom: 0;
                -o-object-fit: cover;
                object-fit: cover;
            }
        }

        &.loading,
        &.buffering {

            &::before {
                content: "";
                background-color: rgba($white_color, .1);
                position: absolute;
                left: 0;
                right: 0;
                bottom: 0;
                top: 0;
                z-index: 99;
                backdrop-filter: blur(10);
            }

            &::after {
                content: "";
                position: absolute;
                top: 50%;
                left: 50%;
                width: 40px;
                height: 40px;
                margin: -20px 0 0 -20px;
                border: 3px solid rgba($white_color, 0.3);
                border-top-color: $white_color;
                border-radius: 50%;
                animation: spin 1s linear infinite;
                z-index: 100;
            }
        }

    }

    .sp-modal-info {
        background-image: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);
        padding: 3rem 1.5rem 1rem;
        color: $white_color;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1;

        > * {
            color: $white_color;
            margin-bottom: 0;

            &:not(:last-child) {
                margin-bottom: .5rem;
            }
        }

        .sp-story-title {

            a {
                display: flex;
                gap: .5rem;
                color: inherit;

                i {
                    margin-top: 2px;

                    &::after {
                        background-color: $white_color;
                    }
                }

                &:hover,
                &:focus {
                    text-decoration: underline;
                }
            }
        }

        .sp-story-caption {
            opacity: .7;
        }
    }

    .sp-modal-media[story-type="text"] {

        + .sp-modal-info {
            background: none;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            padding: 1.5rem;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;

            .sp-story-title {

                a {
                    flex-direction: column;
                    align-items: center;

                    i {
                        order: -1;
                    }
                }
            }
        }
    }

    .sp-modal-progress {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 2;

        .story-progress {
            display: block;
            width: 0;
            height: 4px;
            border-radius: 4px;
            background: $white_color;
            transition: width 0.1s ease;
        }
    }

    .sp-modal-nav {
        position: absolute;
        top: calc(50% - 60px);
        transform: translateY(-50%);
        cursor: pointer;
        z-index: 2;
        background-color: $white_color;
        height: 40px;
        width: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10;

        &.sp-modal-prev {
            left: calc(50% - calc(calc(100dvh * (26 / 53)) / 2));
            transform: translateX(calc(-100% - 3rem));

            @include small-max() {
                left: 0;
                transform: unset;
            }
        }

        &.sp-modal-next {
            right: calc(50% - calc(calc(100dvh * (26 / 53)) / 2));
            transform: translateX(calc(100% + 3rem));

            @include small-max() {
                right: 0;
                transform: unset;
            }
        }
    }

    &.sp-story-products {

        .sp-modal-info {
            background: rgba(#000, .2); // ok
            backdrop-filter: blur(10px);
            padding: .75rem;
            padding-left: calc(50px + .75rem + .75rem);
            margin: .75rem;
            border-radius: 1rem;

            .sp-story-product-preview {
                width: 50px;
                position: absolute;
                left: .75rem;
                border-radius: .5rem;
            }

            .sp-story-title {
                font-size: 1.143em;
                margin-bottom: .25rem;

                a {
                    @include ellipsis();
                }

                i {
                    display: none;
                }
            }

            .sp-story-caption {
                font-size: .875em;
            }
        }
    }
}

.sp-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.5s ease;
    filter: blur(20px) brightness(0.7);
}

.sp-modal-backdrop.active {
    opacity: 1;
}

/* Story Upload Modal Styles */
.sp-story-upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2147483640;
    background-color: rgba(0, 0, 0, 0.75);
    color: var(--sp-text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    &.hidden,
    .hidden {
        display: none !important;
    }

    .sp-upload-container {
        background: var(--sp-modal-bg);
        width: 100%;
        max-width: 600px;
        border-radius: $radius;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .sp-upload-header {
        background-color: var(--sp-card-bg);
        padding: 1rem 2rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--sp-border-color);

        h2 {
            margin: 0;
            font-size: inherit;
        }
    }

    .sp-upload-body {
        padding: 1.5rem 2rem;

        .sp-upload-step {
            display: none;

            &.active {
                display: block;
            }

            h3 {
                margin-top: 0;
                margin-bottom: 1rem;
                font-size: 1.143em;
            }

            &.step-preview {

                h3 {
                    text-align: center;
                }
            }

            .sp-type-options {
                display: flex;
                gap: 1rem;

                button {
                    flex: 1;
                    padding: 1.5rem 1rem;
                    border: none;
                    background: var(--sp-card-bg);
                    color: inherit;
                    cursor: pointer;
                    border-radius: $radius;
                    // height: unset;
                    min-height: unset;
                    display: flex;
                    flex-direction: column;
                    justify-content: center;
                    align-items: center;
                    gap: .5rem;

                    .icon-wrapper {
                        background-color: var(--sp-primary-color);
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        height: 40px;
                        width: 40px;
                        border-radius: 50%;

                        i::after {
                            background-color: $white_color;
                        }
                    }

                    &:hover,
                    &:focus {
                        background-color: var(--sp-primary-color);
                        color: $white_color;

                        .icon-wrapper {
                            background-color: $white_color;

                            i::after {
                                background-color: var(--sp-primary-color);
                            }
                        }
                    }
                }
            }

            .sp-upload-form {
                display: flex;
                flex-direction: column;
                gap: 1rem;

                .form-group {
                    position: relative;
                }

                input[type="file"],
                input[type="text"],
                input[type="url"],
                textarea {
                    width: 100%;
                    padding: .375rem 1rem;
                    border-radius: calc(2.75rem / 2);
                }

                input[type="file"] {
                    height: 2.75rem;
                }

                textarea {
                    resize: vertical;
                }

                input[type="color"] {
                    -webkit-appearance: none;
                    -moz-appearance: none;
                    appearance: none;
                    width: 100%;
                    height: 2.75rem;
                    background-color: transparent;
                    border: none;
                    cursor: pointer;
                }

                input[type="color"]::-webkit-color-swatch {
                    border-radius: calc(2.75rem / 2);
                    border: none;
                }

                input[type="color"]::-moz-color-swatch {
                    border-radius: calc(2.75rem / 2);
                    border: none;
                }

                input[type="file"] {
                    border: 1px solid var(--sp-border-color);
                    line-height: 26px;
                    border-radius: calc(2.75rem / 2);
                    height: 2.75rem;
                    padding-left: 8px;

                    &:hover {
                        cursor: pointer;
                    }
                }

                input[type="file"]::file-selector-button {
                    background-color: var(--sp-modal-bg);
                    border: 1px solid var(--sp-primary-color);
                    color: var(--sp-primary-color);
                    border-radius: calc(2.75rem / 2);

                    &:hover {
                        cursor: pointer;
                    }
                }

                .sp-file-hint {
                    margin: 0;
                    font-size: .75em;
                    opacity: .7;
                }

                .char-counter {
                    background-color: var(--sp-modal-bg);
                    font-size: 0.875rem;
                    padding: 0 .5rem;
                    border-radius: 50%;
                    position: absolute;
                    right: 1rem;
                    top: 0;
                    transform: translateY(-50%);
                }

                .sp-story-info {
                    display: flex;
                    flex-direction: column;
                    gap: 1rem;
                }

                .sp-upload-file {
                    display: flex;
                    flex-direction: column;
                    gap: 0.5rem;
                }
            }
        }

        .step-preview {

            .sp-preview-area {
                aspect-ratio: 230 / 350;
                width: 100%;
                background: #000; // ok
                max-width: 250px;
                margin: auto;
                border-radius: $radius;
                overflow: hidden;
                position: relative;

                .preview-media {
                    height: 100%;
                    width: 100%;
                    position: relative;

                    > * {
                        height: 100%;
                        width: 100%;
                        position: absolute;
                        left: 0;
                        right: 0;
                        top: 0;
                        bottom: 0;
                        -o-object-fit: cover;
                        object-fit: cover;
                    }

                    // img, 
                    // video {}

                    &.preview-loading {

                        &::before {
                            content: "";
                            position: absolute;
                            top: 0;
                            left: 0;
                            right: 0;
                            bottom: 0;
                            background: rgba(0, 0, 0, 0.3); // ok
                            z-index: 10;
                        }

                        &::after {
                            content: "";
                            position: absolute;
                            top: 50%;
                            left: 50%;
                            width: 40px;
                            height: 40px;
                            margin: -20px 0 0 -20px;
                            border: 3px solid rgba($white_color, 0.3);
                            border-top-color: $white_color;
                            border-radius: 50%;
                            animation: spin 1s linear infinite;
                            z-index: 11;
                        }

                        @keyframes spin {
                            to {
                                transform: rotate(360deg);
                            }
                        }
                    }

                }

                .preview-info {
                    background-image: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%); // ok
                    position: absolute;
                    left: 0;
                    right: 0;
                    bottom: 0;
                    padding: 3rem 1.5rem 1rem;
                    z-index: 1;

                    > * {
                        margin-bottom: 0;
                        color: $white_color;

                        &:not(:last-child) {
                            margin-bottom: .5rem;
                        }
                    }

                    .title {

                        a {
                            color: inherit;
                            display: flex;
                            gap: .5rem;

                            i {
                                margin-top: 2px;

                                &::after {
                                    background-color: $white_color;
                                }
                            }

                            &:focus,
                            &:hover {
                                text-decoration: underline;
                            }
                        }
                    }

                    .caption {
                        opacity: .7;
                    }
                }

                &[data-type="text"] {

                    .preview-info {
                        background: none;
                        padding-top: 1.5rem;
                        top: 0;
                        bottom: 0;
                        left: 0;
                        right: 0;
                        display: flex;
                        flex-direction: column;
                        align-items: center;
                        justify-content: center;
                        text-align: center;

                        .title {

                            a {
                                display: flex;
                                flex-direction: column;
                                align-items: center;

                                i {
                                    order: -1;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    .sp-upload-footer {
        padding: 1rem;
        display: flex;
        justify-content: space-between;
        gap: 0.5rem;
        border-top: 1px solid var(--sp-border-color);

        button {
            background-color: transparent;
            padding: 0.375rem 2rem;
            border: none;
            border-radius: 30px;
            cursor: pointer;
            border: 1px solid var(--sp-primary-color);
            color: var(--sp-primary-color);
            min-width: 130px;

            &:hover,
            &:focus {
                background-color: var(--sp-primary-color);
                color: $white_color;
            }

            &:disabled {
                opacity: 0.5;
                cursor: not-allowed;
            }

            &.sp-step-submit {
                background: var(--sp-primary-color);
                border-color: var(--sp-primary-color);
                color: $white_color;

                &:hover,
                &:focus {
                    background: var(--sp-primary-color);
                    border-color: var(--sp-primary-color);
                    color: $white_color;
                }

                &.processing {
                    cursor: not-allowed;
                    -moz-animation: loader-pulsate 0.5s infinite ease-in-out alternate;
                    -webkit-animation: loader-pulsate 0.5s infinite ease-in-out alternate;
                    animation: loader-pulsate 0.5s infinite ease-in-out alternate;
                }
            }
        }
    }

    .sp-uploaded-user-stories {
        padding: 1rem 2rem;
        background: var(--sp-card-bg);
        border-top: 1px solid var(--sp-border-color);

        button.toggle-uploaded-stories {
            background: transparent;
            border: none;
            cursor: pointer;
            padding: 0;
            color: inherit;
            min-height: unset;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 1rem;
            width: 100%;
            font-weight: 600;

            .text-left {
                display: flex;
                align-items: center;
                gap: .5rem;

                .avatar {
                    width: 2em;
                }
            }

            .text-right {

                .icon-wrapper {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    height: 2em;
                    width: 2em;
                    border-radius: 50%;
                    border: 1px solid var(--sp-primary-color);

                    i::after {
                        background-color: var(--sp-primary-color);
                    }
                }
            }

            &:hover,
            &:focus {
                color: currentColor;
                background: transparent;
                border: none;

                .text-right {

                    .icon-wrapper {
                        background-color: var(--sp-primary-color);
                        transform: all .5s;

                        i::after {
                            background-color: $white_color;
                            transform: all .5s;
                        }
                    }
                }
            }
        }

        .uploaded-stories-panel {
            margin-top: 1rem;
            padding-top: 1rem;
            border-top: 1px solid var(--sp-border-color);

            ul {
                list-style: none;
                padding: 0;
                margin: 0;
                max-height: 280px;
                overflow-y: scroll;

                .sp-uploaded-story {
                    display: flex;
                    align-items: center;
                    margin-bottom: 0.75rem;
                    padding: 0.5rem;
                    background-color: var(--sp-modal-bg);
                    border-radius: 100px;
                    position: relative;

                    img {
                        width: 60px;
                        height: 60px;
                        border-radius: 50%;
                        object-fit: cover;
                        flex-shrink: 0;
                    }

                    .story-meta {
                        flex: 1;
                        padding: 0 calc(2rem + 2rem + .5rem + .75rem) 0 .75rem;

                        .story-title {
                            font-weight: 600;
                            display: -webkit-box;
                            -webkit-line-clamp: 1;
                            -webkit-box-orient: vertical;
                            text-overflow: ellipsis;
                            overflow: hidden;
                        }

                        .story-actions {
                            display: flex;
                            gap: 0.25rem;
                            position: absolute;
                            right: .5rem;
                            top: 50%;
                            transform: translateY(-50%);

                            button {
                                background: var(--sp-card-bg);
                                border: none;
                                padding: 0;
                                border-radius: 50%;
                                cursor: pointer;
                                min-height: unset;
                                height: 2rem;
                                width: 2rem;
                                display: flex;
                                align-items: center;
                                justify-content: center;

                                &:hover {

                                    i::after {
                                        background-color: var(--sp-primary-color);
                                    }
                                }
                            }
                        }
                    }

                    &.skeleton {
                        background-color: #e0e0e0; // ok
                        animation: pulse 1.5s ease-in-out infinite;
                        height: 1.25rem;
                    }
                }
            }

            &.hidden {
                display: none;
            }
        }
    }
}

.admin-bar {

    .sp-modal {
        top: 32px;

        @media screen and (max-width: 782px) {
            top: 46px;
        }

        .sp-modal-body {
            height: calc(100dvh - 120px - 32px);

            @media screen and (max-width: 782px) {
                height: calc(100dvh - 120px - 46px);
            }
        }

        .sp-modal-progress {
            top: 32px;

            @media screen and (max-width: 782px) {
                top: 46px;
            }
        }
    }
}

@keyframes spFlipNext {
    0% {
        opacity: 0;
        transform: rotateY(90deg) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: rotateY(0deg) scale(1);
    }
}

@keyframes spFlipPrev {
    0% {
        opacity: 0;
        transform: rotateY(-90deg) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: rotateY(0deg) scale(1);
    }
}
