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

.awt-book-carousel,
.wp-block-awt-author-pro-book-carousel {
    padding: 6rem 0;
    background-color: var(--awt-book-carousel-section-bg, #{$awt-color-paper});
    position: relative;
    box-sizing: border-box;

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

    &__container {
        @include awt-container;
        position: relative;
    }

    /* Header */
    &__header {
        text-align: center;
        margin-bottom: 3.5rem;
    }

    &__subtitle {
        display: inline-block;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.15em;
        color: var(--awt-book-carousel-accent, #{$awt-color-accent});
        margin-bottom: 0.5rem;
    }

    &__title {
        font-family: $awt-font-serif;
        font-size: clamp(1.75rem, 3.5vw, 2.5rem);
        font-weight: 700;
        color: var(--awt-book-carousel-title-color, #{$awt-color-primary});
        margin: 0;
        line-height: 1.25;
    }

    /* Slider & Glide */
    &__slider {
        position: relative;
        width: 100%;
    }

    &__track {
        overflow: hidden;
    }

    &__slides {
        display: flex;
        list-style: none;
        margin: 0;
        padding: 1rem 0;
        transform-style: preserve-3d;
        touch-action: pan-y;
    }

    &__slide {
        height: auto;
        display: flex;
        flex-shrink: 0;
    }

    /* Card */
    &__card {
        background-color: var(--awt-book-carousel-card-bg, #ffffff);
        border-radius: $awt-radius-xl;
        box-shadow: $awt-shadow-sm;
        border: 1px solid #f1f5f9;
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        overflow: hidden;
        transition: transform 0.3s ease, box-shadow 0.3s ease;

        &:hover {
            transform: translateY(-4px);
            box-shadow: $awt-shadow-xl;

            .awt-book-carousel__cover-img {
                transform: scale(1.05);
            }
        }
    }

    &__cover-wrap {
        position: relative;
        padding: 1.5rem;
        background-color: #f1f5f9;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 16rem;
        overflow: hidden;
    }

    &__badge {
        position: absolute;
        top: 1rem;
        left: 1rem;
        background-color: var(--awt-book-carousel-accent, #{$awt-color-accent});
        color: #ffffff;
        font-size: 10px;
        font-weight: 700;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        z-index: 5;
    }

    &__cover-img {
        height: 12rem;
        width: auto;
        max-width: 100%;
        object-fit: contain;
        border-radius: 4px;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        transition: transform 0.5s ease;
    }

    &__cover-placeholder {
        height: 12rem;
        width: 8rem;
        background-color: #e2e8f0;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #94a3b8;
        font-size: 0.75rem;
    }

    /* Content */
    &__content {
        padding: 1.25rem;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    &__meta-top {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0.75rem;
        gap: 0.5rem;
    }

    &__category {
        font-size: 10px;
        font-weight: 700;
        color: var(--awt-book-carousel-accent, #{$awt-color-accent});
        text-transform: uppercase;
        letter-spacing: 0.1em;
        margin-top: 0.125rem;
    }

    &__pricing {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    &__badge-save {
        font-size: 10px;
        font-weight: 700;
        color: #059669;
        background-color: #ecfdf5;
        padding: 0.125rem 0.375rem;
        border-radius: 4px;
        margin-bottom: 0.25rem;
    }

    &__price-wrap {
        display: flex;
        align-items: center;
        gap: 0.375rem;
        line-height: 1;
    }

    &__price-regular {
        font-size: 0.75rem;
        color: #9ca3af;
        text-decoration: line-through;
    }

    &__price-sale,
    &__price {
        font-size: 0.875rem;
        font-weight: 700;
        color: var(--awt-book-carousel-price-color, #{$awt-color-primary});
    }

    &__book-title {
        font-family: $awt-font-serif;
        font-size: 1.125rem;
        font-weight: 700;
        margin: 0 0 0.25rem 0;
        line-height: 1.35;
    }

    &__book-title-link {
        color: var(--awt-book-carousel-title-color, #{$awt-color-primary});
        text-decoration: none;
        transition: color 0.2s ease;

        &:hover {
            color: var(--awt-book-carousel-accent, #{$awt-color-accent});
        }
    }

    /* Rating */
    &__rating {
        display: flex;
        align-items: center;
        gap: 0.375rem;
        margin-bottom: 0.5rem;
    }

    &__stars {
        display: flex;
        gap: 2px;
    }

    &__star {
        width: 12px;
        height: 12px;
        color: #d1d5db;

        &.is-awt-filled {
            color: #facc15;
        }
    }

    &__rating-count {
        font-size: 10px;
        color: #9ca3af;
        font-weight: 500;
    }

    /* Author */
    &__author {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    &__author-icon {
        width: 12px;
        height: 12px;
        color: #9ca3af;
        flex-shrink: 0;
    }

    &__author-name {
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--awt-book-carousel-author-color, #{$awt-color-secondary});
    }

    /* Excerpt */
    &__excerpt {
        font-size: 0.75rem;
        color: $awt-color-secondary;
        line-height: 1.6;
        margin: 0 0 1rem 0;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Actions */
    &__actions {
        margin-top: auto;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    &__store-links {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    &__store-btn {
        flex: 1;
        min-width: 100px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
        background-color: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        font-size: 0.75rem;
        font-weight: 700;
        color: $awt-color-primary;
        text-decoration: none;
        transition: all 0.2s ease;

        &:hover {
            background-color: #ffffff;
            border-color: #ff9900;
            color: #ff9900;
        }
    }

    &__btn-group {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }

    &__details-btn {
        flex: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.625rem;
        border: 1px solid var(--awt-book-carousel-accent, #{$awt-color-primary});
        color: var(--awt-book-carousel-accent, #{$awt-color-primary});
        text-align: center;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        border-radius: 4px;
        text-decoration: none;
        transition: all 0.2s ease;
        line-height: 1.2;

        &:hover {
            background-color: var(--awt-book-carousel-accent, #{$awt-color-primary});
            color: #ffffff;
        }
    }

    /* Controls / Floating Arrows */
    &__controls {
        position: absolute;
        top: 45%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: calc(100% + 48px);
        display: flex;
        justify-content: space-between;
        z-index: 20;
        pointer-events: none;

        @media (max-width: 768px) {
            width: 100%;
            padding: 0 0.5rem;
        }
    }

    &__arrow {
        pointer-events: auto;
        width: 46px;
        height: 46px;
        border-radius: 50%;
        background-color: var(--awt-book-carousel-arrow-bg, #ffffff);
        color: var(--awt-book-carousel-arrow-icon, #1a202c);
        border: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        padding: 0;

        svg {
            width: 20px;
            height: 20px;
        }

        &:hover {
            background-color: #1a202c;
            color: #ffffff;
            transform: scale(1.1);
        }
    }

    /* Footer */
    &__footer {
        margin-top: 3.5rem;
        text-align: center;
    }

    &__view-all {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 2rem;
        border: 1px solid var(--awt-book-carousel-title-color, currentColor);
        color: var(--awt-book-carousel-title-color, #{$awt-color-primary});
        font-weight: 700;
        font-size: 0.875rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-radius: 9999px;
        text-decoration: none;
        transition: all 0.3s ease;

        svg {
            width: 16px;
            height: 16px;
            transition: transform 0.2s ease;
        }

        &:hover {
            background-color: var(--awt-book-carousel-title-color, #{$awt-color-primary});
            color: #ffffff;

            svg {
                transform: translateX(4px);
            }
        }
    }

    &--empty {
        padding: 3rem 0;
        text-align: center;
        color: $awt-color-secondary;
    }

    /* Scoped WooCommerce Loop Button */
    .rswpbs-book-loop-btn {
        display: inline-block;
        margin: 0;
        position: relative;

        a.button {
            display: inline-flex !important;
            align-items: center;
            justify-content: center;
            gap: 6px;

            background-color: var(--awt-book-carousel-accent, #ea580c) !important;
            color: #ffffff !important;
            border: 1px solid var(--awt-book-carousel-accent, #ea580c) !important;
            border-radius: 4px !important;

            padding: 0.5rem 1rem !important;
            font-size: 0.75rem !important;
            font-weight: 700 !important;
            text-transform: capitalize;
            text-decoration: none !important;
            line-height: 1.2 !important;
            min-height: 38px;
            transition: all 0.3s ease;

            &:hover {
                filter: brightness(0.9);
                transform: translateY(-1px);
            }

            &.loading {
                opacity: 0.7;
                cursor: wait;
            }

            &::before {
                content: '';
                display: inline-block;
                width: 14px;
                height: 14px;
                background-color: currentColor;
                -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>') no-repeat center;
                mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>') no-repeat center;
            }

            &.added::before {
                -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>') no-repeat center;
                mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>') no-repeat center;
            }
        }

        a.added_to_cart.wc-forward {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 10;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: #111827;
            color: #ffffff;
            border-radius: 4px;
            font-size: 11px;
            font-weight: 700;
            text-transform: uppercase;
            text-decoration: none;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
    }
}