/**
 * ══════════════════════════════════════════════════════════════
 * استایل بخش نظرات و امتیازدهی
 * ══════════════════════════════════════════════════════════════
 */

.comments-section {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ────────────────────────────────────────────────────────────── */
/* هدر بخش نظرات */
/* ────────────────────────────────────────────────────────────── */

.comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.comments-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

.comments-icon {
    color: #3b82f6;
}

.comments-count {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    background: #eff6ff;
    color: #3b82f6;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

/* ────────────────────────────────────────────────────────────── */
/* خلاصه امتیازها */
/* ────────────────────────────────────────────────────────────── */

.rating-summary {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 32px;
    margin-bottom: 32px;
    padding: 24px;
    background: linear-gradient(135deg, #fef3c7 0%, #fef9c3 100%);
    border-radius: 12px;
}

.rating-overview {
    display: flex;
    gap: 48px;
}

.rating-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.rating-number {
    font-size: 48px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.rating-stars-display {
    display: flex;
    gap: 4px;
}

.rating-stars-display .star {
    color: #fbbf24;
}

.rating-stars-display .star-filled {
    fill: #fbbf24;
}

.rating-stars-display .star-half {
    fill: url(#half-fill);
}

.rating-stars-display .star-empty {
    fill: none;
    stroke: #fbbf24;
}

.rating-count {
    font-size: 14px;
    color: #666;
}

/* نمودار توزیع امتیازات */
.rating-distribution {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.rating-bar-item {
    display: grid;
    grid-template-columns: 70px 1fr 40px;
    align-items: center;
    gap: 12px;
}

.rating-bar-label {
    font-size: 14px;
    color: #666;
    text-align: left;
}

.rating-bar-track {
    height: 8px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    overflow: hidden;
}

.rating-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.rating-bar-count {
    font-size: 13px;
    color: #666;
    text-align: center;
    font-weight: 500;
}

/* دکمه ثبت نظر */
.add-comment-cta {
    display: flex;
    align-items: center;
}

.btn-add-comment,
.btn-login-required {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* ────────────────────────────────────────────────────────────── */
/* فرم ثبت نظر */
/* ────────────────────────────────────────────────────────────── */

.comment-form-container {
    margin-bottom: 32px;
    padding: 24px;
    background: #f9fafb;
    border-radius: 12px;
    border: 2px dashed #d1d5db;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.form-label.required::after {
    content: " *";
    color: #ef4444;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-family: Vazirmatn, sans-serif;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: #fff;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.char-counter {
    align-self: flex-end;
    font-size: 13px;
    color: #6b7280;
}

.form-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}

.form-hint svg {
    color: #3b82f6;
}

/* ورودی امتیازدهی با ستاره */
/* ورودی امتیازدهی با ستاره */
.rating-input-group {
    align-items: flex-start;
}

.rating-input {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 8px;
}

.rating-input input[type="radio"] {
    display: none;
}

.star-label {
    cursor: pointer;
    transition: transform 0.15s ease;
}

.star-label:hover {
    transform: scale(1.15);
}

.star-label .star-icon {
    fill: #e5e7eb;
    transition: fill 0.2s ease;
}

/* هایلایت ستاره‌ها هنگام hover و انتخاب */
.star-label.active .star-icon {
    fill: #fbbf24;
}

/*
 * منطق CSS-only برای هایلایت معکوس (RTL):
 * چون flex-direction: row-reverse است، وقتی روی یک ستاره hover می‌شود،
 * ستاره‌های بعدی (که در DOM قبل‌تر هستند) باید روشن شوند.
 */
.rating-input label.active .star-icon {
    fill: #fbbf24;
}

.rating-hint {
    margin-top: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #f59e0b;
    min-height: 20px;
}

/* چک‌باکس */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #3b82f6;
    cursor: pointer;
}

.checkbox-text {
    font-size: 14px;
    color: #374151;
}

/* دکمه‌های فرم */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn-submit,
.btn-cancel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: Vazirmatn, sans-serif;
    border-radius: 10px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.btn-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* اسپینر لودینگ */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ────────────────────────────────────────────────────────────── */
/* لیست نظرات */
/* ────────────────────────────────────────────────────────────── */

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.comment-card {
    padding: 24px;
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    transition: box-shadow 0.2s ease;
}

.comment-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.comment-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}

.comment-author {
    display: flex;
    align-items: center;
    gap: 12px;
}

.author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    flex-shrink: 0;
}

.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.author-name-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.author-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
}

.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #ecfdf5;
    color: #059669;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.verified-badge svg {
    fill: #059669;
}

.comment-date {
    font-size: 13px;
    color: #9ca3af;
}

/* امتیاز نظر */
.comment-rating {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.comment-rating .star {
    width: 16px;
    height: 16px;
}

.comment-rating .star-filled {
    fill: #fbbf24;
}

.comment-rating .star-empty {
    fill: #e5e7eb;
}

/* بدنه نظر */
.comment-body {
    margin-bottom: 16px;
}

.comment-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px;
}

.comment-text {
    font-size: 15px;
    line-height: 1.7;
    color: #4b5563;
    margin: 0;
}

/* فوتر نظر */
.comment-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid #f5f5f5;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: Vazirmatn, sans-serif;
    color: #6b7280;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.like-btn:hover:not(:disabled) {
    color: #059669;
    border-color: #059669;
}

.dislike-btn:hover:not(:disabled) {
    color: #dc2626;
    border-color: #dc2626;
}

.report-btn {
    margin-inline-start: auto;
}

.report-btn:hover:not(:disabled) {
    color: #f59e0b;
    border-color: #f59e0b;
}

/* ────────────────────────────────────────────────────────────── */
/* حالت خالی */
/* ────────────────────────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    color: #d1d5db;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 18px;
    font-weight: 700;
    color: #374151;
    margin: 0 0 8px;
}

.empty-text {
    font-size: 14px;
    color: #9ca3af;
    margin: 0;
    max-width: 320px;
}

/* دکمه بارگذاری بیشتر */
.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.btn-load-more {
    padding: 12px 32px;
    font-size: 14px;
    font-weight: 600;
    font-family: Vazirmatn, sans-serif;
    border-radius: 10px;
}

/* ────────────────────────────────────────────────────────────── */
/* واکنش‌گرا (موبایل) */
/* ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .comments-section {
        padding: 20px;
    }

    .rating-summary {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .rating-overview {
        flex-direction: column;
        gap: 24px;
        align-items: center;
    }

    .comments-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .comment-header {
        flex-direction: column;
    }

    .comment-rating {
        align-self: flex-start;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-submit,
    .btn-cancel {
        width: 100%;
        justify-content: center;
    }
}
