/* ====================================================
   افزونه دیدگاه‌های پیشرفته مگا - استایل‌های ساختاری
==================================================== */

.mega-comments-wrapper {
    max-width: 100%;
    margin: 0 auto;
    font-family: inherit;
    direction: rtl;
    position: relative;
}

/* ================== پاپ‌آپ لاگین و پیام‌ها ================== */
.mega-popup-overlay, .mega-global-msg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.mega-popup-box, .mega-msg-content {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    text-align: center;
}

.mega-popup-close {
    position: absolute;
    top: 10px; right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

#mega-ajax-login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

#mega-ajax-login-form input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.mega-btn-login, .mega-msg-confirm-btn {
    padding: 10px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.mega-login-msg { margin-top: 10px; font-size: 14px; }

/* ================== ساختار فرم و امتیازدهی ================== */
.mega-comment-form-box {
    margin-bottom: 40px;
}

.mega-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

/* کانتینر دربرگیرنده ستاره‌ها و میانگین */
.mega-rating-section {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* نمایش لایو میانگین امتیاز */
.mega-rating-live-avg {
    background: #f8f9fa;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    color: #555;
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #eee;
}

#mega-avg-number {
    color: #ffb800;
    font-size: 15px;
}

/* ستاره‌های امتیازدهی */
.mega-rating-stars {
    display: flex;
    flex-direction: row-reverse; /* برای راست‌چین بودن هاور در CSS */
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.mega-star {
    font-size: 24px;
    color: #ccc;
    transition: color 0.2s;
}

/* اصلاح منطق هاور و اکتیو ستاره‌ها */
.mega-rating-stars .mega-star:hover,
.mega-rating-stars .mega-star:hover ~ .mega-star,
.mega-rating-stars .mega-star.active,
.mega-rating-stars .mega-star.active ~ .mega-star {
    color: #ffb800; /* رنگ پیش‌فرض پر شده */
}

/* مخفی کردن متن وقتی کاربر رای داده است */
.mega-rating-stars[data-has-rated="true"] .mega-rating-text {
    display: none;
}

.mega-rating-text { margin-right: 10px; font-size: 14px; color: #666; }

/* ردیف‌های فرم */
.mega-user-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: stretch; /* تنظیم برای یکسان‌سازی ارتفاع */
}

.mega-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    justify-content: flex-end; /* برای تراز ماندن در صورت نمایش خطای اینلاین */
}

.mega-input-wrapper input {
    width: 100%;
    padding: 12px;
    outline: none;
    height: 100%; /* پر کردن تمام ارتفاع موجود */
    box-sizing: border-box;
}

.mega-auth-btn-wrapper {
    display: flex;
    align-items: stretch; /* هم‌تراز کردن دکمه با فیلدها */
}

.mega-auth-btn {
    padding: 12px 25px;
    border: 0 solid transparent; /* اصلاح حاشیه پیش‌فرض */
    outline: none;
    cursor: pointer;
    white-space: nowrap;
    height: 100%; /* هم‌اندازه شدن با فیلدها */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mega-textarea-wrapper {
    margin-bottom: 15px;
}

#mega-comment-content {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    resize: vertical;
    outline: none;
}

/* ردیف فوتر (دکمه و کپچا) */
.mega-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    flex-wrap: wrap;
}

.mega-submit-wrapper {
    display: flex;
    gap: 10px;
}

/* اصلاح حاشیه‌های دکمه ارسال و انصراف */
.mega-btn, .mega-btn-cancel {
    padding: 12px 30px;
    border: 0 solid transparent; /* حذف حاشیه اتوماتیک مرورگر */
    outline: none;
    box-shadow: none;
    cursor: pointer;
    transition: all 0.3s;
}

.mega-btn-cancel {
    background: #dc3232;
    color: #fff;
    border-radius: 4px;
}

/* ================== استایل‌های کپچا یک خطی ================== */
.mega-captcha-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* استفاده از important برای جلوگیری از تداخل کدهای قالب سایت */
.mega-captcha-inner {
    display: flex !important;
    align-items: center !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    gap: 10px;
}

.mega-captcha-inner label {
    margin: 0 !important;
    white-space: nowrap !important;
}

.mega-captcha-inner input {
    width: 80px !important;
    padding: 10px !important;
    text-align: center !important;
    margin: 0 !important;
}

/* غیرفعال کردن فلش‌های بالا و پایین در فیلد پاسخ کپچا */
.mega-captcha-inner input[type="number"]::-webkit-outer-spin-button,
.mega-captcha-inner input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.mega-captcha-inner input[type="number"] {
    -moz-appearance: textfield;
}

/* خطاهای بلادرنگ (اینلاین) */
.mega-inline-error {
    display: none; /* در حالت عادی مخفی است */
    padding: 5px 10px;
    font-size: 12px;
    margin-bottom: 5px;
    background: #ffebe8;
    color: #d63638;
    border-radius: 3px;
    border: 1px solid #cc1818;
}

/* خط جداکننده */
.mega-separator {
    border: 0;
    height: 1px;
    background: #eee;
    margin: 40px 0;
}

/* ================== لیست دیدگاه‌ها ================== */
.mega-comments-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-comments-list .children {
    list-style: none;
    padding: 0;
    margin-right: 40px; /* تو رفتگی دیدگاه‌های پاسخ داده شده */
    margin-top: 15px;
    border-right: 2px solid #f0f0f0;
    padding-right: 15px;
}

.mega-comment-item {
    margin-bottom: 20px;
}

.mega-comment-body {
    padding: 20px;
    position: relative;
    border: 1px solid transparent; /* برای تنظیمات المنتور */
}

/* قرار گرفتن آواتار و نام کاربر در یک خط */
.mega-comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: bold;
}

.mega-comment-avatar img {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    object-fit: cover;
    display: block;
}

/* استایل‌های مربوط به جمع شدن متن طولانی دیدگاه */
.mega-expandable-box {
    position: relative;
    margin-bottom: 15px;
}

.mega-comment-text-inner {
    overflow: hidden;
    line-height: 1.6;
    transition: max-height 0.3s ease;
}

.mega-comment-text-inner.collapsed {
    max-height: 90px;
    -webkit-mask-image: linear-gradient(180deg, #000 50%, transparent);
    mask-image: linear-gradient(180deg, #000 50%, transparent);
}

.mega-read-more-toggle {
    text-align: center;
    margin-top: 5px;
    color: #0073aa;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.3s ease;
    display: none; /* پیش‌فرض مخفی، توسط JS مدیریت می‌شود */
}

.mega-read-more-toggle:hover {
    color: #005177;
}

/* ================== فوتر دیدگاه و اکشن‌ها ================== */
.mega-comment-meta-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
    gap: 10px;
}

/* هم‌خط کردن تاریخ، وضعیت و لایک‌ها */
.mega-meta-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* تولتیپ وضعیت دیدگاه */
.mega-status-icon {
    position: relative;
    cursor: help;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mega-status-icon::after {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10;
    margin-bottom: 5px;
}

.mega-status-icon[data-tooltip="published"]::after {
    content: "منتشر شده";
}

.mega-status-icon[data-tooltip="pending"]::after {
    content: "در انتظار تایید";
}

.mega-status-icon:hover::after {
    opacity: 1;
    visibility: visible;
}

/* اکشن‌های دیدگاه (پاسخ، ویرایش) */
.mega-comment-actions {
    display: flex;
    gap: 10px;
}

.mega-action-btn,
.mega-reply-btn,
.mega-edit-btn {
    background: transparent;
    border: 1px solid #ddd;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #555;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mega-action-btn:hover,
.mega-reply-btn:hover,
.mega-edit-btn:hover {
    background: #f5f5f5;
    color: #333;
}

/* سیستم لایک و دیس‌لایک */
.mega-comment-voting {
    display: flex;
    gap: 15px;
    align-items: center;
}

.mega-vote-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mega-vote-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    padding: 0;
    transition: all 0.3s;
}

/* مخفی کردن تصاویر شکسته احتمالی در دکمه‌های رای */
.mega-vote-btn img {
    display: none !important;
}

/* استایل پیش‌فرض آیکن‌های توخالی (خطی) */
.mega-like-btn i {
    color: #28a745; /* سبز برای لایک */
}

.mega-dislike-btn i {
    color: #dc3545; /* قرمز برای دیس‌لایک */
}

/* حالت قفل شده برای رای تکراری */
.mega-vote-btn:disabled,
.mega-vote-btn.mega-voted {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ================== پاپ‌آپ تایید امتیاز ================== */
#mega-rating-confirm-popup {
    display: none; /* مدیریت نمایش با JS انجام می‌شود */
}

.mega-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}

.mega-confirm-btn-yes {
    background: #28a745;
    color: #fff;
    border: none;
    padding: 10px 25px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.mega-confirm-btn-yes:hover {
    background: #218838;
}

.mega-confirm-btn-no {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 10px 25px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.mega-confirm-btn-no:hover {
    background: #c82333;
}
/* استایل پایه برای محفظه متن دیدگاه */
.mega-comment-text-inner {
    overflow: hidden;
    transition: max-height 0.4s ease; /* انیمیشن نرم */
    position: relative;
    display: block;
}

/* حالت جمع شده */
.mega-comment-text-inner.mega-collapsed {
    max-height: 100px !important;
    /* محو کردن پایین متن */
    -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
}

/* استایل دکمه جابجایی */
.mega-read-more-toggle {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    font-weight: bold;
    color: #0073aa;
    cursor: pointer;
    user-select: none;
    transition: color 0.3s;
}

.mega-read-more-toggle:hover {
    color: #005177;
}

/* حل مشکل فاصله باکس پاسخ (مشکل شماره ۳) */
#mega-reply-form-container {
    margin-top: 30px !important;
    margin-bottom: 20px !important;
}

/* حل مشکل ستاره‌ها (مشکل شماره ۴) */
/* 1. جلوگیری از هاور و کلیک مجدد پس از ثبت رای */
.mega-rating-stars[data-has-rated="true"] {
    pointer-events: none !important;
}

/* 2. تضمین اعمال رنگ هاور (جلوگیری از غلبه استایل‌های المنتور) */
.mega-rating-stars:not([data-has-rated="true"]) .mega-star:hover,
.mega-rating-stars:not([data-has-rated="true"]) .mega-star:hover ~ .mega-star {
    color: #ffb800 !important; /* یا هر رنگ دلخواه شما برای زمان هاور */
}

.mega-wp-login-style {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.mega-wp-login-style form {
    margin-top: 20px;
}

.mega-wp-login-style .login-username,
.mega-wp-login-style .login-password {
    margin-bottom: 15px;
}

.mega-wp-login-style label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #333;
}

.mega-wp-login-style input[type="text"],
.mega-wp-login-style input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background: #fbfbfb;
}

.mega-wp-login-style .login-submit input[type="submit"] {
    width: 100%;
    padding: 10px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.3s;
}

.mega-wp-login-style .login-submit input[type="submit"]:hover {
    background: #135e96;
}

.mega-wp-login-style .login-remember {
    margin-bottom: 15px;
    font-size: 13px;
    display: flex;
    align-items: center;
}

.mega-wp-login-style .login-remember input[type="checkbox"] {
    margin-right: 5px; /* برای راست‌چین */
    margin-left: 5px;
}
