/**
 * Review Images for WooCommerce - Frontend Styles
 *
 * @package ReviewImagesWC
 */

/* ==========================================================================
   Rating Breakdown
   ========================================================================== */

.riwc-rating-breakdown {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
}

.riwc-rating-summary {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.riwc-average-rating {
    flex: 0 0 auto;
    text-align: center;
    padding-right: 2rem;
    border-right: 1px solid #e5e5e5;
}

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

.riwc-average-rating .star-rating {
    font-size: 1.25rem;
    margin: 0.5rem 0;
}

.riwc-review-count {
    display: block;
    font-size: 0.875rem;
    color: #666;
}

.riwc-rating-bars {
    flex: 1;
    min-width: 200px;
}

.riwc-rating-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.riwc-rating-bar-row:hover {
    opacity: 0.8;
}

.riwc-rating-label {
    flex: 0 0 50px;
    font-size: 0.875rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 2px;
}

.riwc-star-icon {
    color: #f5a623;
}

.riwc-progress-bar {
    flex: 1;
    height: 12px;
    background: #e5e5e5;
    border-radius: 6px;
    overflow: hidden;
}

.riwc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f5a623, #ffc107);
    border-radius: 6px;
    transition: width 0.3s ease;
}

.riwc-rating-count {
    flex: 0 0 80px;
    font-size: 0.875rem;
    color: #666;
    text-align: right;
}

.riwc-count-number {
    color: #999;
}

/* ==========================================================================
   Image Upload
   ========================================================================== */

.riwc-image-upload-wrapper {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px dashed #ccc;
}

.riwc-upload-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #333;
}

.riwc-upload-hint {
    font-weight: 400;
    font-size: 0.875rem;
    color: #666;
}

.riwc-image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    min-height: 20px;
}

.riwc-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #ddd;
}

.riwc-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.riwc-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.riwc-preview-remove:hover {
    background: rgba(220, 53, 69, 0.9);
}

.riwc-preview-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.riwc-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #ddd;
    border-top-color: #333;
    border-radius: 50%;
    animation: riwc-spin 0.6s linear infinite;
}

@keyframes riwc-spin {
    to { transform: rotate(360deg); }
}

.riwc-upload-controls {
    position: relative;
}

.riwc-add-image-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #333;
    transition: all 0.2s;
}

.riwc-add-image-btn:hover {
    border-color: #999;
    background: #f5f5f5;
}

.riwc-add-image-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.riwc-icon-camera svg {
    display: block;
}

.riwc-image-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.riwc-upload-info {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: #999;
}

/* ==========================================================================
   Star Rating Field
   ========================================================================== */

.riwc-rating-field {
    margin-bottom: 1.5rem;
}

.riwc-rating-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.riwc-stars {
    display: flex;
    gap: 4px;
}

.riwc-star {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #ddd;
    transition: color 0.15s, transform 0.15s;
}

.riwc-star:hover,
.riwc-star.active {
    color: #f5a623;
}

.riwc-star:hover {
    transform: scale(1.1);
}

.riwc-stars:hover .riwc-star {
    color: #ddd;
}

.riwc-stars:hover .riwc-star:hover,
.riwc-stars:hover .riwc-star:hover ~ .riwc-star {
    color: #ddd;
}

.riwc-stars .riwc-star:hover,
.riwc-stars .riwc-star:hover ~ .riwc-star {
    color: #ddd;
}

.riwc-stars:hover .riwc-star:hover,
.riwc-stars:hover .riwc-star.hovered {
    color: #f5a623;
}

/* Fix: hover all stars up to hovered one */
.riwc-stars .riwc-star {
    color: #ddd;
}

.riwc-stars[data-rating="1"] .riwc-star:nth-child(-n+1),
.riwc-stars[data-rating="2"] .riwc-star:nth-child(-n+2),
.riwc-stars[data-rating="3"] .riwc-star:nth-child(-n+3),
.riwc-stars[data-rating="4"] .riwc-star:nth-child(-n+4),
.riwc-stars[data-rating="5"] .riwc-star:nth-child(-n+5) {
    color: #f5a623;
}

/* ==========================================================================
   Character Counter
   ========================================================================== */

.riwc-char-counter {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #999;
}

.riwc-char-counter.riwc-valid {
    color: #28a745;
}

.riwc-char-counter.riwc-invalid {
    color: #dc3545;
}

/* ==========================================================================
   Review Images Display
   ========================================================================== */

.riwc-review-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.riwc-review-image {
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e5e5e5;
    transition: transform 0.2s, box-shadow 0.2s;
}

.riwc-review-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.riwc-review-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   Verified Badge
   ========================================================================== */

.riwc-verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #28a745;
    font-weight: 500;
    margin-left: 0.5rem;
}

.riwc-verified-badge svg {
    flex-shrink: 0;
}

/* ==========================================================================
   Review Item (AJAX loaded)
   ========================================================================== */

.riwc-review {
    padding: 1.25rem;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: #fff;
}

.riwc-review-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.riwc-reviewer-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.riwc-reviewer-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.riwc-reviewer-meta {
    display: flex;
    flex-direction: column;
}

.riwc-reviewer-name {
    font-weight: 600;
    color: #333;
}

.riwc-review-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.riwc-review-rating .star-rating {
    font-size: 0.875rem;
}

.riwc-review-date {
    font-size: 0.75rem;
    color: #999;
}

.riwc-review-content {
    color: #555;
    line-height: 1.6;
}

.riwc-review-content p:last-child {
    margin-bottom: 0;
}

.riwc-no-reviews {
    text-align: center;
    padding: 2rem;
    color: #666;
    background: #f9f9f9;
    border-radius: 8px;
}

/* ==========================================================================
   Load More Button
   ========================================================================== */

.riwc-load-more {
    display: block;
    width: 100%;
    padding: 0.875rem 1.5rem;
    margin-top: 1rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #333;
    transition: all 0.2s;
}

.riwc-load-more:hover {
    border-color: #999;
    background: #f5f5f5;
}

.riwc-load-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.riwc-load-more.loading {
    pointer-events: none;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.riwc-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.riwc-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.riwc-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.riwc-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

.riwc-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.riwc-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.riwc-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.riwc-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.riwc-lightbox-prev {
    left: 1rem;
}

.riwc-lightbox-next {
    right: 1rem;
}

.riwc-lightbox-counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .riwc-rating-summary {
        flex-direction: column;
        gap: 1.5rem;
    }

    .riwc-average-rating {
        padding-right: 0;
        border-right: none;
        padding-bottom: 1.5rem;
        border-bottom: 1px solid #e5e5e5;
    }

    .riwc-rating-number {
        font-size: 2.5rem;
    }

    .riwc-preview-item {
        width: 60px;
        height: 60px;
    }

    .riwc-review-header {
        flex-direction: column;
    }

    .riwc-review-image {
        width: 50px;
        height: 50px;
    }
}
