/* 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;
}

/* Desktop-only rating summary */
@media (min-width: 769px) {
    .desktop-rating-summary {
        flex-shrink: 0;
        width: 140px;
    }

    .carousel-container {
        margin-left: 0;
    }
}

/* Rating Summary Tile */
.rating-summary {
    flex-shrink: 0;
    width: 140px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

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

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

.rating-text {
    font-size: 14px;
    color: #333;
    margin: 5px 0;
}

/* 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;
    margin-left: 10px;
}

.carousel-wrapper {
    position: relative;
    padding: 0 50px;
}

.carousel-track {
    display: flex;
    transition: transform 0.3s ease;
    gap: 10px;
}

/* Review Tiles */
.review-tile {
    flex: 0 0 calc((100% - 20px) / 3);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
}

.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: 18px;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 54px;
}

.read-more {
    color: #0066cc !important;
    font-size: 12px;
    margin-top: 6px;
    display: inline-block;
    text-decoration: none;
}

/* Navigation Buttons */
.nav-button {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50px;
    background: linear-gradient(to right, rgba(248, 248, 248, 0.9), rgba(248, 248, 248, 0.3));
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    color: #333;
    outline: none;
}

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

.nav-button:hover {
    color: #000;
    background: linear-gradient(to right, rgba(248, 248, 248, 0.95), rgba(248, 248, 248, 0.5));
}

.nav-button.prev {
    left: 145px;
    background: white;
}

.nav-button.next {
    right: 0;
    background: linear-gradient(to left, rgba(248, 248, 248, 0.9), rgba(248, 248, 248, 0.3));
}

.nav-button.prev:hover {
    background: white;
}

.nav-button.next:hover {
    background: linear-gradient(to left, rgba(248, 248, 248, 0.95), rgba(248, 248, 248, 0.5));
}

.nav-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 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.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    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.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    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 {
        margin-left: 36px;
        position: relative;
    }

    .rating-summary {
        width: calc(100vw - 100px);
        max-width: calc(100vw - 100px);
        flex-shrink: 0;
    }

    .carousel-wrapper {
        padding: 0;
    }

    .review-tile {
        flex: 0 0 calc(100vw - 100px);
        max-width: calc(100vw - 100px);
    }

    .carousel-track {
        gap: 10px;
    }

    .nav-button {
        width: 36px;
        top: 0;
        bottom: 0;
        height: auto;
        padding: 0;
    }

    .nav-button.prev {
        left: 0;
    }

    .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 Thumbnails */
.review-media-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.review-media-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
    pointer-events: none;
}

.review-media-preview .media-preview-thumb {
    position: relative;
    width: 25px;
    height: 25px;
    overflow: hidden;
    background: #f5f5f5;
}

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

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

.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;
    }
}
