/* ==========================================================================
   SPD Advanced Reviews - Digikala Style (Modern)
   ========================================================================== */

/* --- متغیرهای رنگی برای تغییر آسان --- */
:root {
    --spd-primary: #005e96;      /* قرمز دیجی‌کالا */
    --spd-primary-hover: #004268;
    --spd-text-dark: #3f4064;    /* رنگ متن اصلی */
    --spd-text-light: #767790;   /* رنگ متن ثانویه */
    --spd-border: #e0e0e2;       /* رنگ کادرها */
    --spd-bg-light: #f1f2f4;     /* پس‌زمینه روشن */
    --spd-star: #f9bc00;         /* رنگ ستاره */
    --spd-success-bg: #e4f8e4;   /* پس‌زمینه سبز */
    --spd-success-text: #2e7b32; /* متن سبز */
    --spd-radius: 8px;           /* انحنای استاندارد */
}

.spd-reviews-advanced {
    font-family: inherit; /* فونت قالب را به ارث می‌برد */
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    color: var(--spd-text-dark);
    max-width: 100%;
    overflow: hidden; /* جلوگیری از اسکرول افقی ناخواسته */
}

/* ==========================================================================
   1. هدر بخش نظرات (خلاصه امتیاز و دکمه ثبت)
   ========================================================================== */
.reviews-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    flex-wrap: wrap;
    gap: 15px;
}

.reviews-summary {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rating-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--spd-text-dark);
    display: flex;
    align-items: center;
    gap: 5px;
}

.rating-value .rating-star-icon {
    width: 28px;
    height: 28px;
    color: var(--spd-star);
}

.rating-details {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: var(--spd-text-light);
}

.rating-details span:first-child {
    font-weight: 700;
    color: var(--spd-text-dark);
}

/* دکمه ثبت دیدگاه در هدر */
.add-review-box {
    display: flex;
    align-items: center;
    gap: 15px;
}

.add-review-box span {
    font-size: 0.9rem;
    color: var(--spd-text-light);
}

.add-review-btn {
    background-color: transparent;
    border: 1px solid var(--spd-primary);
    color: var(--spd-primary);
    padding: 8px 20px;
    border-radius: var(--spd-radius);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.add-review-btn:hover {
    background-color: var(--spd-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 57, 78, 0.2);
}

/* ==========================================================================
   2. فرم ثبت نظر (کشویی)
   ========================================================================== */
.review-form-container {
    background-color: #fafafa;
    border: 1px solid var(--spd-border);
    border-radius: var(--spd-radius);
    padding: 24px;
    margin-bottom: 2rem;
    animation: spdFadeIn 0.3s ease;
}

.review-form-rating {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.review-form-rating label {
    font-weight: 700;
    font-size: 0.95rem;
}

.review-form-rating .stars {
    display: flex;
    flex-direction: row-reverse; /* برای چیدمان صحیح ستاره‌ها */
    gap: 4px;
    cursor: pointer;
}

.review-form-rating .star-icon svg {
    width: 28px;
    height: 28px;
    color: #e0e0e2;
    fill: #e0e0e2;
    transition: all 0.2s;
}

.review-form-rating .star-icon:hover svg,
.review-form-rating .star-icon:hover ~ .star-icon svg,
.review-form-rating .star-icon.selected svg,
.review-form-rating .star-icon.selected ~ .star-icon svg {
    color: var(--spd-star);
    fill: var(--spd-star);
}

.review-form-content {
    width: 100%;
    min-height: 120px;
    border: 1px solid var(--spd-border);
    border-radius: var(--spd-radius);
    padding: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    resize: vertical;
    transition: border-color 0.2s;
}

.review-form-content:focus {
    outline: none;
    border-color: #a1a3b5;
}

.review-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.review-form-submit-btn {
    background-color: var(--spd-primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: var(--spd-radius);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.review-form-submit-btn:hover {
    background-color: var(--spd-primary-hover);
}

.review-form-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.review-form-cancel-btn {
    background: transparent;
    border: 1px solid var(--spd-border);
    color: var(--spd-text-light);
    padding: 10px 24px;
    border-radius: var(--spd-radius);
    cursor: pointer;
}

.review-login-note {
    text-align: center;
    color: var(--spd-text-light);
}
.review-login-note a {
    color: #19bfd3; /* آبی لینک دیجی‌کالا */
    text-decoration: none;
    font-weight: 700;
}

/* ==========================================================================
   3. نوار مرتب‌سازی
   ========================================================================== */
.reviews-sort-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--spd-border);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.reviews-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--spd-text-light);
    overflow-x: auto; /* برای موبایل */
    padding-bottom: 4px; /* برای اسکرول بار */
}

.sort-links {
    display: flex;
    gap: 16px;
}

.sort-links a {
    color: var(--spd-text-light);
    text-decoration: none;
    transition: color 0.2s;
    position: relative;
    white-space: nowrap;
}

.sort-links a:hover {
    color: var(--spd-text-dark);
}

.sort-links a.active-sort {
    color: var(--spd-primary);
    font-weight: 700;
}

.sort-links a.active-sort::after {
    content: '';
    position: absolute;
    bottom: -19px; /* متصل به خط پایین */
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--spd-primary);
    border-radius: 4px 4px 0 0;
}

/* ==========================================================================
   4. لیست نظرات و آیتم‌ها
   ========================================================================== */
.reviews-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.review-item {
    border-bottom: 1px solid var(--spd-border);
    padding: 24px 0;
    transition: opacity 0.3s;
}

.review-item:last-child {
    border-bottom: none;
}

/* هدر آیتم */
.review-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.author-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.author-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--spd-text-dark);
}

.verified-badge {
    background-color: var(--spd-success-bg);
    color: var(--spd-success-text);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.review-date {
    font-size: 0.75rem;
    color: #a1a3b5;
    margin-right: auto; /* هل دادن به سمت چپ در موبایل اگر لازم بود */
    padding-right: 10px;
    border-right: 1px solid #e0e0e2;
}

.review-rating {
    background: #f1f2f4;
    padding: 2px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 14px;
    color: #3f4064;
    font-weight: 700;
}
.review-rating .star-icon {
    font-size: 12px;
    color: #e0e0e2;
}
.review-rating .star-icon.filled {
    color: var(--spd-star);
}

/* محتوای دیدگاه */
.review-content {
    margin-bottom: 16px;
    font-size: 0.95rem;
    color: var(--spd-text-dark);
    line-height: 1.8;
}

/* فوتر آیتم (رأی‌گیری) */
.review-footer {
    display: flex;
    justify-content: flex-end; /* دکمه‌ها سمت چپ */
    align-items: center;
}

.review-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-label {
    font-size: 0.8rem;
    color: var(--spd-text-light);
}

.action-btn {
    background: transparent;
    border: 1px solid var(--spd-border);
    border-radius: var(--spd-radius);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--spd-text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn .icon {
    font-size: 1.1em;
    line-height: 1;
}

.action-btn:hover {
    border-color: var(--spd-text-dark);
    color: var(--spd-text-dark);
}

.action-btn.voted {
    border-color: var(--spd-primary);
    color: var(--spd-primary);
    background-color: rgba(239, 57, 78, 0.05);
    cursor: default;
}

/* ==========================================================================
   5. صفحه‌بندی (دکمه لود بیشتر)
   ========================================================================== */
.reviews-pagination {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--spd-border);
}

.reviews-load-more-btn {
    background: transparent;
    border: none;
    color: #19bfd3; /* رنگ آبی لینک */
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    transition: color 0.2s;
}



.reviews-load-more-btn:hover {
    color: #0c9fb0;
}
.reviews-load-more-btn:disabled {
    color: var(--spd-text-light);
    cursor: wait;
}

/* ==========================================================================
   6. حالت‌های خاص (لودینگ و خالی)
   ========================================================================== */
.spd-loading, .spd-no-reviews {
    text-align: center;
    padding: 40px;
    color: var(--spd-text-light);
    font-size: 0.95rem;
}

.spd-loading::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e2;
    border-top-color: var(--spd-primary);
    border-radius: 50%;
    animation: spdSpin 1s linear infinite;
    vertical-align: middle;
    margin-left: 10px;
}

@keyframes spdSpin {
    to { transform: rotate(360deg); }
}

@keyframes spdFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   7. واکنش‌گرا (Responsive)
   ========================================================================== */
@media (max-width: 768px) {
    .reviews-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .add-review-box {
        width: 100%;
        justify-content: space-between;
        background: #f1f2f4;
        padding: 15px;
        border-radius: 8px;
    }

    .rating-value {
        font-size: 2rem;
    }

    .reviews-sort-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .sort-options {
        width: 100%;
        padding-bottom: 10px;
    }

    .review-footer {
        justify-content: flex-start;
        margin-top: 10px;
    }

    .action-label {
        display: none; /* مخفی کردن متن "آیا مفید بود" در موبایل */
    }
}