/* messages.css - استایل سیستم پیام‌رسانی */

.messages-container {
    max-width: 1100px;
    margin: 140px auto 40px;
    padding: 0 20px;
}

.messages-wrapper {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    min-height: 550px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* ===== لیست مکالمات ===== */
.conversations-list {
    width: 320px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    max-height: 600px;
    flex-shrink: 0;
}

.conversations-list::-webkit-scrollbar {
    width: 4px;
}
.conversations-list::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 10px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: 0.3s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.conversation-item.active {
    background: rgba(52, 152, 219, 0.15);
}

.conversation-item .avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498db, #8e44ad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.conversation-item .info {
    flex: 1;
    min-width: 0;
}

.conversation-item .info .name {
    color: #fff;
    font-weight: bold;
    font-size: 0.95rem;
}

.conversation-item .info .last-message {
    color: #bdc3c7;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .info .time {
    color: #7f8c8d;
    font-size: 0.7rem;
}

.conversation-item .unread-badge {
    background: #3498db;
    color: #fff;
    border-radius: 50%;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

/* ===== صفحه چت ===== */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: bold;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.2);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 450px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 10px;
}

.chat-message {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.sent {
    background: #3498db;
    color: #fff;
    align-self: flex-end;
    border-bottom-left-radius: 4px;
}

.chat-message.received {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    align-self: flex-start;
    border-bottom-right-radius: 4px;
}

.chat-message .time {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

.chat-message .sender {
    font-size: 0.7rem;
    color: #3498db;
    margin-bottom: 2px;
    display: block;
}

.empty-chat {
    text-align: center;
    color: #bdc3c7;
    padding: 40px 0;
    align-self: center;
}

.loading {
    text-align: center;
    color: #bdc3c7;
    padding: 20px;
}

/* ===== ناحیه ورودی ===== */
.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.chat-input-area textarea {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    color: #fff;
    font-size: 0.9rem;
    resize: none;
    font-family: inherit;
    outline: none;
}

.chat-input-area textarea:focus {
    border-color: #3498db;
}

.chat-input-area button {
    background: #3498db;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.3s;
    flex-shrink: 0;
}

.chat-input-area button:hover {
    background: #2980b9;
}

.chat-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== ریسپانسیو ===== */
@media (max-width: 768px) {
    .messages-wrapper {
        flex-direction: column;
        min-height: 500px;
    }
    .conversations-list {
        width: 100%;
        max-height: 200px;
        border-left: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    .chat-messages {
        max-height: 300px;
    }
    .chat-message {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .messages-container {
        margin-top: 100px;
    }
    .conversations-list {
        max-height: 150px;
    }
    .chat-messages {
        max-height: 250px;
    }
}






/* ===== منوی اکشن پیام (مثل پیام‌رسان‌ها) ===== */
.message-context-menu {
    display: none;
    position: fixed;
    background: rgba(30, 39, 46, 0.98);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    min-width: 200px;
    padding: 6px 0;
    z-index: 9999;
    animation: contextMenuFade 0.15s ease;
}

.message-context-menu.show {
    display: block;
}

@keyframes contextMenuFade {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.message-context-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: #e0e0e0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: right;
    font-family: 'Vazir', sans-serif;
}

.message-context-menu .menu-item:hover {
    background: rgba(52, 152, 219, 0.15);
    color: #fff;
}

.message-context-menu .menu-item i {
    width: 20px;
    color: #bdc3c7;
    font-size: 1rem;
}

.message-context-menu .menu-item:hover i {
    color: #3498db;
}

.message-context-menu .menu-item.danger:hover {
    background: rgba(231, 76, 60, 0.15);
}

.message-context-menu .menu-item.danger:hover i {
    color: #e74c3c;
}

.message-context-menu .menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 4px 12px;
}

/* استایل روی پیام هنگام active شدن */
.chat-message.context-active {
    background: rgba(52, 152, 219, 0.1) !important;
    border-radius: 12px;
}



@media (max-width: 768px) {
    .back-to-home-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ===== دکمه بازگشت به لیست مکالمات ===== */
.back-to-conversations {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: 0.3s;
    display: none;
}

.back-to-conversations:hover {
    color: #3498db;
}

@media (max-width: 768px) {
    .back-to-conversations {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    .chat-header {
        display: flex;
        align-items: center;
        gap: 10px;
    }
}

/* ===== پیش‌نمایش ریپلای ===== */
.reply-preview-wrapper {
    padding: 8px 16px;
    background: rgba(52, 152, 219, 0.1);
    border-right: 3px solid #3498db;
    border-radius: 8px 0 0 8px;
    margin: 0 16px 4px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reply-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #bdc3c7;
    font-size: 0.85rem;
    flex: 1;
}

.reply-preview-content i {
    color: #3498db;
}

.reply-preview-content .reply-info {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cancel-reply {
    background: transparent;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: 50%;
    transition: 0.3s;
}

.cancel-reply:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* ===== نمایش ریپلای در خود پیام ===== */
.reply-preview {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: 4px;
    font-size: 0.8rem;
    color: #bdc3c7;
    border-right: 3px solid #3498db;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reply-preview i {
    color: #3498db;
    font-size: 0.7rem;
}

.reply-preview .reply-sender {
    color: #3498db;
    font-weight: bold;
}

.reply-preview .reply-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ===== حالت ویرایش ===== */
.chat-message.editing .message-text {
    display: none;
}
.chat-message.editing .edit-input {
    display: block;
    width: 100%;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #3498db;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
}
.chat-message.editing .edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.chat-message.editing .edit-actions .msg-action {
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 20px;
}
.chat-message.editing .edit-actions .msg-action.save-edit {
    background: #2ecc71;
    color: #fff;
}
.chat-message.editing .edit-actions .msg-action.save-edit:hover {
    background: #27ae60;
}
.chat-message.editing .edit-actions .msg-action.cancel-edit {
    background: #e74c3c;
    color: #fff;
}
.chat-message.editing .edit-actions .msg-action.cancel-edit:hover {
    background: #c0392b;
}






/* ===== دکمه حذف مکالمه ===== */
.delete-conversation {
    background: transparent;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: 0.3s;
    font-size: 0.8rem;
    flex-shrink: 0;
    opacity: 0;
}

.conversation-item:hover .delete-conversation {
    opacity: 1;
}

.delete-conversation:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
}

/* در موبایل همیشه قابل مشاهده باشد */
@media (max-width: 768px) {
    .delete-conversation {
        opacity: 1;
    }
}