/* ── Root Variables ── */
:root {
    --star-color: #f5a623;
    --star-empty: #d9d9d9;
    --border-color: #e8e8e8;
    --text-muted-custom: #888;
    --verified-color: #2ecc71;
    --btn-review-border: #4A90D9;
    --btn-review-color: #4A90D9;
    --submit-bg: #4A90D9;
    --submit-hover: #3578c2;
    --cancel-color: #4A90D9;
    --rating-bar-fill: #f5a623;
    --rating-bar-bg: #e8e8e8;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ── Section Wrapper ── */
.review-section {
    font-family: var(--font-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 28px 28px 12px;
    background: #fff;
    margin-bottom: 30px;
}

.review-section h4.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #222;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 14px;
}

/* ── Rating Summary ── */
.rating-summary-wrap {
    display: flex;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.rate-this-product .label {
    font-size: .9rem;
    color: #555;
    margin-bottom: 6px;
}

.star-display-empty {
    display: flex;
    gap: 4px;
}
.star-display-empty i {
    font-size: 1.4rem;
    color: var(--star-empty);
}

.btn-write-review {
    margin-top: 10px;
    border: 1.5px solid var(--btn-review-border);
    color: var(--btn-review-color);
    background: #fff;
    border-radius: 4px;
    padding: 6px 18px;
    font-size: .875rem;
    font-weight: 600;
    transition: background .2s, color .2s;
    cursor: pointer;
}
.btn-write-review:hover {
    background: var(--btn-review-color);
    color: #fff;
}

/* ── Big Score ── */
.big-score-wrap {
    text-align: center;
}
.big-score-wrap .score {
    font-size: 2.8rem;
    font-weight: 800;
    color: #222;
    line-height: 1;
}
.big-score-wrap .stars-filled {
    display: flex;
    justify-content: center;
    gap: 3px;
    margin: 4px 0 2px;
}
.big-score-wrap .stars-filled i {
    font-size: 1.1rem;
    color: var(--star-color);
}
.big-score-wrap .half-star { color: var(--star-color); }
.big-score-wrap .rating-count {
    font-size: .78rem;
    color: var(--text-muted-custom);
}

/* ── Rating Bars ── */
.rating-bars {
    flex: 1;
    min-width: 300px;
}
.rating-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}
.rating-bar-row .stars-label {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.rating-bar-row .stars-label i {
    font-size: .75rem;
    color: var(--star-color);
}
.rating-bar-row .bar-track {
    flex: 1;
    height: 8px;
    background: var(--rating-bar-bg);
    border-radius: 4px;
    overflow: hidden;
}
.rating-bar-row .bar-fill {
    height: 100%;
    background: var(--rating-bar-fill);
    border-radius: 4px;
    transition: width .6s ease;
}
.rating-bar-row .count {
    font-size: .78rem;
    color: #555;
    min-width: 24px;
    text-align: right;
}

/* ── Individual Review Card ── */
.review-card {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
}
.review-card:last-child { border-bottom: none; }

.reviewer-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    background: #ddd;
}
.reviewer-avatar-placeholder {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.reviewer-name {
    font-weight: 700;
    font-size: .92rem;
    color: #222;
}
.reviewer-date {
    font-size: .78rem;
    color: var(--text-muted-custom);
}
.review-stars i {
    font-size: .85rem;
    color: var(--star-color);
}
.review-stars .half-star { color: var(--star-color); }
.review-stars .empty-star { color: var(--star-empty); }

.verified-badge {
    font-size: .78rem;
    color: var(--verified-color);
    font-weight: 600;
}
.verified-badge i { margin-right: 3px; }

.review-body {
    font-size: .9rem;
    color: #444;
    line-height: 1.7;
    margin-top: 10px;
}
.review-image-thumb {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: opacity .2s;
}
.review-image-thumb:hover { opacity: .85; }

.helpful-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.helpful-actions .label {
    font-size: .8rem;
    color: #777;
}
.btn-helpful, .btn-not-helpful {
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    padding: 3px 12px;
    font-size: .8rem;
    cursor: pointer;
    color: #555;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    gap: 5px;
}
.btn-helpful:hover { background: #f0f7ff; border-color: #4A90D9; color: #4A90D9; }
.btn-not-helpful:hover { background: #fff5f5; border-color: #e74c3c; color: #e74c3c; }

/* ── Sort dropdown ── */
.review-sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.review-sort-wrap select {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: .82rem;
    color: #555;
    background: #fff;
    cursor: pointer;
}
.sort-icon { color: #777; font-size: .9rem; cursor: pointer; }

/* ── Modal Styles ── */
#reviewModal .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
#reviewModal .modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 18px 24px 14px;
}
#reviewModal .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #222;
}
#reviewModal .btn-close { opacity: .6; }

/* Product mini card inside modal */
.modal-product-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 18px;
}
.modal-product-img {
    width: 65px;
    height: 65px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}
.modal-product-name {
    font-weight: 700;
    font-size: .95rem;
    color: #222;
    margin-bottom: 2px;
}
.modal-product-author {
    font-size: .82rem;
    color: #666;
    margin-bottom: 4px;
}
.modal-product-stars i { font-size: .8rem; color: var(--star-color); }
.modal-product-price {
    font-size: .88rem;
    font-weight: 700;
    color: #e74c3c;
    margin-right: 6px;
}
.modal-product-old-price {
    font-size: .78rem;
    color: #999;
    text-decoration: line-through;
}

/* Star Rating Input */
.star-rating-input {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 4px 0 16px;
    flex-direction: row-reverse;
}
.star-rating-input input { display: none; }
.star-rating-input label {
    font-size: 2rem;
    color: var(--star-empty);
    cursor: pointer;
    transition: color .15s, transform .1s;
}
.star-rating-input label:hover,
.star-rating-input label:hover ~ label,
.star-rating-input input:checked ~ label {
    color: var(--star-color);
}
.star-rating-input label:hover { transform: scale(1.15); }

.modal-rate-label {
    text-align: center;
    font-size: .85rem;
    color: #666;
    margin-bottom: 6px;
}

/* Textarea */
#reviewModal textarea {
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: .88rem;
    resize: vertical;
    min-height: 110px;
    width: 100%;
    color: #333;
    transition: border-color .2s;
}
#reviewModal textarea:focus {
    border-color: var(--submit-bg);
    outline: none;
    box-shadow: 0 0 0 3px rgba(74,144,217,.12);
}

/* Upload Photo area */
.upload-photo-area {
    border: 1.5px dashed #ccc;
    border-radius: 6px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    color: #888;
    font-size: .85rem;
    transition: border-color .2s, background .2s;
    margin-top: 12px;
}
.upload-photo-area:hover {
    border-color: var(--submit-bg);
    background: #f5f9ff;
    color: var(--submit-bg);
}
.upload-photo-area i { font-size: 1.1rem; margin-right: 6px; }
#photoInput { display: none; }

/* Photo preview thumbnails */
.photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.photo-preview-item {
    position: relative;
    width: 64px;
    height: 64px;
}
.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #ddd;
}
.photo-preview-item .remove-photo {
    position: absolute;
    top: -6px; right: -6px;
    width: 18px; height: 18px;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    font-size: .65rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* Modal footer buttons */
#reviewModal .modal-footer {
    border-top: none;
    padding: 6px 24px 20px;
    gap: 12px;
}
.btn-cancel-review {
    flex: 1;
    border: 1.5px solid #ccc;
    background: #fff;
    color: var(--cancel-color);
    border-radius: 6px;
    padding: 10px;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: background .2s;
}
.btn-cancel-review:hover { background: #f5f5f5; }
.btn-submit-review {
    flex: 1;
    background: var(--submit-bg);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px;
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.btn-submit-review:hover { background: var(--submit-hover); transform: translateY(-1px); }
.btn-submit-review:active { transform: translateY(0); }

/* char counter */
.char-counter { font-size: .75rem; color: #aaa; text-align: right; margin-top: 4px; }
.char-counter.warn { color: #e74c3c; }

/* Success toast */
.review-toast {
    position: fixed;
    bottom: 24px; right: 24px;
    background: #2ecc71;
    color: #fff;
    padding: 14px 22px;
    border-radius: 8px;
    font-weight: 600;
    font-size: .9rem;
    box-shadow: 0 6px 24px rgba(46,204,113,.35);
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 10px;
}
.review-toast.show { display: flex; animation: slideUp .3s ease; }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Validation error */
.field-error { font-size: .78rem; color: #e74c3c; margin-top: 4px; display: none; }
