/* ==================== Chat Styles ==================== */
/* پس‌زمینه صفحه چت */
.chat-room-bg {
    background-color: transparent;
    background-image: none;
}
html.dark .chat-room-bg {
    background-color: transparent;
    background-image: none;
}
/* پیام‌ها */
.chat-bubble {
    max-width: 75%;
    padding: 0.6rem 0.9rem;
    border-radius: 1.2rem !important;
    position: relative;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 0.9rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.chat-bubble.sent {
    border-bottom-right-radius: 0.25rem !important;
    background-color: #e9d5ff;
    margin-left: auto;
    margin-right: 0.5rem;
}
html.dark .chat-bubble.sent {
    background-color: #4c1d95;
    color: #f3f4f6;
}
.chat-bubble.received {
    border-bottom-left-radius: 0.25rem !important;
    background-color: #ffffff;
    margin-right: auto;
    margin-left: 0.5rem;
    border: 1px solid #e5e7eb;
}
html.dark .chat-bubble.received {
    background-color: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

/* اسم فرستنده */
.chat-sender-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: #8b5cf6;
    margin-bottom: 0.2rem;
}
html.dark .chat-sender-name {
    color: #c4b5fd;
}

/* تصویر / استیکر در پیام */
.chat-bubble img {
    max-width: 220px;
    border-radius: 0.75rem;
    margin-top: 0.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.chat-bubble img:hover {
    transform: scale(1.02);
}
.sticker-bubble {
    background: transparent !important;
    max-width: 140px;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
}
.sticker-bubble img {
    max-width: 100%;
}

/* زمان پیام */
.message-meta {
    font-size: 0.6rem;
    color: #9ca3af;
    margin-top: 0.25rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.3rem;
    direction: ltr;
}
.message-meta svg {
    width: 12px;
    height: 12px;
}

/* اسکرول سفارشی بخش پیام‌ها */
#chat-messages {
    scroll-behavior: smooth;
}

/* نوار ورودی */
.chat-input-area {
    position: sticky;
    bottom: 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(229,231,235,0.6);
    padding: 0.75rem 1rem;
    margin: 0;
}
html.dark .chat-input-area {
    background: rgba(17,24,39,0.85);
    border-color: rgba(55,65,81,0.6);
}

.chat-input-area textarea {
    background: #f3f4f6;
    border-radius: 1.5rem;
    padding: 0.6rem 1rem;
    transition: all 0.2s;
}
html.dark .chat-input-area textarea {
    background: #374151;
    color: #f9fafb;
}
.chat-input-area textarea:focus {
    background: #fff;
    box-shadow: 0 0 0 2px #8b5cf6;
}
html.dark .chat-input-area textarea:focus {
    background: #1f2937;
}

/* دکمه‌های کنار ورودی */
.chat-input-area button {
    transition: all 0.2s;
}
.chat-input-area button:hover {
    transform: scale(1.1);
}

/* دکمه ضبط صدا */
#voice-record-btn.recording {
    animation: pulse-red 1s infinite;
}
@keyframes pulse-red {
    0%, 100% { background-color: rgba(239,68,68,0.1); }
    50% { background-color: rgba(239,68,68,0.3); }
}

/* تصاویر در مودال (برای بزرگ‌نمایی) */
.clickable-media {
    cursor: pointer;
    transition: opacity 0.2s;
}
.clickable-media:hover {
    opacity: 0.9;
}

/* بلاک حاوی آواتار و حباب */
.message-row {
    max-width: 85%;
}

/* حباب ویس فضای کامل را بگیرد */
.voice-bubble {
    max-width: 90% !important;
}

/* پلیر صوتی داخل حباب */
.voice-player {
    width: 100% !important;
    min-width: 180px;
    height: 40px;
    display: block;
    box-sizing: border-box;
}

/* چسباندن آواتار به پایین */
.chat-avatar-bottom {
    align-self: flex-end !important;
}
/* placeholder تصویر */
.message-image-placeholder {
    transition: background 0.2s;
    user-select: none;
}
.message-image-placeholder:hover {
    background-color: #e5e7eb;
}
html.dark .message-image-placeholder:hover {
    background-color: #374151;
}

/* ==================== Action Sheet Styles ==================== */

/* مخفی کردن دکمه‌های شناور قدیمی */
.message-actions {
    display: none !important;
}

/* Overlay (پس‌زمینه تیره) */
.chat-action-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.chat-action-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Bottom Sheet (منوی شیشه‌ای) */
.chat-action-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top-left-radius: 2rem;
    border-top-right-radius: 2rem;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 1rem 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-bottom: none;
}
html.dark .chat-action-sheet {
    background: rgba(17, 24, 39, 0.8);
    border-color: rgba(55, 65, 81, 0.6);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
}
.chat-action-sheet.active {
    transform: translateY(0);
}

/* Handle bar (نشانگر کشیدن) */
.action-handle {
    width: 40px;
    height: 5px;
    background-color: #d1d5db;
    border-radius: 1rem;
    margin: 0 auto 1rem;
}
html.dark .action-handle {
    background-color: #6b7280;
}

/* دکمه‌های Action */
.action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1f2937;
    transition: all 0.2s;
    border: 1px solid rgba(229, 231, 235, 0.8);
    cursor: pointer;
    box-sizing: border-box;
}
html.dark .action-btn {
    background: rgba(55, 65, 81, 0.6);
    color: #f3f4f6;
    border-color: rgba(75, 85, 99, 0.8);
}
.action-btn:hover {
    background: #f3f4f6;
    transform: scale(1.02);
}
html.dark .action-btn:hover {
    background: #374151;
}
.action-btn svg {
    width: 1.4rem;
    height: 1.4rem;
    flex-shrink: 0;
}

/* دکمه لغو */
.action-cancel-btn {
    width: 100%;
    padding: 0.9rem;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-radius: 1rem;
    font-weight: 700;
    text-align: center;
    margin-top: 0.5rem;
    cursor: pointer;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
html.dark .action-cancel-btn {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}
/* جداکننده تاریخ در چت */
.chat-date-separator {
    position: relative;
    z-index: 2;
}

.chat-date-separator > div {
    border: 1px solid rgba(0, 0, 0, 0.05);
}

html.dark .chat-date-separator > div {
    border: 1px solid rgba(255, 255, 255, 0.05);
}
/* دکمه حذف در Action Sheet */
.action-delete-btn span {
    color: #ef4444 !important; /* red-500 */
}

.action-delete-btn:hover {
    background-color: rgba(239, 68, 68, 0.1) !important;
}

html.dark .action-delete-btn:hover {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

.action-delete-btn svg {
    color: #ef4444 !important;
}
#action-copy-btn svg {
    color: #6366f1; /* indigo */
}
#action-copy-btn:hover {
    background-color: rgba(99, 102, 241, 0.1);
}
/* ==================== Pinned Messages ==================== */
#pinned-messages {
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    background: rgba(250, 245, 255, 0.7);
    padding: 0.4rem 1rem;                 /* کمی padding راست/چپ برای تنفس */
    overflow-x: hidden;                   /* جلوگیری از اسکرول افقی */
    box-sizing: border-box;
    width: 100%;
}
html.dark #pinned-messages {
    background: rgba(88, 28, 135, 0.15);
    border-color: rgba(139, 92, 246, 0.3);
}

.pinned-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.25rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(139, 92, 246, 0.15);
    max-width: 100%;
    box-sizing: border-box;
}
html.dark .pinned-item {
    background: rgba(55, 65, 81, 0.5);
    border-color: rgba(139, 92, 246, 0.3);
}
.pinned-item:hover {
    background: rgba(139, 92, 246, 0.08);
}

.pinned-item-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;                        /* اجازه کوچک‌شدن به فرزند flex */
    flex: 1;
    overflow: hidden;                    /* محتوا بیش از حد مخفی شود */
}

.pinned-icon {
    width: 1.1rem;
    height: 1.1rem;
    color: #8b5cf6;
    flex-shrink: 0;
}
html.dark .pinned-icon {
    color: #c4b5fd;
}

.pinned-text {
    display: flex;
    flex-direction: column;
    min-width: 0;                        /* مهم: جلوگیری از گسترش بی‌رویه */
    flex: 1;
    overflow: hidden;
}

.pinned-sender {
    font-weight: 700;
    font-size: 0.7rem;
    color: #7c3aed;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
html.dark .pinned-sender {
    color: #c4b5fd;
}

.pinned-preview {
    font-size: 0.7rem;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
html.dark .pinned-preview {
    color: #d1d5db;
}

.pinned-remove-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 0.4rem;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    flex-shrink: 0;
}
.pinned-item:hover .pinned-remove-btn {
    opacity: 1;
}
.pinned-remove-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}
/* تنظیمات نمایش پیام‌های پین‌شده در موبایل */
#pinned-messages {
    padding: 0.2rem 0.5rem;          /* فضای خیلی کمتر */
}

.pinned-item {
    padding: 0.25rem 0.5rem;         /* حاشیه‌ی داخلی کمتر */
    margin-bottom: 0.15rem;          /* فاصله بین آیتم‌ها */
}

.pinned-icon {
    width: 0.9rem;                   /* آیکون کوچکتر */
    height: 0.9rem;
}

.pinned-sender {
    font-size: 0.65rem;              /* اسم فرستنده کوچکتر */
}

.pinned-preview {
    font-size: 0.65rem;              /* پیش‌نمایش کوچکتر */
}
/* فشرده‌سازی input های صفحه auth */
#login-form .input-field,
#register-form .input-field {
    padding: 0.55rem 0.85rem !important;
    font-size: 0.875rem !important;
}

/* کاهش فاصله بین تب‌ها و فرم */
#login-form,
#register-form {
    margin-top: 0.5rem !important;
}

/* کوچک‌تر کردن تب‌های ورود/ثبت‌نام */
.auth-tab-btn {
    padding: 0.45rem 1rem !important;
    font-size: 0.8rem !important;
}

/* کاهش فاصله تب‌ها از بالا */
.mentor-card .flex.justify-center.mb-8 {
    margin-bottom: 0.75rem !important;
}
/* ==================== تب‌های ورود/ثبت‌نام بازطراحی شده ==================== */

/* کانتینر تب‌ها */
.auth-tabs-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
    background: rgba(139, 92, 246, 0.06);
    padding: 0.35rem;
    border-radius: 1rem;
    position: relative;
    gap: 0.25rem;
}

html.dark .auth-tabs-container {
    background: rgba(139, 92, 246, 0.1);
}

/* استایل پایه تب */
.auth-tab-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border-radius: 0.85rem;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    z-index: 1;
    border: none;
    background: transparent;
    color: #6b7280;
    outline: none;
}

html.dark .auth-tab-btn {
    color: #9ca3af;
}

/* تب فعال - با گرادینت بنفش */
.auth-tab-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4), 
                0 1px 3px rgba(0, 0, 0, 0.08);
    transform: scale(1.02);
    letter-spacing: -0.01em;
}

html.dark .auth-tab-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5),
                0 1px 3px rgba(0, 0, 0, 0.2);
}

/* تب غیرفعال - hover */
.auth-tab-btn:not(.active):hover {
    color: #7c3aed;
    background: rgba(139, 92, 246, 0.08);
    transform: translateY(-1px);
}

html.dark .auth-tab-btn:not(.active):hover {
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.12);
}

/* افکت ripple روی کلیک */
.auth-tab-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0.85rem;
    background: radial-gradient(circle at center, rgba(255,255,255,0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.auth-tab-btn:active::after {
    opacity: 1;
    transition: opacity 0s;
}

/* انیمیشن تغییر فرم */
#login-form,
#register-form {
    animation: formFadeSlide 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes formFadeSlide {
    from {
        opacity: 0;
        transform: translateY(12px);
        filter: blur(2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

/* وقتی فرم مخفی میشه انیمیشن خروج هم داشته باشه */
#login-form.hidden,
#register-form.hidden {
    display: none !important;
}

/* برای اینکه انیمیشن خروج هم کار کنه، از transition group استفاده می‌کنیم */
.form-wrapper {
    position: relative;
    overflow: hidden;
}

/* نشانگر sliding background برای تب فعال */
.auth-tabs-container {
    position: relative;
    overflow: hidden;
}

/* حذف استایل‌های قبلی auth-tab-btn که تداخل دارن */
.auth-tab-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4), 
                0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

/* فوکوس روی input ها */
#login-form .input-field:focus,
#register-form .input-field:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    transform: translateY(-1px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* دکمه submit هم گرادینت بنفش */
#login-submit-btn,
#register-submit-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em !important;
}

#login-submit-btn:hover,
#register-submit-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.5) !important;
}

#login-submit-btn:active,
#register-submit-btn:active {
    transform: translateY(0) scale(0.98) !important;
}
/* دکمه‌های تب پنل استاد */
.admin-tab-btn {
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 0.75rem;
}
.admin-tab-btn:not(.active) {
    color: #4b5563; /* gray-600 */
}
html.dark .admin-tab-btn:not(.active) {
    color: #9ca3af; /* gray-400 */
}
.admin-tab-btn.active {
    background-color: #f3e8ff; /* purple-100 */
    color: #6b21a8; /* purple-800 */
    font-weight: 600;
}
html.dark .admin-tab-btn.active {
    background-color: rgba(88, 28, 135, 0.25); /* purple-900/25 */
    color: #d8b4fe; /* purple-300 */
}
/* رفع برش استوری‌ها هنگام هاور */
#stories-container {
    scroll-snap-type: x mandatory;
}
#stories-container > div {
    scroll-snap-align: center;
}
/* ارتقای فیلد جستجو و تب‌های دسته‌بندی در بخش آزمون‌ها */
#quiz-search-input {
    background-color: rgba(255,255,255,0.45) !important;
    backdrop-filter: blur(10px);
}
html.dark #quiz-search-input {
    background-color: rgba(55,65,81,0.45) !important;
}
.category-tab-btn.active {
    border-bottom-color: #7c3aed !important;
    color: #6d28d9 !important;
}
/* ==================== SEPIA THEME ==================== */
html.theme-sepia body {
    background-color: #f4ecd8 !important;
    background-image: none !important;
    color: #4b3b2b !important;
}
html.theme-sepia .card,
html.theme-sepia .mentor-card,
html.theme-sepia .bg-white\/40,
html.theme-sepia .bg-white\/80 {
    background-color: rgba(255, 248, 235, 0.85) !important;
    border-color: #d6c8a9 !important;
    box-shadow: 0 10px 25px rgba(139, 69, 19, 0.1) !important;
    backdrop-filter: blur(8px) !important;
}
html.theme-sepia .input-field {
    background-color: #fffaf0 !important;
    border-color: #c9b896 !important;
    color: #4b3b2b !important;
}
html.theme-sepia .input-field::placeholder {
    color: #8b7355 !important;
}
html.theme-sepia .btn-primary {
    background-image: linear-gradient(to right, #a0522d, #8b4513, #a0522d) !important;
    box-shadow: 0 4px 10px rgba(139, 69, 19, 0.3) !important;
}
html.theme-sepia .btn-primary:hover:not(:disabled) {
    background-position: 100% 0 !important;
    box-shadow: 0 8px 20px rgba(139, 69, 19, 0.4) !important;
}
html.theme-sepia .option {
    background-color: #fff7e6 !important;
    border-color: #d6c8a9 !important;
    color: #4b3b2b !important;
}
html.theme-sepia .option:hover {
    background-color: #efe3ce !important;
    border-color: #8b5a2b !important;
}
html.theme-sepia .option.selected {
    background-color: #e6d5b8 !important;
    border-color: #8b4513 !important;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.3) !important;
}
html.theme-sepia .tab-btn.active {
    background-color: #8b4513 !important;
    color: #fff8e7 !important;
}
html.theme-sepia .category-tab-btn.active {
    color: #8b4513 !important;
    border-bottom-color: #8b4513 !important;
}
html.theme-sepia .tab-btn:not(.active):hover {
    background-color: #efe3ce !important;
    color: #5c3317 !important;
}
html.theme-sepia .custom-modal-content {
    background-color: #fff6e5 !important;
    color: #4b3b2b !important;
    border: 1px solid #d6c8a9;
}
html.theme-sepia .toast-notification {
    background-color: #8b4513 !important;
}
/* سایر المان‌های پرکاربرد */
html.theme-sepia .bg-white,
html.theme-sepia [style*="background-color: white"] {
    background-color: #fffaf1 !important;
}
html.theme-sepia .text-gray-800,
html.theme-sepia .text-gray-900,
html.theme-sepia h1, html.theme-sepia h2, html.theme-sepia h3 {
    color: #4b3b2b !important;
}
html.theme-sepia .text-gray-600,
html.theme-sepia .text-gray-700 {
    color: #5c4a33 !important;
}
html.theme-sepia .border-gray-200,
html.theme-sepia .border-gray-100 {
    border-color: #d6c8a9 !important;
}
html.theme-sepia .chat-bubble.sent {
    background-color: #d2b48c !important;
    color: #2c1e0e !important;
}
html.theme-sepia .chat-bubble.received {
    background-color: #fff6e5 !important;
    border-color: #c9b896 !important;
    color: #3b2c1a !important;
}
/* نوار بالایی و نویگیشن */
html.theme-sepia .sticky.top-0 {
    background-color: rgba(255, 248, 235, 0.9) !important;
    border-color: #c9b896 !important;
}
html.theme-sepia #bottom-nav {
    background-color: rgba(255, 248, 235, 0.7) !important;
    border-color: #d6c8a9 !important;
}
/* استایل پلیر ویدیو - هماهنگ با پلتفرم */
.custom-video-player {
    width: 100%;
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.4);
    background-color: #0f0f0f;
}

.custom-video-player video {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    outline: none;
}

/* استایل کنترل‌های پیش‌فرض مرورگر (فقط در مرورگرهای مبتنی بر chromium قابل شخصی‌سازی جزئی) */
.custom-video-player video::-webkit-media-controls-panel {
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.3));
    border-radius: 0.75rem;
    padding: 0 10px;
}

.custom-video-player video::-webkit-media-controls-play-button,
.custom-video-player video::-webkit-media-controls-volume-slider,
.custom-video-player video::-webkit-media-controls-timeline {
    filter: drop-shadow(0 0 2px #8b5cf6);
}

/* برای مرورگرهایی که از وی‌پاد پشتیبانی نمی‌کنند، یک استایل جایگزین */
@supports not (selector(::-webkit-media-controls-panel)) {
    .custom-video-player {
        border: 2px solid rgba(139, 92, 246, 0.5);
    }
}

/* انیمیشن ورود پلیر */
@keyframes fadeScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.custom-video-player {
    animation: fadeScale 0.3s ease-out;
}
/* مودال ویدئو – تمام صفحه در موبایل، با حداکثر عرض مشخص در دسکتاپ */
#video-modal {
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
}

#video-modal .modal-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#player {
    width: 100%;
    max-width: 1152px;    /* حداکثر عرض دلخواه */
    height: auto;
    aspect-ratio: 1152 / 860;   /* نسبت ابعاد 4:3 تقریبی */
    background: #000;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* برای نمایشگرهای بزرگتر از 1200px */
@media (min-width: 1200px) {
    #player {
        width: 1152px;
        height: 860px;
        aspect-ratio: unset;
    }
}

/* در موبایل، پلیر کل عرض را می‌گیرد و ارتفاع متناسب حفظ می‌شود */
@media (max-width: 640px) {
    #player {
        border-radius: 0.75rem;
    }
}

/* وسط‌چین کردن محتوای iframe داخل پلیر */
#player iframe {
    width: 100% !important;
    height: 100% !important;
    display: block;
    margin: 0 auto;
}
/* انیمیشن خروج برای مودال‌ها */
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
@keyframes modalPopOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
}
.modal-exit-backdrop {
    animation: fadeOut 0.3s ease-out forwards;
}
.modal-exit-content {
    animation: modalPopOut 0.3s ease-out forwards;
}
/* ثابت نگه داشتن ستون درصد در هنگام اسکرول افقی */
.sticky-percent {
    position: sticky !important;
    right: 0 !important; /*因为在 RTL 布局中，右侧是固定的 */
    background-color: inherit !important;
    z-index: 15 !important;
    box-shadow: -2px 0 5px -2px rgba(0,0,0,0.1);
}

/* برای هدر جدول نیز باید sticky باشد */
thead th.sticky-percent {
    background-color: #f3f4f6; /* matching thead background */
    z-index: 20;
}
html.dark thead th.sticky-percent {
    background-color: #374151;
}
/* استایل نوار اسکرول افقی */
.overflow-x-auto::-webkit-scrollbar {
    height: 8px;
}
.overflow-x-auto::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
.overflow-x-auto::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 10px;
}
.overflow-x-auto::-webkit-scrollbar-thumb:hover {
    background: #a78bfa;
}
/* Scrollbar اختصاصی برای پنل تنظیمات (باریک و بنفش) */
#settings-panel::-webkit-scrollbar {
    width: 4px;
}
#settings-panel::-webkit-scrollbar-track {
    background: rgba(203, 213, 225, 0.3);
    border-radius: 10px;
}
#settings-panel::-webkit-scrollbar-thumb {
    background: #c084fc; /* purple-400 */
    border-radius: 10px;
}
#settings-panel::-webkit-scrollbar-thumb:hover {
    background: #a855f7; /* purple-500 */
}
#settings-panel {
    scrollbar-width: thin;
    scrollbar-color: #c084fc rgba(203, 213, 225, 0.3);
}
/* ===== REACTIONS STYLES ===== */
.chat-popover {
    position: fixed;
    background: rgba(30, 30, 40, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 28px;
    border: 1px solid rgba(139, 92, 246, 0.4);
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(139, 92, 246, 0.2) inset;
    z-index: 10000;
    padding: 8px;
    min-width: 180px;
    max-width: 300px;
    display: none;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    transform: scale(0.95) translateY(5px);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    /* برای انیمیشن ورود توسط JS اضافه می‌شود */
}
.chat-popover.show {
    opacity: 1;
    transform: scale(1) translateY(0);
}
html.dark .chat-popover {
    background: rgba(20, 20, 30, 0.85);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(139, 92, 246, 0.3) inset;
}

/* ردیف ایموجی‌ها با اسکرول نرم */
.chat-popover-emoji-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.chat-popover-emoji-row::-webkit-scrollbar {
    height: 3px;
}
.chat-popover-emoji-row::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.chat-popover-emoji-row::-webkit-scrollbar-thumb {
    background: #a855f7;
    border-radius: 10px;
}
html.dark .chat-popover-emoji-row {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* هر ایموجی */
.chat-popover-emoji {
    font-size: 1.6rem;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    flex-shrink: 0;
}
.chat-popover-emoji:hover {
    background: rgba(139, 92, 246, 0.2);
    transform: scale(1.15);
    backdrop-filter: blur(4px);
}

/* دکمه‌های اکشن (پاسخ، کپی، ...) */
.chat-popover-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 500;
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.03);
    border: none;
}
html.dark .chat-popover-btn {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.02);
}
.chat-popover-btn:hover {
    background: rgba(139, 92, 246, 0.25);
    transform: translateX(-3px);
    backdrop-filter: blur(4px);
}
.chat-popover-btn.delete {
    color: #f87171;
}
.chat-popover-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
}
.chat-popover-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
}
.reaction-badge {
    background: rgba(0,0,0,0.05);
    border-radius: 9999px;        /* ← این خط را تغییر دهید: بیضی کامل */
    padding: 2px 12px;            /* ← کمی فضای داخلی بیشتر برای ظاهر بهتر */
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;                     /* ← فاصله بین ایموجی و عدد */
}
html.dark .reaction-badge {
    background: rgba(255,255,255,0.1);
}
.reaction-badge:hover {
    background: #e9d5ff;
    transform: scale(1.05);
}
/* ==================== دکمه ارسال مدرن ==================== */
#chat-send-btn {
    background: linear-gradient(135deg, #8b5cf6, #6366f1) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
    border-radius: 9999px !important;
    width: 44px !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    overflow: hidden !important;
}
#chat-send-btn:hover {
    transform: scale(1.05) translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4) !important;
}
#chat-send-btn:active {
    transform: scale(0.95) !important;
}
#chat-send-btn svg {
    transition: transform 0.2s ease;
}
#chat-send-btn:hover svg {
    transform: translateX(2px) rotate(-5deg);
}
#chat-send-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}
#chat-send-btn:active::after {
    width: 120%;
    height: 120%;
}
.chat-send-btn-loading {
    pointer-events: none;
    opacity: 0.7;
}
.chat-send-btn-loading svg {
    animation: spin 1s linear infinite;
    transform-origin: center;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
#chat-message-input {
    overflow-y: auto;
    resize: none;
    transition: height 0.1s ease;
}
#voice-record-btn {
    touch-action: none; /* جلوگیری از اسکرول صفحه هنگام لمس */
    user-select: none;  /* جلوگیری از انتخاب متن */
    -webkit-tap-highlight-color: transparent;
}
.group-card {
    transition: all 0.25s ease;
}
.group-card:hover {
    transform: translateY(-2px);
    border-color: rgba(139, 92, 246, 0.5);
}
/* افکت هایلایت زیبا برای پیام پین شده */
.highlight-message {
    animation: softGlow 0.4s ease-out, fadeOutGlow 2s ease-in forwards;
    border-radius: 1rem;
    position: relative;
    z-index: 10;
}

@keyframes softGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
        background-color: rgba(139, 92, 246, 0.1);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.3);
        background-color: rgba(139, 92, 246, 0.2);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
        background-color: rgba(139, 92, 246, 0.15);
    }
}

@keyframes fadeOutGlow {
    0% {
        box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
        background-color: rgba(139, 92, 246, 0.15);
    }
    70% {
        background-color: rgba(139, 92, 246, 0.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
        background-color: transparent;
    }
}

/* اطمینان از اینکه افکت روی حباب چت تأثیر نگذارد (اختیاری) */
.chat-bubble.highlight-message {
    transition: all 0.2s ease;
}
/* دکمه اسکرول به پایین - نسخه شیشه‌ای مدرن */
#chat-scroll-bottom-btn {
    position: absolute;
    bottom: 85px;
    left: 20px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    z-index: 45;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
}

#chat-scroll-bottom-btn:not(.hidden) {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#chat-scroll-bottom-btn:hover {
    background: rgba(139, 92, 246, 0.7);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 12px 28px rgba(139, 92, 246, 0.35);
    transform: scale(1.08);
}

#chat-scroll-bottom-btn:active {
    transform: scale(0.95);
}

/* آیکون داخل دکمه */
#chat-scroll-bottom-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: transform 0.2s ease;
}

#chat-scroll-bottom-btn:hover svg {
    transform: translateY(2px);
}

/* نسخه موبایل (کمی کوچک‌تر) */
@media (max-width: 640px) {
    #chat-scroll-bottom-btn {
        width: 42px;
        height: 42px;
        bottom: 75px;
        left: 16px;
    }
    #chat-scroll-bottom-btn svg {
        width: 20px;
        height: 20px;
    }
}
/* --- Telegram-like User Profile Modal --- */
#user-profile-modal {
    backdrop-filter: blur(8px);
    background-color: rgba(0, 0, 0, 0.4);
    transition: opacity 0.2s ease;
}
.modal-content-custom {
    transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1), opacity 0.2s ease;
    will-change: transform, opacity;
}
#user-profile-modal .modal-content-custom {
    max-width: 90vw;
    width: 360px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    backdrop-filter: none;
}
html.dark #user-profile-modal .modal-content-custom {
    background: rgba(30, 30, 35, 0.98);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
#user-profile-modal .modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.1);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    z-index: 2;
}
html.dark #user-profile-modal .modal-close {
    background: rgba(255,255,255,0.15);
}
#user-profile-modal .modal-close:hover {
    background: rgba(0,0,0,0.2);
}
#user-profile-modal .avatar-wrapper {
    width: 88px;
    height: 88px;
    margin: 28px auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #c084fc);
    padding: 2px;
}
#user-profile-modal .avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
html.dark #user-profile-modal .avatar-inner {
    background: #1f2937;
}
#user-profile-modal .user-name {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    margin-top: 10px;
    color: #1f2937;
}
html.dark #user-profile-modal .user-name {
    color: #f3f4f6;
}
#user-profile-modal .user-role {
    text-align: center;
    font-size: 0.7rem;
    color: #8b5cf6;
    background: rgba(139,92,246,0.12);
    display: inline-block;
    padding: 3px 12px;
    border-radius: 30px;
    margin: 8px auto 0;
    width: fit-content;
}
#user-profile-modal .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 20px 20px 24px;
}
#user-profile-modal .stat-card {
    background: rgba(0,0,0,0.03);
    border-radius: 20px;
    padding: 12px 8px;
    text-align: center;
    transition: 0.1s;
}
html.dark #user-profile-modal .stat-card {
    background: rgba(255,255,255,0.05);
}
#user-profile-modal .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}
#user-profile-modal .stat-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: #6b7280;
    letter-spacing: -0.2px;
}
html.dark #user-profile-modal .stat-label {
    color: #9ca3af;
}
#user-profile-modal .stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin-top: 4px;
}
html.dark #user-profile-modal .stat-value {
    color: #f9fafb;
}
#user-profile-modal .privacy-note {
    font-size: 0.65rem;
    text-align: center;
    padding: 12px 16px;
    background: rgba(0,0,0,0.02);
    border-top: 0.5px solid rgba(0,0,0,0.05);
    color: #6b7280;
}
html.dark #user-profile-modal .privacy-note {
    background: rgba(255,255,255,0.02);
    border-top-color: rgba(255,255,255,0.05);
    color: #9ca3af;
}
/* تنظیمات مودال تصویر برای زوم لمسی */
#story-viewer-modal {
    touch-action: none; /* جلوگیری از اسکرول صفحه هنگام زوم روی تصویر */
}

#story-viewer-image {
    transform-origin: center center;
    transition: transform 0.05s linear; /* نرمی در هنگام زوم */
    will-change: transform;
    cursor: zoom-in;
}

/* وقتی تصویر بزرگ‌تر از ۱ است، حالت cursor تغییر کند */
#story-viewer-image[data-scale="1"] {
    cursor: zoom-in;
}
#story-viewer-image[data-scale]:not([data-scale="1"]) {
    cursor: grab;
}
#story-viewer-image[data-scale]:not([data-scale="1"]):active {
    cursor: grabbing;
}
.discount-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: linear-gradient(135deg, #10b981, #34d399);
    color: white;
    font-size: 1rem;
    font-weight: 800;
    padding: 0.4rem 0.9rem;
    border-radius: 9999px;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.35);
    backdrop-filter: blur(4px);
    letter-spacing: 0.5px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: soft-pulse 2s infinite ease-in-out;
}
.discount-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 14px rgba(16, 185, 129, 0.5);
}
@keyframes soft-pulse {
    0%, 100% { opacity: 0.95; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}
html.dark .discount-badge {
    background: linear-gradient(135deg, #059669, #10b981);
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.4);
}