@font-face {
    font-family: 'IranianSans';
    src: url('../font/IranianSans.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* --- تنظیمات کلی و متغیرها --- */
:root {
    --bg-dark: #050510;
    --bg-card: #0f1020;
    --bg-hover: #1a1b35;
    --bg-sidebar: #0f1020;
    --bg-main: #050510;
    --primary: #00f2ff;
    --secondary: #bc13fe;
    --text-main: #e0e6ed;
    --text-muted: #94a3b8;
    --border: #2d2f4a;
    --glass: rgba(15, 16, 32, 0.85);
    --sidebar-width: 350px;
    --header-height: 60px;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(188, 19, 254, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 242, 255, 0.08) 0%, transparent 40%);
    margin: 0;
    padding: 0;
    font-family: 'IranianSans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: block;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
body::-webkit-scrollbar { display: none; }

/* --- استایل‌های اصلی لی‌اوت (Responsive Layout) --- */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
    flex-direction: column; /* پیش‌فرض برای موبایل */
}

/* --- سایدبار (لیست چت‌ها) --- */
.sidebar {
    width: 100%;
    height: 100%;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    overflow: hidden;
}

/* --- محتوای اصلی (صفحه چت) --- */
.main-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    z-index: 20;
    transform: translateX(-100%); /* مخفی در موبایل */
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.main-content.active {
    transform: translateX(0);
}

/* --- مدیا کوئری برای دسکتاپ --- */
@media (min-width: 769px) {
    .app-container {
        flex-direction: row;
        height: 100vh;
    }
    .sidebar {
        width: var(--sidebar-width);
        max-width: 400px;
        border-left: none;
        border-right: 1px solid var(--border);
        order: 2; /* سمت راست */
    }
    .main-content {
        position: relative;
        width: auto;
        flex-grow: 1;
        transform: translateX(0) !important;
        z-index: 5;
        order: 1; /* سمت چپ */
    }
    .desktop-hidden {
        display: none !important;
    }
    .main-content.empty-state {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .main-content.empty-state .chat-container {
        display: none;
    }
    .main-content.empty-state .placeholder-text {
        display: block;
    }
}

@media (max-width: 768px) {
    .main-content.empty-state .placeholder-text {
        display: none;
    }
}

/* --- استایل placeholder --- */
.placeholder-text {
    display: none;
    text-align: center;
    color: var(--text-muted);
}
.placeholder-text img {
    width: 150px;
    opacity: 0.5;
    margin-bottom: 20px;
}

/* --- استایل‌های دکمه نوتیفیکیشن --- */
.notif-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    margin-left: 15px;
    color: var(--text-muted);
    transition: color 0.3s;
}
.notif-toggle-btn.active { color: var(--primary); }
.notif-toggle-btn:hover { opacity: 0.8; }

/* --- استایل دکمه ارسال (اصلاح شده و یکپارچه) --- */
.send-button {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 5px;
    border-radius: 50%;
}
.send-button:hover { background: rgba(255, 255, 255, 0.1); }
.send-button:disabled { opacity: 0.5; cursor: not-allowed; }

/* استایل آیکون دکمه ارسال در چت */
.message-input .send-button img {
    width: 35px;
    height: 35px;
    filter: drop-shadow(0 0 5px var(--primary));
    transition: transform 0.2s;
}
.message-input .send-button:hover img { transform: scale(1.1); }

/* استایل آیکون دکمه ارسال در سایدبار (اگر استفاده شود) */
.sidebar .send-button img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

/* --- استایل بخش ویرایش (Edit Preview) --- */
#edit-preview-area {
    display: none;
    background: rgba(255, 165, 0, 0.15);
    border-right: 3px solid orange;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    align-items: center;
    justify-content: space-between;
    flex-direction: row;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    direction: rtl;
    text-align: right;
    white-space: nowrap;
}
#edit-preview-area .edit-content {
    display: flex;
    align-items: center;
    flex-grow: 1;
    overflow: hidden;
}
#edit-preview-area .edit-label {
    color: orange;
    font-weight: bold;
    margin-right: 8px;
    margin-left: 0;
    flex-shrink: 0;
}
#edit-preview-area .edit-text {
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}
#edit-preview-area .close-edit {
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
    margin-left: 10px;
    margin-right: 0;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
}
#edit-preview-area .close-edit:hover { color: #fff; }

/* --- استایل مودال راهنمای بلاک --- */
#blocked-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}
#blocked-modal.active { display: flex; }
.blocked-content {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
}
.blocked-icon { font-size: 40px; margin-bottom: 15px; display: block; }
.blocked-title { color: var(--primary); font-size: 18px; font-weight: bold; margin-bottom: 10px; }
.blocked-text { color: var(--text-muted); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.blocked-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
    margin-bottom: 10px;
}
.blocked-btn:hover { opacity: 0.9; }
.blocked-btn.secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }

/* --- استایل‌های صفحه لاگین --- */
.login-container {
    background-color: rgba(17, 34, 64, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 45px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: 420px;
    margin: 0;
    text-align: center;
    overflow: hidden;
    display: block;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5000;
}
.login-content { animation: fadeIn 0.6s ease-out; }
.login-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 4px;
    background: linear-gradient(90deg, #64ffda, #0068ff);
}
.login-container h2 {
    color: #64ffda;
    margin-bottom: 35px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(100, 255, 218, 0.3);
}
.login-container label {
    display: block;
    margin-bottom: 8px;
    text-align: right;
    font-weight: 600;
    font-size: 14px;
    color: #8892b0;
}
.login-container input[type="text"],
.login-container input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 24px;
    border: 2px solid #233554;
    border-radius: 12px;
    background-color: rgba(10, 25, 47, 0.6);
    color: #ccd6f6;
    font-size: 15px;
    box-sizing: border-box;
    transition: all 0.3s ease;
    outline: none;
}
.login-container input[type="text"]:focus,
.login-container input[type="password"]:focus {
    border-color: #64ffda;
    background-color: rgba(10, 25, 47, 0.9);
    box-shadow: 0 0 0 4px rgba(100, 255, 218, 0.1);
    transform: translateY(-2px);
}
.login-container button[type="submit"] {
    background: linear-gradient(135deg, #64ffda 0%, #4cd6b3 100%);
    color: #0a192f;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 800;
    transition: all 0.3s ease;
    width: 100%;
    box-shadow: 0 4px 15px rgba(100, 255, 218, 0.2);
    position: relative;
    overflow: hidden;
}
.login-container button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(100, 255, 218, 0.4);
    filter: brightness(1.1);
}
.login-container button[type="submit"]:active { transform: translateY(1px); }
.login-container button[type="submit"]:disabled {
    background: #233554;
    color: #8892b0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.login-container .message {
    color: #ff6b6b;
    margin-bottom: 20px;
    font-size: 14px;
    min-height: 20px;
    font-weight: 500;
    opacity: 0;
    animation: slideDown 0.3s forwards;
}
.login-container .switch-link {
    margin-top: 25px;
    font-size: 14px;
    color: #8892b0;
}
.login-container .switch-link a {
    color: #64ffda;
    text-decoration: none;
    font-weight: 700;
    position: relative;
    transition: color 0.3s;
}
.login-container .switch-link a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    right: 0;
    background-color: #64ffda;
    transition: width 0.3s ease;
}
.login-container .switch-link a:hover { color: #fff; }
.login-container .switch-link a:hover::after { width: 100%; }

/* --- تنظیمات دکمه‌های هدر --- */
.back-link {
    color: #ff4757;
    text-decoration: none;
    font-weight: bold;
    font-size: 12px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.3s;
    background: transparent;
    border: none;
    padding: 0;
}
.back-link:hover { background: rgba(255, 71, 87, 0.1); }
.header-btn {
    background: transparent;
    border: 0px solid var(--border);
    color: var(--text-main);
    padding: 0 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    height: 36px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}
.header-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    color: var(--primary);
}
.header-icon {
    width: 25px;
    height: 25px;
    filter: brightness(0) invert(1);
    vertical-align: middle;
    margin-left: 4px;
}

/* --- تنظیمات موبایل --- */
@media (max-width: 480px) {
    .login-container { width: 90%; padding: 35px 20px; }
    .login-container h2 { font-size: 22px; margin-bottom: 25px; }
}

/* --- انیمیشن‌ها --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- استایل‌های اصلی برنامه (لیست و چت) --- */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 100px;
    position: relative;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(45, 47, 74, 0.5);
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.header h2 {
    margin: 0;
    font-size: 24px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.logout-link {
    color: #ff4757;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 20px;
    transition: all 0.3s ease;
}
.logout-link:hover {
    background: rgba(255, 71, 87, 0.1);
    box-shadow: 0 0 10px rgba(255, 71, 87, 0.4);
}

/* Conversation List */
.conversation-list {
    list-style: none;
    padding: 20px 10px;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    direction: rtl;
}
.conversation-list li { margin-bottom: 2px; perspective: 1000px; }
.conversation-list::-webkit-scrollbar { display: none; }
.convo-link {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 15px;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text-main);
    border: 1px solid var(--border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.convo-link::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: linear-gradient(to bottom, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity 0.3s;
}
.convo-link:hover {
    transform: translateY(-3px) scale(1.01);
    background: var(--bg-hover);
    border-color: var(--primary);
    box-shadow: 0 10px 25px -5px rgba(0, 242, 255, 0.15);
}
.convo-link:hover::before { opacity: 1; }
.convo-link img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    margin-left: 15px;
    transition: border-color 0.3s;
}
.convo-link:hover img { border-color: var(--primary); }
.convo-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}
.convo-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
.chat-name { font-weight: 700; font-size: 16px; color: #fff; }
.unread-dot {
    width: 10px;
    height: 10px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--primary);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 242, 255, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(0, 242, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 242, 255, 0); }
}
.convo-preview {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Floating Button */
.start-chat-link {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 1000;
    transition: transform 0.3s;
}
.start-chat-link:hover { transform: rotate(90deg) scale(1.1); }
.new-message {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(188, 19, 254, 0.4);
    padding: 0;
}
.new-message img { width: 30px; height: 30px; filter: brightness(0) invert(1); margin: 0; border: none; }

/* --- Modals --- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(5, 5, 16, 0.85); backdrop-filter: blur(5px);
    z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal {
    width: 100%; max-width: 400px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 20px; padding: 25px; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: slideUp 0.3s ease-out; direction: rtl;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display:flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { color: var(--primary); font-weight: 800; font-size: 18px; }
.modal-close { background: transparent; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; }

/* --- استایل دکمه‌های منو (عمودی) --- */
.modal-action {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    color: var(--text-main);
    cursor: pointer;
    text-align: center;
    font-weight: 700;
    margin-bottom: 12px;
    transition: 0.2s;
    display: block;
    box-sizing: border-box;
}
.modal-action:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--text-muted);
    transform: translateY(-2px);
}
.modal-action.primary {
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    border: none;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 242, 255, 0.3);
}

/* --- استایل فرم‌ها --- */
.hidden { display: none !important; }
.group-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 12px;
}
.group-form input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    color: #fff;
    outline: none;
    font-family: inherit;
}
.group-form input:focus { border-color: var(--primary); }
.group-form button { width: 100%; box-sizing: border-box; }
.file-row {
    color: var(--text-muted);
    cursor: pointer;
    display: block;
    margin-bottom: 10px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    text-align: center;
    transition: 0.2s;
}
.file-row:hover { border-color: var(--primary); color: var(--primary); }

/* --- SPA Overlay --- */
#spa-overlay {
    position: fixed; inset: 0; background-color: var(--bg-dark); z-index: 3000;
    overflow-y: auto; display: none; transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#spa-overlay.active { display: block; transform: translateX(0); }
#spa-content { width: 100%; min-height: 100%; }

/* --- Chat Container --- */
.chat-container {
    height: 100%;
    width: 100%;
    background-image: url('../icons/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    direction: ltr;
    text-align: left;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.chat-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 25px 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    direction: ltr;
}
.chat-title h3 { color: var(--primary); margin: 0; font-size: 18px; }
.chat-title .sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* --- لیست پیام‌ها --- */
.messages { 
    flex: 1; 
    overflow-y: auto; 
    padding: 20px; 
    display: flex; 
    height: auto;
    flex-direction: column; 
    gap: 15px; 
    scrollbar-width: none;
    -ms-overflow-style: none;
    min-height: 0; 
}
.messages::-webkit-scrollbar { display: none; }
.message { 
    display: flex; 
    flex-direction: column; 
    max-width: 80%; 
    position: relative; 
}
.message.my-message { align-self: flex-end; align-items: flex-end; }
.message.other-message { align-self: flex-start; align-items: flex-start; }
.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 13px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    text-align: left;
    direction: ltr;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;  
}
.my-message .message-content {
    background: linear-gradient(135deg, var(--secondary), #9d00e0);
    color: #fff; 
    border-bottom-right-radius: 18px;
    border-bottom-right-radius: 4px;
}
.other-message .message-content {
    background: var(--bg-card); 
    border: 1px solid var(--border); 
    color: var(--text-main);
    border-bottom-left-radius: 18px;
    border-bottom-left-radius: 4px;
}
.sender-name { 
    font-size: 11px; 
    color: var(--text-muted); 
    margin-bottom: 4px; 
    margin-right: 0;
    margin-left: 5px;
    text-align: left;
    direction: ltr;
}
.timestamp { 
    font-size: 10px; 
    color: rgba(255,255,255,0.5); 
    margin-top: 5px; 
    text-align: right; 
    direction: ltr;
}

/* --- فرم ورودی پیام --- */
.message-input {
    flex-shrink: 0;
    background: var(--bg-card); 
    border-top: 1px solid var(--border); 
    padding: 15px;
    display: flex; 
    flex-direction: column;
    gap: 10px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    z-index: 50;
}
#reply-preview-area {
    display: none;
    background: rgba(0, 242, 255, 0.1);
    border-left: 3px solid var(--primary);
    padding: 8px 12px;
    border-radius: 8px;
    margin: 0 5px;
    position: relative;
    direction: rtl;
    text-align: right;
}
.close-reply {
    position: absolute;
    top: 5px;
    left: 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: bold;
    font-size: 16px;
}
.close-reply:hover { color: #fff; }
.reply-content { margin-left: 25px; }
.reply-author { color: var(--primary); font-size: 12px; font-weight: bold; }
.reply-text { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.message-input input[type="text"] {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 25px;
    padding: 12px 20px;
    color: #fff;
    outline: none;
    font-family: inherit;
    text-align: right;
}
.message-input input[type="text"]:focus { border-color: var(--primary); }
.file-upload-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}
.file-upload-button:hover {
    background: rgba(0, 242, 255, 0.15);
    transform: scale(1.05);
}
.iconfile {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
    pointer-events: none;
}
.message-content a.file-link img {
    width: 250px;
    height: auto;
    border-radius: 12px;
    display: block;
    margin-bottom: 5px;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.1);
}
.message-content a.file-link:not(:has(img)) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    margin-top: 5px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}
.message-content a.file-link:not(:has(img)):hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Context Menu --- */
#context-menu {
    display: none;
    position: fixed;
    z-index: 10000;
    width: 160px;
    margin-left: -400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
    flex-direction: column;
    direction: rtl;
    text-align: right;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
#context-menu .menu-item {
    padding: 12px 15px;
    color: var(--text-main);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}
#context-menu .menu-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--primary);
}
#context-menu .menu-item.delete { color: #ff4757; }
#context-menu .menu-item.delete:hover { background: rgba(255, 71, 87, 0.1); }

/* --- Delete Modal --- */
.delete-modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    z-index: 20000; display: none; align-items: center; justify-content: center; padding: 20px;
}
.delete-modal-box {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    direction: rtl;
}
.delete-modal-icon { font-size: 40px; margin-bottom: 15px; display: block; }
.delete-modal-title { color: #ff4757; font-size: 18px; font-weight: bold; margin-bottom: 10px; }
.delete-modal-desc { color: var(--text-muted); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.delete-modal-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-confirm-delete {
    background: #ff4757; color: white; border: none; padding: 12px; border-radius: 10px;
    width: 100%; font-weight: bold; cursor: pointer; margin-top: 15px;
}
.btn-cancel-delete {
    background: transparent; color: var(--text-muted); border: 1px solid var(--border);
    padding: 12px; border-radius: 10px; width: 100%; margin-top: 10px; cursor: pointer;
}

/* --- Add Member Modal (اصلاح شده) --- */
/* استفاده از کلاس اختصاصی برای جلوگیری از تداخل با delete-modal-backdrop */
.add-member-modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    z-index: 20000; display: none; align-items: center; justify-content: center; padding: 20px;
}
.add-member-modal-backdrop.active { display: flex; }
.dm-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; max-height: 300px; overflow-y: auto; }
.dm-list li {
    padding: 12px; border-bottom: 1px solid var(--border); cursor: pointer;
    display: flex; justify-content: space-between; align-items: center; color: var(--text-main);
}
.dm-list li:hover { background: rgba(255,255,255,0.05); }

/* --- Media Modal (Image/Video) --- */
.media-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.media-modal.active {
    display: flex;
    opacity: 1;
}
.media-content-wrapper {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.media-content-wrapper img, .media-content-wrapper video {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.media-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 40px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.media-close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* --- Audio Player --- */
.custom-audio-player {
    position: relative;
    width: 100%;
    max-width: 300px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    box-sizing: border-box;
    direction: ltr;
    text-align: left;
}
.audio-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.audio-play-btn:hover {
    transform: scale(1.1);
}
.audio-info {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}
.audio-name {
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
    font-weight: bold;
    width: 100%;
}
.audio-progress-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.audio-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}
.audio-progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    border-radius: 2px;
    transition: width 0.1s linear;
}
.audio-times {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 2px;
}

/* --- استایل ویدیو در چت (پیش‌نمایش) --- */
.chat-video-preview {
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    display: block;
    margin-top: 0;
    background: #000;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
    aspect-ratio: 16/9;
    object-fit: cover;
}
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    z-index: 2;
}
.chat-video-preview:hover .video-play-overlay {
    background: rgba(0, 0, 0, 0.2);
}
.video-play-icon {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}
.chat-video-preview:hover .video-play-icon {
    transform: scale(1.1);
}

/* --- تنظیمات نهایی موبایل --- */
@media (max-width: 770px) {
    .header h2 { font-size: 20px; }
    .new-message { width: 55px; height: 55px; }
    #context-menu { margin-left: -100px; }
    .custom-audio-player {
        max-width: 200px;
    }
}