* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: vazir;
}



  @font-face {
  font-family: vazir;
  src: url('font/Vazir.eot');
  src: url('font/Vazir.eot?#iefix') format('FontName-opentype'),
       url('font/Vazir.woff') format('woff'),
       url('font/Vazir.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
        
 }





body {
    font-family: vazir;
    background: #e5ddd5;
    height: 100vh;
    overflow: hidden;
}

/* تنظیمات RTL */
body {
    font-family: vazir;
    direction: rtl;
}

/* صفحات */
.page {
    display: none;
    height: 100vh;
    width: 100%;
}

.page.active {
    display: flex;
    flex-direction: column;
}

/* صفحه ورود */
.login-container {
    max-width: 400px;
    width: 90%;
    margin: auto;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    width: 165px;
    height: 80px;
}

.login-header h1 {
    color: #0088cc;
    font-size: 28px;
    margin-top: 10px;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #0088cc;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #0088cc;
    color: white;
}

.btn-primary:hover {
    background: #0077b3;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-sm {
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
}

.error-message {
    color: #dc3545;
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
}

/* هدر برنامه */
.app-header {
    background: #0088cc;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h2 {
    font-size: 20px;
    margin: 0;
    color: white;
}

.menu-container {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    transition: transform 0.2s;
}

.menu-btn:hover {
    transform: scale(1.1);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* منوی کشویی */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 35px;
    background: white;
    color: #333;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    padding: 8px 0;
    z-index: 1000;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
    font-size: 14px;
}

.dropdown-menu a:hover {
    background: #f0f0f0;
}

.menu-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 5px 0;
}
/* محتوای اصلی */
.app-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* لیست چت‌ها */
.chat-list {
    width: 350px;
    background: white;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.chat-search {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.chat-search input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

.chat-items {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f5f5f5;
}

.chat-item:hover {
    background: #f5f5f5;
}

.chat-item.active {
    background: #e3f2fd;
}

.chat-item-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-left: 12px;
    object-fit: cover;
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    font-weight: 600;
    color: #333;
}

.chat-item-last-msg {
    font-size: 13px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 11px;
    color: #999;
}

/* پنجره چت */
.chat-window {
    flex: 1;
    background: #e5ddd5;
    display: flex;
    flex-direction: column;
}

.chat-window-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #666;
}

.empty-icon {
    width: 240px;
    height: 120px;
    margin-bottom: 20px;
    opacity: 0.6;
}

.chat-header {
    background: #f0f0f0;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #d0d0d0;
}

.back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #0088cc;
    display: none;
    padding: 0 10px;
    margin-top: 8px;
    margin-right: -17px;
}

.chat-user-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.chat-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-left: 10px;
    object-fit: cover;
}

.chat-user-name {
    font-weight: 600;
    color: #333;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.message {
    max-width: 70%;
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    word-wrap: break-word;
    position: relative;
}

.message.sent {
    background: #dcf8c6;
    align-self: flex-start;
    border-bottom-left-radius: 0;
}

.message.received {
    background: white;
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

.message .message-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    display: block;
    margin-bottom: -7px;
}

.message .message-sender {
    font-size: 12px;
    font-weight: 600;
    color: #0088cc;
    margin-bottom: 3px;
}

.message .message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-top: 5px;
}

.message .message-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-top: 5px;
}

.message-input-container {
    padding: 10px 15px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #d0d0d0;
}

.message-input-container input[type="text"] {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 15px;
    background: white;
}

.message-input-container input[type="text"]:focus {
    outline: none;
    border-color: #0088cc;
}

.attach-btn, .send-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.send-btn {
    color: #0088cc;
}

.attach-btn:hover, .send-btn:hover {
    color: #0077b3;
}

/* مودال‌ها */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0 10px;
}

.modal-body {
    padding: 20px;
}

.contacts-search {
    margin-bottom: 15px;
}

.contacts-search input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

.contacts-actions {
    margin-bottom: 15px;
}

.contacts-list {
    max-height: 400px;
    overflow-y: auto;
}

.contact-item {
    padding: 10px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.2s;
}

.contact-item:hover {
    background: #f5f5f5;
}

.contact-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-left: 10px;
    object-fit: cover;
}

.contact-item-info {
    flex: 1;
}

.contact-item-name {
    font-weight: 500;
    color: #333;
}

.contact-item-national {
    font-size: 12px;
    color: #888;
}

/* تنظیمات */
.settings-section {
    margin-bottom: 30px;
}

.settings-section h4 {
    color: #333;
    margin-bottom: 15px;
}

.profile-image-container {
    text-align: center;
    margin-bottom: 20px;
}

.profile-image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #0088cc;
}

/* گروه و کانال */
.member-list {
    max-height: 300px;
    overflow-y: auto;
}

.member-item {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.member-item:hover {
    background: #f5f5f5;
}

.member-item input[type="checkbox"] {
    margin-left: 10px;
}

.member-item .member-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-left: 10px;
    object-fit: cover;
}

/* اسکرول‌بار سفارشی */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}




/* ============================================ */
/* وضعیت آنلاین در هدر چت */
/* ============================================ */
.chat-user-info {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 10px;
}

.chat-user-details {
    display: flex;
    flex-direction: column;
}

.chat-user-status {
    font-size: 12px;
    margin-top: 2px;
}

.chat-user-status.online {
    color: #25d366;
}

.chat-user-status.offline {
    color: #999;
}

.chat-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}


/* ============================================ */
/* نشانگر بارگذاری پیام‌های قدیمی */
/* ============================================ */
#loadingMoreIndicator {
    text-align: center;
    color: #999;
    padding: 15px;
    font-size: 14px;
    background: transparent;
    width: 100%;
}

/* انیمیشن برای نشانگر بارگذاری */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#loadingMoreIndicator {
    animation: fadeIn 0.3s ease-in;
}



/* ============================================ */
/* منوی زمینه (Context Menu) - با اسکرول */
/* ============================================ */
.message-context-menu {
    display: none;
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 200px;
    max-width: 280px;
    max-height: 60vh; /* حداکثر ارتفاع 60% از صفحه */
    overflow-y: auto; /* اسکرول داخلی */
    padding: 8px 0;
    z-index: 99999;
    font-size: 14px;
    direction: rtl;
    animation: menuFadeIn 0.15s ease-out;
}

.message-context-menu.show {
    display: block;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-5px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.message-context-menu .menu-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #333;
    font-size: 14px;
    min-height: 44px; /* برای لمس بهتر در موبایل */
}

.message-context-menu .menu-item:active {
    background: #e0e0e0;
}

.message-context-menu .menu-item.danger {
    color: #dc3545;
}

.message-context-menu .menu-item.danger:active {
    background: #f8d7da;
}

.message-context-menu .menu-divider {
    height: 1px;
    background: #e8e8e8;
    margin: 4px 0;
}

/* ============================================ */
/* اسکرول‌بار زیبا برای منو */
/* ============================================ */
.message-context-menu::-webkit-scrollbar {
    width: 4px;
}

.message-context-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.message-context-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.message-context-menu::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ============================================ */
/* تنظیمات برای موبایل */
/* ============================================ */
@media (max-width: 768px) {
    .message-context-menu {
        min-width: 160px;
        max-width: 240px;
        padding: 6px 0;
        border-radius: 10px;
    }
    
    .message-context-menu .menu-item {
        padding: 14px 16px;
        font-size: 15px;
        min-height: 48px;
    }
}

/* ============================================ */
/* تیک‌های وضعیت پیام - طراحی زیبا */
/* ============================================ */

.message-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

/* ===== تیک یک‌دونه سفید (ارسال شده) ===== */
.message-status.sent {
    color: #b0b0b0;
    font-size: 16px;
}

.message-status.sent .tick {
    display: inline-block;
    transform: scale(0.8);
}

/* ===== تیک یک‌دونه آبی (تحویل داده شده) ===== */
.message-status.delivered {
    color: #4fc3f7;
    font-size: 16px;
}

.message-status.delivered .tick {
    display: inline-block;
    animation: tickFadeIn 0.2s ease-out;
}

/* ===== تیک دوتایی آبی (مشاهده شده) ===== */
.message-status.seen {
    color: #4fc3f7;
    font-size: 18px;
    letter-spacing: -1px;
}

.message-status.seen .tick {
    display: inline-block;
}

.message-status.seen .tick:first-child {
    margin-right: -2px;
}

.message-status.seen .tick:last-child {
    animation: tickPop 0.3s ease-out 0.1s both;
}

/* ===== انیمیشن‌ها ===== */
@keyframes tickFadeIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes tickPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== تیک دوتایی با دایره پس‌زمینه ===== */
.message-status.seen-bubble {
    display: inline-flex;
    align-items: center;
    background: #4fc3f7;
    border-radius: 12px;
    padding: 0 6px;
    color: white;
    font-size: 12px;
    height: 20px;
    min-width: 28px;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(79, 195, 247, 0.3);
}

.message-status.seen-bubble .tick {
    font-size: 14px;
    font-weight: 700;
}

.message-status.seen-bubble .tick:first-child {
    margin-right: -1px;
}

.message-status.seen-bubble .tick:last-child {
    margin-left: -1px;
}

/* ===== تیک دوتایی با بج کوچک ===== */
.message-status.seen-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(79, 195, 247, 0.15);
    border: 1px solid #4fc3f7;
    border-radius: 12px;
    padding: 0 8px;
    color: #4fc3f7;
    font-size: 12px;
    height: 20px;
    min-width: 30px;
    justify-content: center;
}

.message-status.seen-badge .tick {
    font-size: 14px;
}

/* ===== برای پیام‌های گروهی ===== */
.message-status.group-seen {
    display: inline-flex;
    align-items: center;
    background: rgba(79, 195, 247, 0.1);
    border-radius: 12px;
    padding: 0 8px;
    color: #4fc3f7;
    font-size: 11px;
    height: 20px;
    gap: 3px;
}

.message-status.group-seen .eye-icon {
    font-size: 12px;
}

/* ============================================ */
/* تیک‌ها در حالت تاریک (اختیاری) */
/* ============================================ */
.message.sent .message-status.sent {
    color: #888;
}

.message.sent .message-status.delivered,
.message.sent .message-status.seen {
    color: #4fc3f7;
}

.message.received .message-status.sent {
    color: #999;
}

.message.received .message-status.delivered,
.message.received .message-status.seen {
    color: #4fc3f7;
}

/* ============================================ */
/* پاسخ به پیام (Reply) */
/* ============================================ */
.message-reply {
    background: #f0f0f0;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 5px;
    border-right: 3px solid #0088cc;
    font-size: 13px;
    color: #666;
    cursor: pointer;
}

.message-reply .reply-sender {
    font-weight: 600;
    color: #0088cc;
}

.message-reply .reply-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================ */
/* پیام ویرایش شده */
/* ============================================ */
.message .edited-badge {
    font-size: 10px;
    color: #999;
    margin-right: 5px;
}

/* ============================================ */
/* پیام حذف شده */
/* ============================================ */
.message.deleted {
    opacity: 0.6;
    font-style: italic;
    color: #999;
}

/* ============================================ */
/* بزرگ‌نمایی عکس‌ها */
/* ============================================ */
.image-viewer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}

.image-viewer-overlay.show {
    display: flex;
}

.image-viewer-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    cursor: default;
}

.image-viewer-overlay .close-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    font-size: 32px;
    cursor: pointer;
    background: rgba(0,0,0,0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    transition: background 0.3s;
}

.image-viewer-overlay .close-btn:hover {
    background: rgba(255,0,0,0.7);
}

/* ============================================ */
/* عکس پروفایل در هدر چت - نشانگر کلیک */
/* ============================================ */
.chat-user-avatar {
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-user-avatar:hover {
    transform: scale(1.05);
}

/* ============================================ */
/* تصاویر پیام - نشانگر کلیک */
/* ============================================ */
.message-image {
    cursor: pointer;
    transition: transform 0.2s;
    border-radius: 8px;
    max-width: 100%;
    max-height: 300px;
}

.message-image:hover {
    transform: scale(1.02);
}

/* ============================================ */
/* انیمیشن تیک آبی */
/* ============================================ */
@keyframes tickFadeIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.message .message-status.seen .tick {
    animation: tickFadeIn 0.3s ease-out;
}




/* ============================================ */
/* غیرفعال کردن انتخاب متن در پیام‌ها */
/* ============================================ */

.message {
    -webkit-user-select: none;  /* Safari */
    -moz-user-select: none;     /* Firefox */
    -ms-user-select: none;      /* IE/Edge */
    user-select: none;          /* استاندارد */
    
    /* جلوگیری از نمایش منوی context مرورگر */
    -webkit-touch-callout: none;
}


/* ============================================ */
/* جلوگیری از هایلایت شدن هنگام لمس طولانی */
/* ============================================ */

.message * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}






/* ============================================ */
/* نوار ریپلای (پاسخ به پیام) */
/* ============================================ */
#replyBar {
    display: none;
    background: #f0f2f5;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 10px;
    border-right: 4px solid #0088cc;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    animation: replySlideDown 0.25s ease-out;
}

@keyframes replySlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 80px;
    }
}

#replyBar .reply-sender {
    font-weight: 600;
    color: #0088cc;
    font-size: 13px;
}

#replyBar .reply-text {
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-top: 2px;
}

#replyBar .reply-close {
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 0 8px;
    transition: color 0.2s;
    flex-shrink: 0;
}

#replyBar .reply-close:hover {
    color: #dc3545;
}

#replyBar .reply-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* ============================================ */
/* کانتینر ورودی پیام */
/* ============================================ */
.message-input-container {
    padding: 10px 15px;
    background: #f0f0f0;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #d0d0d0;
}

.message-input-container .input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}







/* ============================================ */
/* کشیدن پیام برای پاسخ (Swipe to Reply) */
/* ============================================ */

.message {
    position: relative;
    transition: transform 0.25s ease-out;
    touch-action: pan-y;
    will-change: transform;
}

/* نشانگر پاسخ که هنگام کشیدن ظاهر می‌شود */
.swipe-reply-indicator {
    position: absolute;
    left: 0;
    top: 80%;
    transform: translateY(-50%) scale(0.5);
    opacity: 0;
    transition: all 0.2s ease-out;
    color: #0088cc;
    font-size: 20px;
    background: rgba(0, 136, 204, 0.1);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}

.message.swiping .swipe-reply-indicator {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* وقتی پیام به آستانه رسید */
.message.swipe-ready .swipe-reply-indicator {
    background: #0088cc;
    color: white;
    transform: translateY(-50%) scale(1.2);
}

/* انیمیشن بازگشت */
.message.swipe-reset {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* برای پیام‌های دریافتی (received) که به راست کشیده می‌شوند */
.message.received.swiping {
    transform: translateX(var(--swipe-x, 0px));
}

/* برای پیام‌های ارسالی (sent) که به چپ کشیده می‌شوند (اختیاری) */
.message.sent.swiping {
    transform: translateX(var(--swipe-x, 0px));
}

/* ============================================ */
/* انیمیشن فلش پاسخ */
/* ============================================ */
@keyframes swipeArrowPulse {
    0% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.3); }
    100% { transform: translateY(-50%) scale(1); }
}

.message.swipe-ready .swipe-reply-indicator {
    animation: swipeArrowPulse 0.6s ease-in-out infinite;
}



/* ============================================ */
/* استیکرها در پیام‌ها */
/* ============================================ */

/* استیکر معمولی */
.message-sticker {
    width: 120px;
    height: 120px;
    object-fit: contain;
    cursor: pointer;
    border-radius: 8px;
    transition: transform 0.2s;
    display: block;
}

.message-sticker:hover {
    transform: scale(1.05);
}

/* ============================================ */
/* استیکر بزرگ - وقتی پیام فقط شامل استیکر است */
/* ============================================ */
.message.sticker-only {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 250px;
    border-radius: 0;
}

.message.sticker-only .message-sticker {
    width: 200px;
    height: 200px;
    border-radius: 0;
}

/* در موبایل استیکر بزرگ کمی کوچک‌تر */
@media (max-width: 768px) {
    .message.sticker-only .message-sticker {
        width: 160px;
        height: 160px;
    }
    
    .message-sticker {
        width: 100px;
        height: 100px;
    }
}

/* ============================================ */
/* حذف پس‌زمینه پیام‌های استیکری */
/* ============================================ */
.message.sticker-only.sent,
.message.sticker-only.received {
    background: transparent !important;
    padding: 5px !important;
    box-shadow: none !important;
}

/* ============================================ */
/* زمان پیام استیکری (کمی محو‌تر) */
/* ============================================ */
.message.sticker-only .message-time {
    background: rgba(0, 0, 0, 0.4);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    display: inline-block;
    margin-top: 5px;
}

/* ============================================ */
/* انیمیشن استیکر */
/* ============================================ */
@keyframes stickerPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.message.sticker-only .message-sticker {
    animation: stickerPop 0.3s ease-out;
}



/* ============================================ */
/* شکلک‌های بزرگ (Emoji) */
/* ============================================ */



/* ============================================ */
/* اندازه‌های مختلف Emoji */
/* ============================================ */

/* خیلی بزرگ - 1 تا 3 ایموجی */
.message-emoji.emoji-xlarge {
    font-size: 35px;
    line-height: 1.2;
    display: inline-block;
}

/* بزرگ - 4 تا 6 ایموجی */
.message-emoji.emoji-large {
    font-size: 25px;
    line-height: 1.2;
    display: inline-block;
}

/* متوسط - 7 تا 10 ایموجی */
.message-emoji.emoji-medium {
    font-size: 15px;
    line-height: 1.2;
    display: inline-block;
}



/* ============================================ */
/* انیمیشن Emoji */
/* ============================================ */
@keyframes emojiPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.message-emoji {
    animation: emojiPop 0.3s ease-out;
}

/* ============================================ */
/* در موبایل اندازه‌ها کمی کوچک‌تر */
/* ============================================ */
@media (max-width: 768px) {
    .message-emoji.emoji-xlarge {
        font-size: 35px;
    }
    
    .message-emoji.emoji-large {
        font-size: 25px;
    }
    
    .message-emoji.emoji-medium {
        font-size: 15px;
    }
}



/* ============================================ */
/* دکمه میکروفون */
/* ============================================ */
.voice-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    transition: all 0.3s;
    border-radius: 50%;
}

.voice-btn:hover {
    color: #0088cc;
    transform: scale(1.1);
}

.voice-btn.recording {
    color: #dc3545;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ============================================ */
/* پیام‌های صوتی */
/* ============================================ */
.message-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    max-width: 300px;
    padding: 5px 0;
}

.message-voice .voice-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0088cc;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.message-voice .voice-play-btn:hover {
    background: #0077b3;
    transform: scale(1.05);
}

.message-voice .voice-play-btn.playing {
    background: #dc3545;
}

.message-voice .voice-waveform {
    flex: 1;
    height: 30px;
    display: flex;
    align-items: center;
    gap: 2px;
    overflow: hidden;
}

.message-voice .voice-waveform .wave-bar {
    width: 3px;
    background: #0088cc;
    border-radius: 2px;
    opacity: 0.4;
    transition: all 0.1s;
}

.message-voice .voice-waveform .wave-bar.active {
    opacity: 1;
    background: #0088cc;
}

.message-voice .voice-duration {
    font-size: 12px;
    color: #666;
    flex-shrink: 0;
    min-width: 40px;
    text-align: left;
}

.message.sent .message-voice .voice-play-btn {
    background: #25d366;
}

.message.sent .message-voice .voice-play-btn:hover {
    background: #1da851;
}

.message.sent .message-voice .voice-waveform .wave-bar {
    background: #25d366;
}







/* ============================================ */
/* دکمه اسکرول به پایین (مثل تلگرام و واتس‌اپ) */
/* ============================================ */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #0088cc;
    color: white;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 100;
    transition: all 0.3s ease;
    font-size: 20px;
    font-weight: bold;
}

.scroll-to-bottom-btn:hover {
    background: #0077b3;
    transform: scale(1.1);
}

.scroll-to-bottom-btn.show {
    display: flex;
    animation: scrollBtnFadeIn 0.3s ease-out;
}

.scroll-to-bottom-btn .scroll-arrow {
    font-size: 24px;
    line-height: 1;
    animation: arrowBounce 2s infinite;
}

/* ============================================ */
/* شمارنده پیام‌های جدید */
/* ============================================ */
.new-messages-counter {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: counterPop 0.3s ease-out;
}

/* ============================================ */
/* انیمیشن‌ها */
/* ============================================ */
@keyframes scrollBtnFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes arrowBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(3px);
    }
}

@keyframes counterPop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

/* ============================================ */
/* تنظیمات موبایل */
/* ============================================ */
@media (max-width: 768px) {
    .scroll-to-bottom-btn {
        bottom: 75px;
        left: 15px;
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
    
    .scroll-to-bottom-btn .scroll-arrow {
        font-size: 22px;
    }
    
    .new-messages-counter {
        font-size: 10px;
        padding: 1px 5px;
        min-width: 16px;
        height: 16px;
    }
}

/* ============================================ */
/* اطمینان از position: relative برای chatWindowContent */
/* ============================================ */
#chatWindowContent {
    position: relative;
}


/* ============================================ */
/* نشانگر "در حال نوشتن" - بالای کادر ورودی */
/* ============================================ */
.typing-indicator-input {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #999;
    font-style: italic;
    background: transparent;
    margin-bottom: -4px;
    direction: rtl;
    animation: typingInputFadeIn 0.3s ease-out;
}

.typing-indicator-input.show {
    display: flex;
}

.typing-indicator-input .typing-text {
    color: #999;
    font-weight: normal;
    font-size: 13px;
}

/* ============================================ */
/* نقطه‌های متحرک */
/* ============================================ */
.typing-indicator-input .typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.typing-indicator-input .typing-dots span {
    width: 4px;
    height: 4px;
    background: #999;
    border-radius: 50%;
    display: inline-block;
    animation: typingInputBounce 1.4s infinite ease-in-out both;
}

.typing-indicator-input .typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator-input .typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-indicator-input .typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

/* ============================================ */
/* انیمیشن‌ها */
/* ============================================ */
@keyframes typingInputBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes typingInputFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================ */
/* در موبایل */
/* ============================================ */
@media (max-width: 768px) {
    .typing-indicator-input {
        font-size: 12px;
        padding: 4px 10px;
    }
    
    .typing-indicator-input .typing-text {
        font-size: 12px;
    }
    
    .typing-indicator-input .typing-dots span {
        width: 3px;
        height: 3px;
    }
}





/* ============================================ */
/* هایلایت پیام اصلی (هنگام کلیک روی ریپلای) */
/* ============================================ */
.message.message-highlighted {
    animation: messageHighlight 2s ease-out;
    position: relative;
    z-index: 10;
}

@keyframes messageHighlight {
    100% {
        background: #ffeb3b;
        transform: scale(1.02);
        box-shadow: 0 0 30px rgba(255, 235, 59, 0.8);
    }
    50% {
        background: #fff9c4;
        transform: scale(1.01);
        box-shadow: 0 0 25px rgba(255, 235, 59, 0.6);
    }
    0% {
        background: inherit;
        transform: scale(1);
        box-shadow: none;
    }
}

/* ============================================ */
/* نشانگر قابل کلیک بودن ریپلای */
/* ============================================ */
.message-reply {
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.message-reply:hover {
    background: #e0e0e0;
    transform: translateX(-3px);
}

.message-reply:active {
    transform: scale(0.98);
}







/* ============================================ */
/* پیام نصب PWA (Add to Home Screen) */
/* ============================================ */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    padding: 15px;
    z-index: 99999;
    border-radius: 20px 20px 0 0;
    animation: pwaSlideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    direction: rtl;
    font-family: vazir, Tahoma, sans-serif;
}

@keyframes pwaSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 500px;
    margin: 0 auto;
}

.pwa-install-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.pwa-install-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pwa-install-text strong {
    font-size: 15px;
    color: #333;
    margin-bottom: 3px;
}

.pwa-install-text span {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-btn {
    background: #0088cc;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.pwa-install-btn:hover {
    background: #0077b3;
    transform: scale(1.05);
}

.pwa-install-btn:active {
    transform: scale(0.98);
}

.pwa-close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
    font-family: inherit;
}

.pwa-close-btn:hover {
    color: #dc3545;
}

/* ============================================ */
/* در موبایل کوچک */
/* ============================================ */
@media (max-width: 480px) {
    .pwa-install-banner {
        padding: 12px;
    }
    
    .pwa-install-icon {
        width: 60px;
        height: 28px;
    }
    
    .pwa-install-text strong {
        font-size: 14px;
    }
    
    .pwa-install-text span {
        font-size: 11px;
    }
    
    .pwa-install-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}




/* ============================================ */
/* نوار پیشرفت آپلود */
/* ============================================ */
.upload-progress-bar {
    background: #f0f2f5;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    border-right: 4px solid #0088cc;
    animation: uploadSlideDown 0.25s ease-out;
    direction: rtl;
}

@keyframes uploadSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 80px;
    }
}

.upload-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.upload-file-name {
    color: #333;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    margin-left: 10px;
}

.upload-percentage {
    color: #0088cc;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.upload-progress-track {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0088cc, #00a8e8);
    border-radius: 3px;
    transition: width 0.2s ease;
    position: relative;
}

.upload-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: uploadShimmer 1.5s infinite;
}

@keyframes uploadShimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ============================================ */
/* حالت موفقیت */
/* ============================================ */
.upload-progress-bar.success {
    border-right-color: #25d366;
}

.upload-progress-bar.success .upload-progress-fill {
    background: #25d366;
}

.upload-progress-bar.success .upload-percentage {
    color: #25d366;
}

/* ============================================ */
/* حالت خطا */
/* ============================================ */
.upload-progress-bar.error {
    border-right-color: #dc3545;
}

.upload-progress-bar.error .upload-progress-fill {
    background: #dc3545;
}

.upload-progress-bar.error .upload-percentage {
    color: #dc3545;
}

/* ============================================ */
/* در موبایل */
/* ============================================ */
@media (max-width: 768px) {
    .upload-progress-bar {
        padding: 8px 12px;
    }
    
    .upload-progress-info {
        font-size: 12px;
    }
    
    .upload-percentage {
        font-size: 13px;
    }
}



/* ============================================ */
/* دکمه لغو آپلود */
/* ============================================ */
.upload-progress-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.upload-cancel-btn {
    background: #dc3545;
    color: white;
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
    font-family: inherit;
}

.upload-cancel-btn:hover {
    background: #c82333;
    transform: scale(1.15);
}

.upload-cancel-btn:active {
    transform: scale(0.95);
}

/* ============================================ */
/* در حالت موفقیت، دکمه لغو مخفی شود */
/* ============================================ */
.upload-progress-bar.success .upload-cancel-btn {
    display: none;
}

.upload-progress-bar.error .upload-cancel-btn {
    display: none;
}

/* ============================================ */
/* در موبایل */
/* ============================================ */
@media (max-width: 768px) {
    .upload-cancel-btn {
        width: 24px;
        height: 24px;
        font-size: 13px;
    }
}








/* ============================================ */
/* مودال برش عکس */
/* ============================================ */
.crop-modal {
    max-width: 700px;
    width: 95%;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.crop-modal .modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.crop-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

.crop-container {
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    max-height: 400px;
}

.crop-container img {
    max-width: 100%;
    max-height: 400px;
    display: block;
}

/* ============================================ */
/* نوار ابزار برش */
/* ============================================ */
.crop-toolbar {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 10px;
}

.crop-tool-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: all 0.2s;
    min-width: 55px;
    font-family: inherit;
}

.crop-tool-btn:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.crop-tool-btn:active {
    transform: translateY(0);
}

.crop-tool-btn span {
    font-size: 18px;
    line-height: 1;
}

.crop-tool-btn small {
    font-size: 10px;
    color: #666;
}

/* ============================================ */
/* نسبت‌های ابعاد */
/* ============================================ */
.crop-aspect-ratios {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px;
    background: white;
    border-radius: 10px;
}

.aspect-btn {
    background: #f0f0f0;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: all 0.2s;
    min-width: 55px;
    font-family: inherit;
}

.aspect-btn:hover {
    background: #e0e0e0;
}

.aspect-btn.active {
    background: #e3f2fd;
    border-color: #0088cc;
}

.aspect-btn span {
    font-size: 18px;
    line-height: 1;
    color: #0088cc;
}

.aspect-btn small {
    font-size: 10px;
    color: #666;
}

/* ============================================ */
/* دکمه‌های اقدام */
/* ============================================ */
.crop-actions {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
}

.crop-actions .btn {
    flex: 1;
    padding: 12px;
    font-size: 15px;
    border-radius: 25px;
}

/* ============================================ */
/* تنظیمات Cropper.js */
/* ============================================ */
.cropper-view-box {
    outline: 2px solid #0088cc;
    outline-color: #0088cc;
}

.cropper-line {
    background-color: #0088cc;
}

.cropper-point {
    background-color: #0088cc;
}

.cropper-modal {
    background-color: rgba(0, 0, 0, 0.6);
}

/* ============================================ */
/* موبایل */
/* ============================================ */
@media (max-width: 768px) {
    .crop-modal {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .crop-container {
        min-height: 250px;
        max-height: 300px;
    }
    
    .crop-container img {
        max-height: 300px;
    }
    
    .crop-tool-btn,
    .aspect-btn {
        min-width: 48px;
        padding: 6px 8px;
    }
    
    .crop-tool-btn span,
    .aspect-btn span {
        font-size: 16px;
    }
    
    .crop-actions .btn {
        font-size: 14px;
        padding: 10px;
    }
}