/**
 * Mad Customer Reviews Widget Styles
 * Multiple customer review cards in a flexible grid layout with repeater fields
 */

/* Main Widget Container - Grid Layout */
.mad-customer-reviews-widget {
    width: 100%;
    display: grid;
    column-gap: var(--column-gap, 30px);
    row-gap: var(--row-gap, 70px);
    grid-template-columns: repeat(var(--reviews-columns, 3), 1fr);
    grid-auto-rows: 1fr; /* Forces all rows to be equal height */
    padding: 50px 0 20px;
}

/* Individual Review Card Container */
.mad-customer-review-item {
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%; /* Take full height of grid cell */
}

/* Review Container for each item */
.mad-review-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1; /* Expand to fill available space */
}

/* Customer Photo - Floating above card - NEVER TOUCH THIS POSITION */
.mad-customer-photo {
    position: absolute;
    top: -50px; /* FIXED POSITION - DO NOT CHANGE */
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border: 4px solid #fff;
}

.mad-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    display: block;
}

/* Review Card - Base */
.mad-review-card {
    position: relative;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1; /* Expand to fill available space */
}

/* Dynamic card padding based on title presence */
.mad-has-title .mad-review-card {
    padding-top: 55px !important; /* Less padding when title present - title goes closer to photo */
}

.mad-no-title .mad-review-card {
    padding-top: 45px !important; /* Much less padding when no title - stars align with title position */
}

/* Review Title */
.mad-review-title {
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    margin-top: 10px; /* REDUCED - title closer to photo */
    line-height: 1.2;
    font-size: 24px;
    color: #333;
}

/* Hide empty titles */
.mad-review-title:empty {
    display: none;
    margin: 0;
}

/* Star Rating Container */
.mad-star-rating {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
}

/* Star Styling with Distinctive Pattern */
.mad-star {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    color: #ddd; /* Default empty star color */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

/* Filled stars get the selected color */
.mad-star.mad-star-filled {
    color: inherit; /* Will use the color set inline */
}

/* Distinctive Star Sizes - Small, Small, Large, Small, Small */
.mad-star.mad-star-small {
    font-size: 16px;
}

.mad-star.mad-star-large {
    font-size: 22px;
    margin: 0 3px;
}

/* Review Text */
.mad-review-text {
    margin: 25px 0;
    line-height: 1.6;
    font-style: italic;
    color: #666;
    position: relative;
}

.mad-review-text p {
    margin: 0;
    padding: 0;
}

/* Decorative Quotes - Target the P tag inside review text */
.mad-review-text p::before {
    content: '"';
    font-size: 1.5em;
    line-height: 1;
    font-family: Georgia, serif;
    color: #666666 !important; /* GRAY COLOR */
    font-weight: bold;
    margin-right: 3px;
    vertical-align: -0.1em;
    display: inline-block;
}

.mad-review-text p::after {
    content: '"';
    font-size: 1.5em;
    line-height: 1;
    font-family: Georgia, serif;
    color: #666666 !important; /* GRAY COLOR */
    font-weight: bold;
    margin-left: 3px;
    vertical-align: -0.1em;
    display: inline-block;
}

/* Customer Name - Signature Style */
.mad-customer-name {
    margin-top: 25px;
    font-style: italic;
    font-weight: normal;
    color: #999;
    position: relative;
}

/* Responsive Grid Layout */
@media (max-width: 1200px) {
    .mad-customer-reviews-widget {
        grid-template-columns: repeat(min(var(--reviews-columns, 3), 3), 1fr);
    }
}

@media (max-width: 768px) {
    .mad-customer-reviews-widget {
        grid-template-columns: repeat(min(var(--reviews-columns, 3), 2), 1fr);
        column-gap: calc(var(--column-gap, 30px) * 0.8);
        row-gap: calc(var(--row-gap, 70px) * 0.8);
        padding-top: 40px;
    }
    
    .mad-customer-photo {
        width: 80px !important;
        height: 80px !important;
        top: -40px;
    }
    
    .mad-review-card {
        padding-top: 65px; /* Increased for mobile */
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .mad-review-title {
        font-size: 20px;
    }
    
    .mad-star.mad-star-small {
        font-size: 14px;
    }
    
    .mad-star.mad-star-large {
        font-size: 18px;
        margin: 0 2px;
    }
    
    .mad-review-text {
        font-size: 14px;
    }
    
    .mad-customer-name {
        font-size: 16px;
    }
}

/* Equal Height Content Distribution */
.mad-review-text {
    flex: 1; /* Expand to fill available space */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center text vertically in available space */
}

.mad-customer-name {
    margin-top: auto; /* Push name to bottom of card */
}

@media (max-width: 480px) {
    .mad-customer-reviews-widget {
        grid-template-columns: 1fr; /* Force single column on mobile */
        column-gap: calc(var(--column-gap, 30px) * 0.6);
        row-gap: calc(var(--row-gap, 70px) * 0.6);
        padding-top: 35px;
    }
    
    .mad-customer-photo {
        width: 70px !important;
        height: 70px !important;
        top: -35px;
        border-width: 3px;
    }
    
    .mad-review-card {
        padding-top: 60px; /* Increased for small mobile */
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .mad-review-title {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .mad-star-rating {
        margin: 15px 0;
    }
    
    .mad-star.mad-star-small {
        font-size: 12px;
    }
    
    .mad-star.mad-star-large {
        font-size: 16px;
        margin: 0 1px;
    }
    
    .mad-review-text {
        font-size: 13px;
        margin: 20px 0;
    }
    
    .mad-customer-name {
        font-size: 14px;
        margin-top: 20px;
    }
}

/* Hover Effects for Enhanced Interactivity */
.mad-customer-review-item:hover .mad-customer-photo {
    transform: translateX(-50%) scale(1.05);
    transition: transform 0.3s ease;
}

.mad-customer-review-item:hover .mad-review-card {
    transform: translateY(-2px);
    transition: transform 0.3s ease;
}

/* Animation for stars */
.mad-star.mad-star-filled {
    animation: starGlow 2s ease-in-out;
}

@keyframes starGlow {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.1);
        filter: brightness(1.2);
    }
}

/* Ensure proper spacing in different contexts */
.panel-grid-cell .mad-customer-reviews-widget,
.so-panel .mad-customer-reviews-widget {
    margin: 20px auto;
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mad-customer-photo {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .mad-photo-img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .mad-customer-review-item:hover .mad-customer-photo,
    .mad-customer-review-item:hover .mad-review-card {
        transform: none;
    }
    
    .mad-star {
        text-shadow: none;
    }
    
    .mad-customer-reviews-widget {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
}