/**
 * Book Gallery Widget Styles - Centered Version with Infinite Loop
 * File: assets/css/elementor-css/book-gallery.css
 */

/* ===== Thumbnail Carousel ===== */
.book-gallery-wrapper {
    width: 100%;
    position: relative;
    padding: 40px 0;
}

.book-gallery-carousel {
    width: 100vw;
    position: relative;
    left: 50%;
    margin-left: -50vw;
    overflow: hidden;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.book-gallery-carousel.dragging {
    cursor: grabbing;
}

.book-gallery-track {
    display: flex;
    gap: 0;
    will-change: transform;
    transform: translateX(0); /* CHANGED: Let JS handle positioning */
    transition: transform 0.3s ease-out;
}

.book-gallery-carousel.dragging .book-gallery-track {
    transition: none;
}

.book-gallery-item {
    flex: 0 0 auto;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
    padding: 0 15px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-gallery-carousel.dragging .book-gallery-item {
    pointer-events: none;
}

.book-gallery-item:hover {
    transform: translateY(-5px);
    opacity: 0.9;
}

.book-gallery-item img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 0px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.book-gallery-item:hover img {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Navigation Arrows */
.book-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.book-gallery-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.book-gallery-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.book-gallery-prev {
    left: -20px;
}

.book-gallery-next {
    right: -20px;
}

.book-gallery-nav svg {
    width: 20px;
    height: 20px;
    stroke: #333;
    stroke-width: 2;
}

/* Navigation Dots */
.book-gallery-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
}

.book-gallery-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
}

.book-gallery-dot:hover {
    background: #bbb;
}

.book-gallery-dot.active {
    background: #333;
    width: 30px;
    border-radius: 5px;
}

/* ===== Lightbox Modal ===== */
.book-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    background: rgb(0 0 0 / 38%);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.book-lightbox-overlay.active {
    display: flex;
    opacity: 1;
}

.book-lightbox-content {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 80vh;
    width: 90vw;
    background: #fff;
    display: flex;
    gap: 20px;
    padding: 40px;
}

.book-lightbox-close {
    position: absolute;
    top: 20px;
    left: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 10;
    color: #365B5E;
    transition: transform 0.2s ease;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-lightbox-close:hover {
    transform: rotate(90deg);
}

/* Lightbox Left Side */
.book-lightbox-left {
    width: 20%;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.book-lightbox-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 390px;
    overflow-y: auto;
    padding-right: 10px;
}

.book-lightbox-thumbnails::-webkit-scrollbar {
    width: 4px;
}

.book-lightbox-thumbnails::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

.book-lightbox-thumb {
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.3s ease;
    border-radius: 0px;
    overflow: hidden;
    max-width: 80px;
}

.book-lightbox-thumb:hover,
.book-lightbox-thumb.active {
    opacity: 1;
}

.book-lightbox-thumb img {
    width: 48px;
    height: 48px;
    display: block;
    object-fit: contain;
}

.book-lightbox-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.book-lightbox-title {
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.3;
}

.book-lightbox-description {
    font-size: 16px;
    color: #666;
    line-height: 1.6;
    margin: 0;
    text-align: justify;
}

/* Lightbox Right Side */
.book-lightbox-right {
    flex: 1;
    display: flex;
    width: 80%;
}

.book-lightbox-image {
    max-height: 100%;
    width: 100%;
    object-fit: cover;
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
    .book-lightbox-content {
        flex-direction: column;
        height: auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    .book-lightbox-left {
        flex: 0 0 auto;
        width: 100%;
    }

    .book-lightbox-right {
        width: 100%;
        min-height: 400px;
    }

    .book-lightbox-thumbnails {
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding-right: 0;
        padding-bottom: 10px;
    }

    .book-lightbox-thumb {
        flex: 0 0 80px;
    }
}

@media (max-width: 768px) {
    .book-gallery-wrapper {
        padding: 30px 0;
    }

    .book-gallery-prev {
        left: -15px;
    }

    .book-gallery-next {
        right: -15px;
    }

    .book-lightbox-content {
        padding: 20px;
    }

    .book-lightbox-title {
        font-size: 22px;
    }

    .book-lightbox-description {
        font-size: 14px;
    }

    .book-lightbox-close {
        top: 10px;
        left: 10px;
    }
}

@media (max-width: 480px) {
    .book-gallery-item {
        padding: 0 8px;
    }

    .book-gallery-nav {
        width: 35px;
        height: 35px;
    }

    .book-gallery-prev {
        left: -10px;
    }

    .book-gallery-next {
        right: -10px;
    }

    .book-lightbox-content {
        padding: 15px;
        gap: 20px;
    }

    .book-lightbox-title {
        font-size: 20px;
    }

    .book-lightbox-description {
        font-size: 13px;
    }

    .book-lightbox-thumb {
        flex: 0 0 60px;
    }
}

/* RTL Support */
[dir="rtl"] .book-lightbox-close {
    left: 20px;
    right: auto;
}

[dir="rtl"] .book-gallery-prev {
    left: auto;
    right: -20px;
}

[dir="rtl"] .book-gallery-next {
    right: auto;
    left: -20px;
}

/* Prevent text selection during drag */
.book-gallery-carousel * {
    user-select: none;
    -webkit-user-drag: none;
}

/* Animation for lightbox */
@keyframes lightboxFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.book-lightbox-overlay.active .book-lightbox-content {
    animation: lightboxFadeIn 0.3s ease;
}