/* Hidden full text storage - absolutely invisible */
.review-full-text {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    user-select: none !important;
    z-index: -9999 !important;
}

/* Ensure review container doesn't have hidden overflow that might hide the span */
.review {
    position: relative; /* For the absolute positioned hidden span */
}

/* Carousel container */
.google-reviews-carousel {
    position: relative;
    padding-top: 56px; /* Space for arrows above */
    background: transparent !important;
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
}

/* FLEX container for arrows, always horizontal, top right */
.carousel-arrows-topright {
    position: absolute;
    top: 12px;
    right: 24px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    z-index: 200;
}

/* Arrow circle styling */
.carousel-arrow {
    width: 44px;
    height: 44px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    opacity: 0.95;
    user-select: none;
}
.carousel-arrow:hover {
    background: #f0f4fa;
    box-shadow: 0 4px 16px rgba(30, 34, 45, 0.18);
}
.carousel-arrow svg {
    display: block;
    margin: 0 auto;
    pointer-events: none;
}

/* Reviews flex row - CRITICAL: align-items must be flex-start */
.reviews-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    overflow-y: visible !important; /* Allow vertical overflow */
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding: 0 24px 40px 24px; /* Increased bottom padding for expanded cards */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;     /* Firefox */
    align-items: flex-start !important; /* CRITICAL: Cards align to top, can grow down */
    min-height: auto !important;
    max-height: none !important;
    height: auto !important;
}
.reviews-container::-webkit-scrollbar {
    display: none;  /* Chrome, Safari, Opera */
}

/* Individual review card - Aggressive height removal */
.review {
    flex: 0 0 280px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(30, 34, 45, 0.07);
    padding: 22px 20px 18px 20px;
    display: block !important;
    scroll-snap-align: start;
    transition: box-shadow 0.2s;
    /* AGGRESSIVE HEIGHT FIXES */
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    max-height: unset !important;
    overflow: visible !important;
    align-self: flex-start !important; /* Cards stick to top */
    position: relative;
    contain: layout style; /* Prevent layout interference */
}
.review:hover {
    box-shadow: 0 8px 24px rgba(30, 34, 45, 0.12);
}

/* Reviewer info row */
.review-header {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

/* Profile photo or fallback initials */
.google-reviews-carousel .review-header .profile-photo,
.google-reviews-carousel .review-header img.profile-photo {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    object-fit: cover;
    margin-right: 12px;
    background: #f59e42;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1em;
    border: 2px solid #ececec !important;
    max-width: none !important;
    box-shadow: none !important;
}

/* Name, checkmark, Google icon, and date */
.author-details {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.author-row {
    display: flex;
    align-items: center;
    gap: 5px;
}
.author-name {
    font-weight: 600;
    color: #222;
    font-size: 1.07em;
    margin: 0;
}
.author-name a {
    color: inherit;
    text-decoration: none;
}
.author-name a:hover {
    text-decoration: underline;
}
.verified {
    color: #3b82f6;
    font-size: 1.1em;
    margin-left: 2px;
    vertical-align: middle;
}
.google-icon {
    width: 17px;
    height: 17px;
    margin-left: 2px;
    vertical-align: middle;
    display: inline-block;
}
.google-icon svg {
    width: 17px;
    height: 17px;
    display: block;
}
.review-date {
    color: #888;
    font-size: 0.97em;
    margin-top: 1px;
}

/* Star rating row */
.rating {
    display: flex;
    align-items: center;
    margin: 8px 0 7px 0;
    font-size: 1.09em;
    gap: 2px;
}
.rating .star {
    font-size: 1.18em;
    color: #fbbc04;
}
.rating .star.empty {
    color: #e0e0e0;
}

/* Review text - Fixed expansion handling */
.review-text {
    color: #222;
    font-size: 1.06em;
    margin-bottom: 7px;
    line-height: 1.5;
    word-break: break-word;
    width: 100%;
    transition: all 0.3s ease;
    position: relative; /* For proper height calculation */
    display: block !important; /* Ensure block display */
}

/* Collapsed state - Line clamping */
.review-text.collapsed {
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important; /* 3 lines for better preview */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    max-height: 4.5em !important; /* 3 lines * 1.5 line-height */
    text-overflow: ellipsis !important;
}

/* Expanded state - AGGRESSIVE full display */
.review-text:not(.collapsed) {
    display: block !important;
    -webkit-line-clamp: unset !important;
    -webkit-box-orient: initial !important;
    overflow: visible !important;
    max-height: none !important;
    max-height: unset !important;
    max-height: 9999px !important; /* Fallback for stubborn themes */
    height: auto !important;
    min-height: auto !important;
    white-space: normal !important; /* Ensure text wraps */
    text-overflow: initial !important;
}

/* Extra specificity for expanded text */
.google-reviews-carousel .review.expanded .review-text {
    display: block !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    -webkit-line-clamp: unset !important;
}

/* Override any theme/plugin max-height constraints */
.google-reviews-carousel .review,
.google-reviews-carousel .review * {
    max-height: none !important;
    max-height: unset !important;
}
.google-reviews-carousel .review.expanded,
.google-reviews-carousel .review:has(.review-text:not(.collapsed)) {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
}

/* Read more link */
.more-link {
    color: #3b82f6;
    font-weight: 500;
    font-size: 0.98em;
    cursor: pointer;
    text-decoration: none;
    margin-top: 2px;
    display: inline-block;
    transition: opacity 0.2s;
}
.more-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .review { 
        flex: 0 0 70vw; 
    }
    .carousel-arrows-topright { 
        right: 12px; 
    }
    .reviews-container {
        padding-bottom: 30px; /* More padding on mobile for expanded cards */
    }
}

@media (max-width: 480px) {
    .review { 
        flex: 0 0 85vw; /* Slightly smaller for better mobile view */
    }
    .carousel-arrows-topright { 
        right: 6px; 
    }
    
    /* Ensure profile photos remain circular on small screens */
    .google-reviews-carousel .review-header .profile-photo,
    .google-reviews-carousel .review-header img.profile-photo {
        width: 36px !important;
        height: 36px !important;
        font-size: 1em;
    }
}

/* ULTIMATE OVERRIDE SECTION - Place at the end to override everything */
.google-reviews-carousel,
.google-reviews-carousel * {
    max-height: none !important;
    max-height: unset !important;
}

/* Specific overrides for expanded state */
.google-reviews-carousel .review.expanded {
    height: auto !important;
    max-height: none !important;
    max-height: unset !important;
    max-height: 9999px !important;
    overflow: visible !important;
}

/* Nuclear option for stubborn themes - using :where for lower specificity if needed elsewhere */
:where(.google-reviews-carousel) :where(.review) {
    contain: none !important;
    max-height: none !important;
}

/* If your theme uses specific selectors, add them here */
body .google-reviews-carousel .reviews-container {
    height: auto !important;
    max-height: none !important;
    align-items: flex-start !important;
}

body .google-reviews-carousel .review {
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
}