/* Enhanced WooCommerce Reviews Styles - Complete Updated Version */

/* Main reviews section */
.enhanced-reviews-section {
    margin: 15px 0;
    padding: 0;
}

/* Style Customer Reviews heading to match WooCommerce tabs */
.enhanced-reviews-section h2 {
    padding: 15px 20px;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    letter-spacing: 0.5px;
    position: relative;
    display: inline-block;
}

.enhanced-reviews-section h2::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: #fff;
}

/* Reviews container layout */
.reviews-container {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

/* Left sidebar - Reviews summary */
.reviews-summary {
    flex: 0 0 300px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 24px;
    position: sticky;
    top: 20px;
    /* Ensure it doesn't get hidden behind floating header */
    z-index: 100;
}

/* When floating header is active, adjust sticky position to avoid collision */
body.floating-header-active .reviews-summary {
    top: calc(var(--floating-header-height, 70px) + 20px);
}

.rating-overview {
    text-align: center;
}

.average-rating {
    margin-bottom: 24px;
}

.rating-number {
    font-size: 48px;
    font-weight: 700;
    color: #333;
    display: block;
    line-height: 1;
}

.stars {
    margin: 8px 0;
    font-size: 24px;
}

.star {
    color: #ddd;
    margin: 0 1px;
}

.star.full {
    color: #ffc107;
}

.star.half {
    background: linear-gradient(90deg, #ffc107 50%, #ddd 50%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.total-reviews {
    color: #666;
    font-size: 14px;
    margin-top: 4px;
}

/* Rating breakdown */
.rating-breakdown {
    margin-bottom: 24px;
}

.rating-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
}

.rating-label {
    flex: 0 0 60px;
    text-align: left;
    color: #333;
}

.rating-bar {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.rating-fill {
    height: 100%;
    background: #ffc107;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.rating-count {
    flex: 0 0 30px;
    text-align: right;
    color: #666;
    font-size: 12px;
}

/* Add review button */
.add-review-btn {
    background: #0073aa;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.3s ease;
}

.add-review-btn:hover {
    background: #005a87;
}

/* Right side - Reviews list */
.reviews-list-container {
    flex: 1;
    min-width: 0;
}

/* Filters */
.reviews-filters {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.reviews-filters label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.reviews-filters input[type="checkbox"] {
    margin: 0;
}

/* Reviews list */
.reviews-list {
    margin-bottom: 32px;
}

/* Updated review box layout */
.single-review {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    background: white;
}

.single-review:last-child {
    margin-bottom: 0;
}

/* New top row layout - single line */
.review-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 16px;
}

/* Left side - Rating and Name on same line */
.review-left-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reviewer-name {
    color: #333;
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

.review-rating {
    font-size: 16px;
}

.review-rating .star {
    font-size: 16px;
}

/* Right side - Product details, location, time on same line */
.review-right-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.review-product-details {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.review-meta-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.review-location {
    color: #888;
    background-color: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.review-time {
    color: #666;
    font-size: 14px;
    font-style: italic;
}

/* Product details */
.product-detail {
    display: inline-block;
    background-color: #e8f4f8;
    color: #555;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 8px;
    margin-bottom: 4px;
}

/* Review text */
.review-text {
    color: #333;
    line-height: 1.6;
    margin-bottom: 16px;
    font-size: 15px;
}

/* Review images */
.review-images {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.review-image-thumbnail {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.review-image-thumbnail:hover {
    border-color: #0073aa;
    transform: scale(1.05);
}

/* No reviews message */
.no-reviews {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
}

/* Pagination */
.reviews-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 0;
    border-top: 1px solid #e9ecef;
}

.page-btn {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: #333;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-btn:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 16px;
    font-size: 14px;
    color: #333;
}

#current-page {
    width: 50px;
    padding: 4px 8px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}

/* Image Modal Styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.image-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.image-modal img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.image-modal-close {
    position: absolute;
    top: 15px;
    right: 25px;
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.image-modal-close:hover {
    opacity: 0.7;
}

/* Review form container */
.review-form-container {
    margin-top: 40px;
    padding: 24px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.review-form-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

/* Loading state */
.reviews-list.loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.reviews-list.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Review form modal */
.review-form-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.review-form-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.review-form-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #666;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
}

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

.review-form-modal .review-form-container {
    padding: 30px;
    margin: 0;
    background: white;
    border: none;
    border-radius: 8px;
}

.review-form-modal .review-form-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Review Purchase Verification Popup Styles */
.review-popup {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.review-popup-content {
    background-color: white;
    margin: 10% auto;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.review-popup-header {
    padding: 20px 20px 0 20px;
    position: relative;
}

.review-popup-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    font-family: var(--font-heading, 'Inter', sans-serif);
}

.review-popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #6b7280;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.review-popup-close:hover {
    color: #374151;
}

.review-popup-body {
    padding: 15px 20px 20px 20px;
}

.review-popup-body p {
    margin: 0;
    color: #4b5563;
    line-height: 1.5;
    font-size: 16px;
    font-family: var(--font-body, 'Inter', sans-serif);
}

.review-popup-footer {
    padding: 0 20px 20px 20px;
}

.popup-button {
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-family: var(--font-body, 'Inter', sans-serif);
    width: 100%;
}

.popup-button:hover {
    background-color: #dc2626;
}

.popup-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.popup-button:active {
    background-color: #b91c1c;
}

/* Loading state for the verification check */
.add-review-btn.checking {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.add-review-btn.checking::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 16px;
    margin-top: -8px;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spinLoader 1s linear infinite;
}

@keyframes spinLoader {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Product color swatch styles */
.product-color-detail {
    display: inline-block !important;
    background: none !important;
    padding: 0 !important;
    margin-right: 8px !important;
    margin-bottom: 4px !important;
    position: relative;
    cursor: pointer;
    border: none !important;
    border-radius: 0 !important;
}

.product-color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid #ddd;
    display: inline-block;
    vertical-align: middle;
    margin-top: 0;
    margin-bottom: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    position: relative;
}

.product-color-detail:hover::before {
    content: attr(data-title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--info-box-bck, #4e4e4e);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    pointer-events: none;
}

.product-color-detail:hover::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--info-box-bck, #4e4e4e);
    margin-bottom: 1px;
    z-index: 1000;
    pointer-events: none;
}

.review-product-details .product-color-detail {
    vertical-align: middle;
}

/* ================================================
   MOBILE RESPONSIVE DESIGN - MAJOR IMPROVEMENTS
   ================================================ */

/* Mobile responsive design - breakpoint adjustments */
@media (max-width: 1024px) {
    .reviews-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .reviews-summary {
        flex: none;
        position: static;
        order: 1;
        width: 100%;
        max-width: none;
        margin-bottom: 1rem;
    }
    
    .reviews-list-container {
        order: 2;
        width: 100%;
    }
    
    /* Remove sticky positioning and floating header adjustments on mobile */
    body.floating-header-active .reviews-summary {
        top: auto;
        position: static;
    }
    
    /* Keep normal section padding on mobile */
    .enhanced-reviews-section {
        padding: 1rem;
    }
    
    .enhanced-reviews-section h2 {
        padding: 0 0 15px 0;
        margin-bottom: 1rem;
    }
}

@media (max-width: 768px) {
    /* Further mobile improvements */
    .reviews-container {
        gap: 15px;
        padding: 0;
    }
    
    .reviews-summary {
        padding: 16px;
        margin-bottom: 1rem;
        border-radius: 6px;
    }
    
    .reviews-filters {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }
    
    /* Adjust review layout for mobile */
    .review-top-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .review-right-info {
        align-items: flex-start;
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    
    .review-product-details {
        justify-content: flex-start;
        width: 100%;
    }
    
    .review-meta-info {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    
    .review-image-thumbnail {
        width: 80px;
        height: 80px;
    }
    
    .image-modal-content {
        max-width: 95%;
        max-height: 95%;
    }
    
    .image-modal-close {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
    
    .reviews-pagination {
        flex-wrap: wrap;
        gap: 4px;
        padding: 15px 0;
    }
    
    .page-info {
        margin: 8px 0;
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .page-btn {
        min-width: 32px;
        height: 32px;
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* Mobile responsive for popup */
    .review-popup-content {
        margin: 20% auto;
        width: 95%;
        max-width: 350px;
    }
    
    .review-popup-header h3 {
        font-size: 18px;
    }
    
    .review-popup-body p {
        font-size: 15px;
    }
    
    .popup-button {
        padding: 14px 24px;
        font-size: 16px;
    }
    
    .product-color-swatch {
        width: 16px;
        height: 16px;
    }
    
    .product-color-detail:hover::before {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* Improve mobile review form modal */
    .review-form-modal-content {
        margin: 10% auto;
        width: 95%;
        max-width: 500px;
    }
    
    .review-form-modal .review-form-container {
        padding: 20px;
    }
    
    .review-form-modal .review-form-container h3 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    /* Very small screens */
    .enhanced-reviews-section {
        padding: 0.5rem;
    }
    
    .enhanced-reviews-section h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .reviews-summary {
        padding: 12px;
    }
    
    .rating-number {
        font-size: 36px;
    }
    
    .stars {
        font-size: 20px;
    }
    
    .single-review {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .reviewer-name {
        font-size: 14px;
    }
    
    .review-text {
        font-size: 14px;
    }
    
    .review-image-thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .reviews-filters {
        padding: 8px;
        gap: 8px;
    }
    
    .reviews-filters label {
        font-size: 13px;
    }
}

/* ================================================
   PRINT STYLES
   ================================================ */

@media print {
    .enhanced-reviews-section {
        /* Normal spacing for print */
        margin: 15px 0;
        padding: 0;
    }
    
    .reviews-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .reviews-summary {
        position: static;
        order: 1;
        page-break-inside: avoid;
    }
    
    .reviews-list-container {
        order: 2;
    }
    
    .single-review {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
    
    .review-form-modal {
        display: none !important;
    }
    
    .add-review-btn {
        display: none;
    }
    
    .reviews-pagination {
        display: none;
    }
    
    .reviews-filters {
        display: none;
    }
}

/* ================================================
   FLOATING HEADER COLLISION FIX
   ================================================ */

/* Ensure reviews section doesn't get hidden behind floating header on mobile */
@media (max-width: 768px) {
    /* On mobile, floating header is always visible but don't push down entire section */
    body.floating-header-active .enhanced-reviews-section {
        /* Remove the excessive padding - let content flow naturally */
        padding-top: 0;
    }
    
    /* Ensure review modals appear above floating header */
    .review-form-modal {
        z-index: 10001;
    }
    
    .review-popup {
        z-index: 10001;
    }
    
    .image-modal {
        z-index: 10001;
    }
}

/* ================================================
   PERFORMANCE OPTIMIZATIONS
   ================================================ */

/* Use GPU acceleration for smooth animations */
.reviews-summary {
    will-change: transform;
    transform: translateZ(0);
}

.single-review {
    will-change: transform;
    transform: translateZ(0);
}

.review-image-thumbnail {
    will-change: transform;
    transform: translateZ(0);
}

/* Optimize for touch devices */
@media (hover: none) and (pointer: coarse) {
    .review-image-thumbnail:hover {
        transform: none;
        border-color: transparent;
    }
    
    .page-btn:hover {
        background: #f8f9fa;
        border-color: #e9ecef;
    }
    
    .add-review-btn:hover {
        background: #0073aa;
    }
}