:root {
    --primary-blue: #007bff;
    --primary-dark-blue: #000000;
    --accent-yellow: #facc15;
    --text-dark: hsl(218, 23%, 23%);
    --text-medium: #000000;
    --text-light: #718096;
    --bg-light: #f7fafc;
    --bg-container: #ffffff;
    --border-color: #e2e8f0;
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --shadow-heavy: rgba(0, 123, 255, 0.2);
    --border-radius-card: 16px;
    --border-radius-button: 25px;
    --carousel-padding: 1px;
    --carousel-gap: 20px;
    --carousel-item-min-height: 220px;
    --carousel-item-padding-top: 20px;
    --carousel-item-padding-bottom: 0px;
    --carousel-wrapper-width: 25px;
    --carousel-control-button-size: 45px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
    line-height: 1.6;
    color: var(--text-dark);
}

.rating-carousel-wrapper {
    position: relative;
}

.carousel-container {
    position: relative;
    display: flex;
    overflow: hidden;
    scroll-behavior: smooth;
    gap: var(--carousel-gap);
    padding: var(--carousel-padding);
    background: var(--bg-container);
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--shadow-medium);
    margin-bottom: 30px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    z-index: 1;
}

.carousel-item {
    flex: 0 0 auto;
    width: calc((100% - (var(--carousel-padding) * 2) - (var(--carousel-gap) * 3)) / 4);
    min-height: var(--carousel-item-min-height);
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-card);
    padding: var(--carousel-item-padding-top) 20px var(--carousel-item-padding-bottom) 20px;
    text-align: left;
    box-shadow: 0 5px 15px var(--shadow-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 1;
}

.carousel-item.hidden {
    display: none !important;
}

.carousel-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 25px var(--shadow-medium);
}

.carousel-item h5 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.carousel-item .date {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.carousel-item .rating {
    font-size: 1.2rem;
    color: var(--accent-yellow);
    margin-bottom: 12px;
    display: flex;
    gap: 2px;
    align-items: center;
}
.carousel-item .rating span {
    display: inline-block;
}

.carousel-item .comment {
    font-size: 0.95rem;
    color: var(--text-medium);
    line-height: 1.5;
    margin-bottom: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.carousel-item .read-more {
    color: var(--primary-blue);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease, text-decoration 0.2s ease;
    align-self: flex-start;
}
.carousel-item .read-more:hover {
    color: var(--primary-dark-blue);
    text-decoration: underline;
}

.rating-filters {
    text-align: center;
    margin-bottom: 24px;
    padding: 0 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.filter-btn {
    margin: 0;
    padding: 10px 22px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-button);
    background: #edf2f7;
    color: var(--text-dark);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.filter-btn.active {
    background: var(--primary-blue);
    color: #fff;
    border-color: var(--primary-blue);
    box-shadow: 0 4px 10px var(--shadow-heavy);
    transform: translateY(-2px);
}
.filter-btn:hover:not(.active):not(.disabled) {
    background: #e2e8f0;
    border-color: #cbd5e0;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.filter-btn.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background: #f7fafc;
    color: #a0aec0;
    border-color: #edf2f7;
    transform: none;
    box-shadow: none;
}

/* Base styles for navigation wrappers (shared) */
.carousel-prev-wrapper,
.carousel-next-wrapper {
    position: absolute;
    top: 0;
    bottom: 0;
    height: auto;
    transform: none;
    width: var(--carousel-wrapper-width);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--text-dark);
    opacity: 0.08;
    transition: background 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    z-index: 2;
}

/* Default LTR positioning */
.carousel-prev-wrapper {
    left: 0;
    right: auto; /* Ensure no conflict with RTL rules */
    border-top-left-radius: 20px;
    border-bottom-left-radius: 20px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
}
.carousel-next-wrapper {
    right: 0;
    left: auto; /* Ensure no conflict with RTL rules */
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
}

/* RTL Adjustments */
[dir="rtl"] .carousel-prev-wrapper {
    left: auto; /* Reset LTR left */
    right: 0; /* Move prev button to right */
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 20px; /* Adjust radius for RTL */
    border-bottom-right-radius: 20px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2); /* Adjust shadow direction */
}

[dir="rtl"] .carousel-next-wrapper {
    right: auto; /* Reset LTR right */
    left: 0; /* Move next button to left */
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 20px; /* Adjust radius for RTL */
    border-bottom-left-radius: 20px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2); /* Adjust shadow direction */
}


.carousel-prev-wrapper:hover,
.carousel-next-wrapper:hover {
    background: #fff;
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.3);
    opacity: 1;
}
.carousel-prev-wrapper:active,
.carousel-next-wrapper:active {
    background: #ffffff !important;
    opacity: 1 !important;
}

/* CSS for the icons */
.carousel-prev.prev-icon,
.carousel-next.next-icon {
    display: block;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    cursor: pointer;
    background: transparent;
    transform: none; /* Reset any previous transform */
}

/* LTR arrow direction */
.carousel-prev.prev-icon {
    border-right: 15px solid #fff; /* White arrow pointing left */
}

.carousel-next.next-icon {
    border-left: 15px solid #fff; /* White arrow pointing right */
}

/* RTL arrow direction (swap them) */
[dir="rtl"] .carousel-prev.prev-icon {
    border-right: none; /* Remove LTR border */
    border-left: 15px solid #fff; /* Make it point right (which is "previous" in RTL) */
}

[dir="rtl"] .carousel-next.next-icon {
    border-left: none; /* Remove LTR border */
    border-right: 15px solid #fff; /* Make it point left (which is "next" in RTL) */
}


/* Hover effects for the icons */
.carousel-prev-wrapper:hover .prev-icon {
    /* LTR: prev moves left, RTL: prev moves right */
    transform: translateX(calc(var(--carousel-prev-icon-hover-offset) * -1));
    border-right-color: var(--primary-blue); /* LTR */
    border-left-color: var(--primary-blue); /* RTL */
}

.carousel-next-wrapper:hover .next-icon {
    /* LTR: next moves right, RTL: next moves left */
    transform: translateX(var(--carousel-next-icon-hover-offset));
    border-left-color: var(--primary-blue); /* LTR */
    border-right-color: var(--primary-blue); /* RTL */
}

/* Define hover offsets for movement */
:root {
    --carousel-prev-icon-hover-offset: 3px;
    --carousel-next-icon-hover-offset: 3px;
}

[dir="rtl"] {
    --carousel-prev-icon-hover-offset: -3px; /* In RTL, prev moves right */
    --carousel-next-icon-hover-offset: -3px; /* In RTL, next moves left */
}


@media (max-width: 768px) {
    .carousel-container {
        gap: 16px;
        padding: 16px;
        overflow: hidden;
        scroll-snap-type: x mandatory;
    }
    .carousel-item {
        width: calc(100% - (16px * 2));
        max-width: calc(100% - (16px * 2));
        margin: 0;
        scroll-snap-align: center;
    }

    /* Mobile specific positioning */
    .carousel-prev-wrapper {
        left: 0;
        right: auto;
        border-radius: 8px 0 0 8px; /* Correct radius for left side on LTR */
        box-shadow: none;
        opacity: 0.2;
    }

    .carousel-next-wrapper {
        left: auto;
        right: 0;
        border-radius: 0 8px 8px 0; /* Correct radius for right side on LTR */
        box-shadow: none;
        opacity: 0.2;
    }

    /* Mobile RTL adjustments */
    [dir="rtl"] .carousel-prev-wrapper {
        left: auto;
        right: 0;
        border-radius: 0 8px 8px 0; /* Correct radius for right side on RTL */
    }
    [dir="rtl"] .carousel-next-wrapper {
        left: 0;
        right: auto;
        border-radius: 8px 0 0 8px; /* Correct radius for left side on RTL */
    }

    .carousel-prev-wrapper:active,
    .carousel-next-wrapper:active {
        opacity: 1 !important;
    }

    .rating-filters {
        gap: 8px;
        padding: 0 10px;
    }

    .filter-btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    .carousel-title {
        font-size: 0.9rem;
        margin-bottom: 15px;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        border-bottom: none;
        padding-bottom: 0;
    }

    .carousel-title .stars-display {
        color: var(--accent-yellow);
        font-size: 1.3rem;
    }
    .carousel-title .average-text {
        font-size: 1.3rem;
        font-weight: 600;
    }
    .carousel-title .total-count {
        font-size: 0.99rem;
        color: var(--text-medium);
        margin-left: 0;
        margin-top: 5px;
    }
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal.show {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-container);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    text-align: left;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: fadeInScale 0.3s ease-out forwards;
}
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s ease;
}
.close-modal:hover {
    color: var(--text-dark);
}

#full-comment {
    font-size: 1rem;
    color: var(--text-dark);
    line-height: 1.6;
    margin-top: 10px;
}

.carousel-title {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary-dark-blue);
    margin-bottom: 30px;
    padding: 15px 0;
    background: transparent;
    border-bottom: 2px solid var(--primary-blue);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.carousel-title .stars-display {
    color: var(--accent-yellow);
    font-size: 1.8rem;
}
.carousel-title .average-text {
    font-size: 1.8rem;
    font-weight: 600;
}
.carousel-title .total-count {
    font-size: 1.2rem;
    color: var(--text-medium);
    margin-left: 5px;
}

.reviews-summary {
    text-align: center;
    padding: 20px;
    background: var(--bg-container);
    border-radius: 12px;
    box-shadow: 0 5px 15px var(--shadow-light);
    margin-bottom: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.reviews-summary .stars {
    font-size: 1.4rem;
    color: var(--accent-yellow);
    font-weight: 400;
}
.reviews-summary .total-ratings {
    font-size: 0.9rem;
    color: var(--text-medium);
    margin-left: 5px;
}
.reviews-summary .view-reviews {
    display: inline-block;
    background: var(--primary-blue);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--border-radius-button);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s ease, transform 0.2s ease;
    margin-top: 10px;
}
.reviews-summary .view-reviews:hover {
    background: var(--primary-dark-blue);
    transform: translateY(-2px);
}
.carousel-item img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 10px;
}