/* General Styles */
* {
    box-sizing: border-box;
}

.review-carousel-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 1270px;
    margin: 0 auto;
    padding: 20px 0;
    position: relative;
}

/* Container Layout */
.widget-container {
    display: flex;
    align-items: stretch;
    position: relative;
}

/* Rating Summary Tile */
.rating-summary {
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.rating-summary:hover {
    background-color: #f5f5f5;
}

.rating-summary .stats-info {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    line-height: 1.4;
}

.rating-value {
    font-size: 32px;
    font-weight: bold;
    margin: 5px 0;
}

.rating-text {
    font-size: 14px;
    margin: 5px 0;
    background: linear-gradient(90deg, #e8a87c, #d4789c, #9b59b6, #3498db, #2ecc71, #f1c40f, #e8a87c);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rainbow-shift 8s linear infinite;
}

@keyframes rainbow-shift {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

/* Star Rating */
.star-rating {
    display: inline-flex;
    gap: 2px;
    margin: 5px 0;
}

.star {
    width: 20px;
    height: 20px;
    position: relative;
    background: url("/modules/iqitreviews/views/img/star-filled.svg") no-repeat center;
    background-size: contain;
}

.star.filled {
    filter: none;
}

.star.empty {
    background: url("/modules/iqitreviews/views/img/star-empty.svg") no-repeat center;
    background-size: contain;
    filter: none;
}

.star.partial {
    position: relative;
    background: url("/modules/iqitreviews/views/img/star-empty.svg") no-repeat center;
    background-size: contain;
    filter: none;
}

.star.partial::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: var(--fill-percentage);
    height: 100%;
    background: url("/modules/iqitreviews/views/img/star-filled.svg") no-repeat left center;
    background-size: 20px 20px;
    overflow: hidden;
    z-index: 1;
}

/* Carousel Container */
.carousel-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.carousel-container:active {
    cursor: grabbing;
}

.carousel-wrapper {
    position: relative;
    padding: 0;
    overflow: visible;
}

.carousel-track {
    display: flex;
    align-items: stretch;
    transition: transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
    gap: 10px;
    will-change: transform;
}

/* Review Tiles */
.review-tile {
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

@media (min-width: 769px) {
    .review-tile {
        width: calc((100% / 3) - (20px / 3));
    }
}

.review-tile:hover {
    background-color: #f5f5f5;
}

.review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    height: 20px;
}

.review-header .star-rating {
    margin: 0;
}

.verified-badge {
    width: 20px;
    height: 20px;
    background: url("/modules/iqitreviews/views/img/verified-badge.svg") no-repeat center;
    background-size: contain;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: brightness(0) saturate(100%) invert(27%) sepia(95%) saturate(1234%) hue-rotate(192deg) brightness(97%) contrast(101%);
}

.review-meta {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
    height: 14px;
}

.review-content {
    overflow: hidden;
}

.review-title {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.review-text {
    font-size: 14px;
    line-height: 20px;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Navigation Buttons */
.nav-button {
    position: static;
    width: 40px;
    height: 40px;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 10;
    color: #333;
    outline: none;
}

.nav-button:focus {
    outline: none;
    border: none;
}

.nav-button:hover {
    color: #000;
    background: #e0e0e0;
}

.nav-button.prev {
    background: #f0f0f0;
}

.nav-button.next {
    background: #f0f0f0;
}

.nav-button.prev:hover {
    background: #e0e0e0;
}

.nav-button.next:hover {
    background: #e0e0e0;
}

/* Navigation container */
.carousel-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 16px;
}

.nav-button:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Loading spinner for nav buttons */
.nav-button.loading {
    pointer-events: none;
}

.nav-button.loading svg {
    display: none;
}

.nav-button.loading::after {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top-color: #333;
    border-radius: 50%;
    animation: nav-spinner 0.6s linear infinite;
}

@keyframes nav-spinner {
    to { transform: rotate(360deg); }
}

/* Expanded Review Modal */
.review-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 20px;
}

.review-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    position: relative;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 20px;
    max-height: calc(80vh - 140px);
    overflow-y: auto;
}

/* Review Popup Overlay */
.review-popup {
    position: absolute;
    background: white;
    border: 2px solid #0066cc;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    opacity: 1;
    pointer-events: none;
    padding: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: none;
    overflow-y: auto;
    max-height: 80vh;
}

.review-popup.active {
    pointer-events: auto;
    border-radius: 12px;
}

.review-popup-close {
    position: absolute;
    right: 15px;
    top: 15px;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    z-index: 1;
}

.review-popup-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.review-popup-meta {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
}

.review-popup-content {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.review-popup-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 16px;
}

.review-popup-footer {
    margin-top: 20px;
    text-align: left;
}

.review-popup-link {
    color: #0066cc;
    text-decoration: none;
    font-size: 14px;
}

/* Stats Popup */
.stats-popup {
    position: absolute;
    background: white;
    border: 2px solid #0066cc;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    opacity: 1;
    pointer-events: none;
    padding: 20px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: none;
    overflow-y: auto;
    max-height: 300px;
}

.stats-popup.active {
    pointer-events: auto;
    border-radius: 12px;
}

.stats-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.stats-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
}

.stats-info {
    font-size: 14px;
    color: #666;
}

.stats-link {
    color: #0066cc;
    text-decoration: none;
    font-size: 14px;
    display: inline-block;
    margin-top: 10px;
}

/* Logo */
.ts-logo {
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTAiIGN5PSIxMCIgcj0iMTAiIGZpbGw9IiMwMDY2Q0MiLz4KPHBhdGggZD0iTTYgMTBMOSAxMyAxNCA3IiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=")
        no-repeat center;
    background-size: contain;
    margin: 5px auto 0;
    display: block;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .review-carousel-widget {
        padding: 10px 5px;
    }

    .rating-summary .star-rating {
        justify-content: center;
    }

    .widget-container {
        flex-direction: row;
        overflow-x: hidden;
    }

    .carousel-container {
        position: relative;
        transition: height 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
    }

    .rating-summary {
        flex-shrink: 0;
    }

    .review-tile {
        flex: 0 0 auto;
    }

    .review-media-preview .media-preview-thumb {
        width: 100%;
        min-width: 100%;
        aspect-ratio: unset;
        height: 0;
        padding-bottom: 100%;
    }

    .review-media-preview .media-preview-thumb img,
    .review-media-preview .media-preview-thumb video {
        position: absolute;
        top: 0;
        left: 0;
    }

    .carousel-track {
        gap: 0;
    }

    .nav-button {
        width: 32px;
        height: 32px;
    }

    .carousel-container::before,
    .carousel-container::after {
        display: none;
    }

    .review-popup {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 40px);
    }

    .stats-popup {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 40px);
    }
}

/* Media Slider */
.review-media-slider {
    margin-top: auto;
    padding-top: 10px;
    width: 100%;
}

.media-slider-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding-top: 6px;
}

.media-slider-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d0d0d0;
    transition: background 0.2s;
}

.media-slider-dot.active {
    background: #333;
}

/* Media Thumbnails */
.review-media-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.review-media-preview {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border-radius: 8px;
    cursor: grab;
    user-select: none;
}

.review-media-preview.grabbing {
    cursor: grabbing;
    scroll-snap-type: none;
}

.review-media-preview::-webkit-scrollbar {
    display: none;
}

.review-media-preview .media-preview-thumb {
    position: relative;
    width: 100%;
    min-width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    scroll-snap-align: start;
    flex-shrink: 0;
}

@media (min-width: 769px) {
    .review-media-preview .media-preview-thumb {
        aspect-ratio: 3 / 4;
    }
}

.review-media-preview .media-preview-thumb:hover {
    opacity: 0.9;
}

.review-media-preview .video-play-icon .fa {
    font-size: 18px !important;
}

.review-media-preview .media-preview-thumb img,
.review-media-preview .media-preview-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #e0e0e0;
}

.review-media-preview.media-layout-all {
    overflow-x: hidden;
    scroll-snap-type: none;
    gap: 6px;
    cursor: default;
    flex-wrap: wrap;
}

.review-media-preview.media-layout-all .media-preview-thumb {
    width: 50px;
    min-width: 50px;
    height: 50px;
    aspect-ratio: 1 / 1;
    scroll-snap-align: unset;
    border-radius: 4px;
}

.media-thumbnail {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    transition: border-color 0.2s;
}

.media-thumbnail:hover {
    border-color: #0066cc;
}

.media-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-play-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 20px;
    pointer-events: none;
}

/* Reviews Details Modal */
.iqitreviews-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.iqitreviews-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.iqitreviews-modal-close {
    color: #666;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iqitreviews-modal-close:hover {
    color: #000;
}

.review-images .slick-prev,
.review-images .slick-next {
    z-index: 100;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    color: white;
    border: none;
    font-size: 16px;
}

.review-images .slick-prev:before,
.review-images .slick-next:before {
    content: none;
}

.review-images .slick-prev {
    left: 10px;
}

.review-images .slick-next {
    right: 10px;
}

@media (max-width: 768px) {
    .media-thumbnail {
        width: 50px;
        height: 50px;
    }

    .video-play-icon {
        font-size: 16px;
    }

    .iqitreviews-modal-content {
        margin: 2% auto;
        width: 95%;
        max-height: 90vh;
    }
}
