:root {
    --bg-color: #ffffff;
    --sidebar-bg: #ffffff;
    --chat-bg: #87a3b7; /* رنگ قدیمی تلگرام */
    --header-bg: #ffffff;
    --text-primary: #000000;
    --text-secondary: #707579;
    --input-bg: #ffffff;
    --border-color: #dfe1e5;
    --hover-color: #f4f4f5;
    --primary-color: #3390ec;
    --my-msg-bg: #eeffde;
    --other-msg-bg: #ffffff;
    --shadow: 0 1px 2px rgba(0,0,0,0.1);
    --pattern-opacity: 0.4;
    --scroll-thumb: #ced0d1;
}

body.dark-mode {
    --bg-color: #0f0f0f;
    --sidebar-bg: #1c1c1d;
    --chat-bg: #0f0f0f;
    --header-bg: #1c1c1d;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --input-bg: #1c1c1d;
    --border-color: #2f2f2f;
    --hover-color: #2c2c2c;
    --primary-color: #8774e1;
    --my-msg-bg: #8774e1;
    --other-msg-bg: #212121;
    --shadow: none;
    --pattern-opacity: 0.1;
    --scroll-thumb: #444;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: 'Tahoma', 'Vazir', sans-serif; background: var(--bg-color); color: var(--text-primary); height: 100vh; overflow: hidden; }

/* Login */
#login-screen { position: fixed; inset: 0; background: var(--chat-bg); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.login-box { background: var(--sidebar-bg); padding: 30px; border-radius: 15px; width: 300px; text-align: center; box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
.logo-icon { font-size: 50px; color: var(--primary-color); margin-bottom: 10px; }
.login-box input { width: 100%; padding: 12px; margin: 15px 0; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-color); color: var(--text-primary); text-align: center;}
.login-box button { width: 100%; padding: 12px; background: var(--primary-color); color: white; border: none; border-radius: 10px; cursor: pointer; font-size: 16px; font-weight: bold; }
.hint { font-size: 12px; color: var(--text-secondary); margin-top: 10px; }

/* Layout */
.app-container { display: flex; height: 100%; width: 100%; max-width: 1600px; margin: 0 auto; }

/* Sidebar */
.sidebar { width: 350px; background: var(--sidebar-bg); border-left: 1px solid var(--border-color); display: flex; flex-direction: column; transition: transform 0.3s; }
.sidebar-header { padding: 10px 15px; display: flex; align-items: center; gap: 15px; }
.search-box { flex: 1; padding: 8px 15px; background: var(--hover-color); border: 1px solid transparent; border-radius: 20px; color: var(--text-primary); transition: 0.2s; }
.search-box:focus { border-color: var(--primary-color); background: var(--bg-color); }
.menu-icon { color: var(--text-secondary); cursor: pointer; }

#user-list { flex: 1; overflow-y: auto; }
.user-item { padding: 10px 15px; display: flex; align-items: center; cursor: pointer; transition: 0.2s; }
.user-item:hover, .user-item.active { background: var(--hover-color); }
.user-item.active { background: var(--primary-color); }
.user-item.active .user-name, .user-item.active .user-last-msg { color: white; }
.avatar { width: 48px; height: 48px; border-radius: 50%; margin-left: 12px; background: #ddd; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-last-msg { font-size: 14px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge { background: #00c853; color: white; border-radius: 10px; padding: 2px 8px; font-size: 11px; font-weight: bold; }

/* Chat Area */
.chat-area { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.chat-area::before { content: ""; position: absolute; inset: 0; background-image: url('https://web.telegram.org/img/bg_0.png'); background-size: 400px; opacity: var(--pattern-opacity); pointer-events: none; }

.chat-header { padding: 8px 15px; background: var(--header-bg); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; z-index: 10; cursor: pointer;}
.header-left { display: flex; align-items: center; }
.header-right { display: flex; align-items: center; gap: 15px; color: var(--text-secondary); }
.back-btn { display: none; background: none; border: none; font-size: 18px; color: var(--text-secondary); margin-left: 10px; cursor: pointer; }
.chat-status { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

#empty-state { flex: 1; display: flex; justify-content: center; align-items: center; }
.bubble { background: rgba(0,0,0,0.3); color: white; padding: 5px 15px; border-radius: 20px; font-size: 14px; }

.chat-messages { flex: 1; overflow-y: auto; padding: 10px 5%; display: flex; flex-direction: column; gap: 6px; z-index: 5; scroll-behavior: smooth; }
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }

.message { max-width: 75%; padding: 6px 10px 6px 10px; border-radius: 12px; position: relative; font-size: 15px; box-shadow: var(--shadow); line-height: 1.4; word-wrap: break-word; }
.message.sent { background: var(--my-msg-bg); align-self: flex-start; border-bottom-right-radius: 2px; color: var(--text-primary); }
.message.sent.dark-mode-fix { color: white; } /* Fix text color for sent msg in dark mode */
.message.received { background: var(--other-msg-bg); align-self: flex-end; border-bottom-left-radius: 2px; color: var(--text-primary); }

.msg-info { float: left; display: flex; align-items: center; margin-right: 8px; margin-top: 6px; opacity: 0.6; font-size: 11px; user-select: none; }
.tick { margin-right: 2px; font-size: 12px; }
.read { color: #4fc3f7; }

/* Input Area */
.chat-input-area { padding: 8px 15px; background: var(--header-bg); display: flex; align-items: center; gap: 10px; z-index: 20; position: relative; }
.chat-input-area input { flex: 1; padding: 12px; border: none; background: transparent; color: var(--text-primary); font-size: 16px; }
.emoji-btn, .send-btn { color: var(--text-secondary); font-size: 22px; cursor: pointer; background: none; border: none; transition: 0.2s; }
.emoji-btn:hover { color: var(--primary-color); }
.send-btn { color: var(--primary-color); }

/* Emoji Picker */
.emoji-picker {
    display: none; position: absolute; bottom: 65px; right: 10px; 
    width: 300px; height: 250px; background: var(--sidebar-bg); 
    border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); 
    overflow-y: auto; padding: 10px; grid-template-columns: repeat(6, 1fr); gap: 5px;
    border: 1px solid var(--border-color);
}
.emoji-picker.show { display: grid; }
.emoji-item { font-size: 24px; cursor: pointer; text-align: center; padding: 5px; border-radius: 5px; }
.emoji-item:hover { background: var(--hover-color); }

/* Responsive Media Queries */
@media (max-width: 768px) {
    .app-container { position: relative; overflow: hidden; }
    .sidebar { width: 100%; height: 100%; position: absolute; z-index: 15; }
    .chat-area { width: 100%; height: 100%; position: absolute; z-index: 10; }
    
    /* When chat is open (controlled by JS class) */
    .app-container.chat-active .sidebar { transform: translateX(100%); } /* Hide sidebar */
    .back-btn { display: block; }
}

/* تمام استایل‌های قبلی را نگه دارید و این‌ها را اضافه/جایگزین کنید */

/* استایل فایل‌ها در چت */
.msg-image { max-width: 100%; border-radius: 10px; margin-bottom: 5px; cursor: pointer; display: block;}
.msg-audio { width: 250px; margin-bottom: 5px; }
.msg-file { 
    display: flex; align-items: center; background: rgba(0,0,0,0.05); 
    padding: 10px; border-radius: 8px; text-decoration: none; color: inherit; 
    margin-bottom: 5px;
}
.msg-file i { font-size: 24px; margin-left: 10px; color: var(--primary-color); }
.file-name { font-size: 13px; font-weight: bold; word-break: break-all;}

/* دکمه پیوست */
.attach-btn { font-size: 22px; color: var(--text-secondary); cursor: pointer; padding: 0 10px; transform: rotate(45deg); transition: 0.2s; }
.attach-btn:hover { color: var(--primary-color); }

/* ضبط صدا */
.recording { color: red !important; animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* منوی پروفایل */
.profile-menu {
    display: none; position: absolute; top: 50px; right: 10px;
    background: var(--sidebar-bg); border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2); border-radius: 8px; z-index: 100;
}
.profile-menu.show { display: block; }
.menu-item { padding: 10px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px; color: var(--text-primary); }
.menu-item:hover { background: var(--hover-color); }

/* بهبود سایدبار برای نمایش آخرین پیام */
.user-last-msg {
    font-size: 13px; opacity: 0.7; height: 18px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.tick.read { color: #4fc3f7; }
.tick.unread { color: #a0a0a0; }

/* ... تمام کدهای قبلی را حفظ کنید ... */

/* اضافه کردن این موارد جدید: */

/* هدر سایدبار و عکس خودم */
.my-avatar-small {
    width: 35px; height: 35px; border-radius: 50%; object-fit: cover; cursor: pointer; margin-left: 10px;
}

/* استایل پیام حذف شده برای ادمین */
.message.deleted-message {
    opacity: 0.6;
    border: 1px dashed #ff4444;
    background-color: #ffe6e6 !important;
}
.message.deleted-message::after {
    content: "🗑️ (حذف شده توسط کاربر)";
    display: block; font-size: 10px; color: #cc0000; margin-top: 5px; font-weight: bold;
}
.dark-mode .message.deleted-message {
    background-color: #3e2020 !important;
    border-color: #ff6b6b;
}

/* منوی راست کلیک (Context Menu) */
.context-menu {
    display: none; position: absolute; z-index: 1000;
    background: var(--sidebar-bg); border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2); border-radius: 5px; width: 150px;
}
.context-item {
    padding: 10px 15px; cursor: pointer; display: flex; align-items: center; gap: 10px; color: var(--text-primary); font-size: 14px;
}
.context-item:hover { background: var(--hover-color); }
.context-item.delete-option { color: #ff4444; }

/* مودال نمایش عکس */
.modal {
    display: none; position: fixed; z-index: 3000; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.85); align-items: center; justify-content: center;
}
.modal-content {
    max-width: 90%; max-height: 90%; border-radius: 10px; box-shadow: 0 0 20px rgba(255,255,255,0.2);
}
.close-modal {
    position: absolute; top: 20px; right: 30px; color: #fff; font-size: 40px; font-weight: bold; cursor: pointer;
}

/* ... استایل‌های قبلی ثابت ... */

/* تغییر مهم: سایز عکس در چت */
.msg-image {
    width: 200px;         /* عرض ثابت */
    height: 200px;        /* ارتفاع ثابت */
    object-fit: cover;    /* برش عکس به صورت مربعی و منظم */
    border-radius: 10px;
    margin-bottom: 5px;
    cursor: pointer;
    display: block;
    transition: transform 0.2s;
}
.msg-image:hover {
    transform: scale(1.02);
}

/* استایل مودال ویرایش پروفایل */
.edit-profile-form {
    display: flex; flex-direction: column; gap: 15px; width: 100%;
}
.edit-profile-form input {
    padding: 10px; border: 1px solid #ccc; border-radius: 5px; background: #fff; color: #000;
}
.edit-profile-form button {
    padding: 10px; background: var(--primary-color); color: white; border: none; border-radius: 5px; cursor: pointer;
}

/* برای حالت دارک مود اینپوت ها */
.dark-mode .edit-profile-form input {
    background: #2c2c2c; color: white; border-color: #444;
}

/* ... بقیه کدهای قبلی ... */

/* ... کدهای قبلی ... */

/* --- استایل پلیر صوتی شبیه تلگرام --- */
.custom-audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    min-width: 250px;
}

/* دکمه پخش */
.audio-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}
.audio-play-btn:hover {
    filter: brightness(1.1);
}
.received .audio-play-btn {
    background-color: #3390ec; /* آبی برای پیام دریافتی */
}
.sent .audio-play-btn {
    background-color: #ffffff; /* سفید برای پیام ارسالی */
    color: var(--primary-color);
}
.dark-mode .sent .audio-play-btn {
    background-color: #8774e1;
    color: white;
}

/* نوار پیشرفت (Progress Bar) */
.audio-progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.audio-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(0,0,0,0.2);
    outline: none;
    cursor: pointer;
    margin-bottom: 4px;
}
.dark-mode .audio-slider {
    background: rgba(255,255,255,0.2);
}

/* استایل تامب (دکمه روی اسلایدر) */
.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}
.sent .audio-slider::-webkit-slider-thumb {
    background: #fff;
}
.received .audio-slider::-webkit-slider-thumb {
    background: #3390ec;
}
.dark-mode .sent .audio-slider::-webkit-slider-thumb {
    background: #8774e1;
}

/* تایمر */
.audio-time {
    font-size: 11px;
    opacity: 0.7;
    align-self: flex-start;
}

/* دکمه سرعت */
.audio-speed-btn {
    background: rgba(0,0,0,0.1);
    border: none;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-primary);
    width: 35px;
    text-align: center;
}
.sent .audio-speed-btn {
    background: rgba(255,255,255,0.3);
    color: #000;
}
.dark-mode .sent .audio-speed-btn {
    color: #fff;
    background: rgba(0,0,0,0.3);
}

/* این را به style.css اضافه کنید اگر خط جدا کننده نداشت */
#admin-options {
    border-top: 1px solid var(--border-color);
    margin-top: 5px;
    padding-top: 5px;
}
.dark-mode #admin-options {
    border-top-color: #444;
}


/* ... کدهای قبلی ... */

/* آیکون‌های هدر */
.action-icon {
    margin-right: 15px;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
}
.action-icon:hover {
    color: var(--primary-color);
}

/* نوار جستجو */
.search-bar-container {
    display: none; /* پیش‌فرض مخفی */
    flex-direction: row;
    align-items: center;
    background: var(--header-bg);
    padding: 8px 15px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    z-index: 9;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    margin-left: 10px;
}

.search-icon-inside {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
}

#chat-search-input {
    width: 100%;
    padding: 8px 35px 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--hover-color);
    color: var(--text-primary);
    font-size: 14px;
}

.search-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

#search-counter {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 10px;
    min-width: 40px;
    text-align: center;
}

.search-controls button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    font-size: 14px;
}
.search-controls button:hover {
    color: var(--primary-color);
}
.close-search-btn {
    font-size: 12px !important;
    font-weight: bold;
    color: var(--primary-color) !important;
}

/* استایل هایلایت متن */
mark {
    background-color: #ffeb3b;
    color: black;
    border-radius: 2px;
    padding: 0 2px;
}

/* هایلایت فعال (اونی که الان روش هستیم) */
mark.current-highlight {
    background-color: #ff9800;
    color: white;
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
}

.dark-mode mark {
    background-color: #5d4037;
    color: white;
}
.dark-mode mark.current-highlight {
    background-color: #ff9800;
    color: white;
}

/* برای اطمینان از اینکه متن پیام در یک کانتینر مشخص است */
.msg-content-wrapper {
    display: inline-block; /* یا block */
}

/* ... کدهای قبلی ... */

/* نوار پیش‌نمایش ریپلای (بالای اینپوت) */
.reply-preview-bar {
    position: absolute;
    bottom: 100%; /* می‌چسبد به بالای اینپوت */
    left: 0;
    right: 0;
    background: var(--header-bg);
    border-top: 1px solid var(--border-color);
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 15;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.reply-content {
    display: flex;
    align-items: center;
    overflow: hidden;
    border-right: 3px solid var(--primary-color); /* خط رنگی سمت راست */
    padding-right: 10px;
}
.reply-info {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    margin-right: 10px;
}
.reply-to-name {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 12px;
}
.reply-to-text {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}
.close-reply {
    cursor: pointer;
    color: var(--text-secondary);
    padding: 5px;
}

/* استایل پیام ریپلای شده داخل حباب چت */
.msg-reply-quote {
    display: block;
    margin-bottom: 5px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-right: 3px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.dark-mode .msg-reply-quote {
    background: rgba(255, 255, 255, 0.1);
}
.reply-sender {
    display: block;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 2px;
}
.reply-text-preview {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sent .reply-text-preview {
    color: #555;
}

/* انیمیشن در حال نوشتن */
.typing-indicator {
    font-size: 12px;
    color: var(--primary-color);
    font-style: italic;
    animation: pulse 1.5s infinite;
}

:root {
    --bg-color: #ffffff;
    --sidebar-bg: #ffffff;
    --chat-bg: #87a3b7;
    --header-bg: #ffffff;
    --text-primary: #000000;
    --text-secondary: #707579;
    --input-bg: #ffffff;
    --border-color: #dfe1e5;
    --hover-color: #f4f4f5;
    --primary-color: #3390ec;
    --my-msg-bg: #eeffde;
    --other-msg-bg: #ffffff;
    --shadow: 0 1px 2px rgba(0,0,0,0.1);
    --pattern-opacity: 0.4;
    --scroll-thumb: #ced0d1;
}

body.dark-mode {
    --bg-color: #0f0f0f;
    --sidebar-bg: #1c1c1d;
    --chat-bg: #0f0f0f;
    --header-bg: #1c1c1d;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --input-bg: #1c1c1d;
    --border-color: #2f2f2f;
    --hover-color: #2c2c2c;
    --primary-color: #8774e1;
    --my-msg-bg: #8774e1;
    --other-msg-bg: #212121;
    --shadow: none;
    --pattern-opacity: 0.1;
    --scroll-thumb: #444;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: 'Tahoma', 'Vazir', sans-serif; background: var(--bg-color); color: var(--text-primary); height: 100vh; overflow: hidden; }

/* Login */
#login-screen { position: fixed; inset: 0; background: var(--chat-bg); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.login-box { background: var(--sidebar-bg); padding: 30px; border-radius: 15px; width: 300px; text-align: center; box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
.logo-icon { font-size: 50px; color: var(--primary-color); margin-bottom: 10px; }
.login-box input { width: 100%; padding: 12px; margin: 15px 0; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-color); color: var(--text-primary); text-align: center;}
.login-box button { width: 100%; padding: 12px; background: var(--primary-color); color: white; border: none; border-radius: 10px; cursor: pointer; font-size: 16px; font-weight: bold; }

/* Layout */
.app-container { display: flex; height: 100%; width: 100%; max-width: 1600px; margin: 0 auto; }

/* Sidebar */
.sidebar { width: 350px; background: var(--sidebar-bg); border-left: 1px solid var(--border-color); display: flex; flex-direction: column; transition: transform 0.3s; }
.sidebar-header { padding: 10px 15px; display: flex; align-items: center; justify-content: space-between; height: 60px; background: var(--header-bg); border-bottom: 1px solid var(--border-color); }
.menu-icon { color: var(--text-secondary); cursor: pointer; font-size: 20px; }
.my-avatar-small { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; cursor: pointer; }

#user-list { flex: 1; overflow-y: auto; }
.user-item { padding: 10px 15px; display: flex; align-items: center; cursor: pointer; transition: 0.2s; }
.user-item:hover, .user-item.active { background: var(--hover-color); }
.user-item.active { background: var(--primary-color); }
.user-item.active .user-name, .user-item.active .user-last-msg { color: white; }
.avatar { width: 48px; height: 48px; border-radius: 50%; margin-left: 12px; background: #ddd; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-last-msg { font-size: 14px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge { background: #00c853; color: white; border-radius: 10px; padding: 2px 8px; font-size: 11px; font-weight: bold; }

/* Chat Area */
.chat-area { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.chat-area::before { content: ""; position: absolute; inset: 0; background-image: url('https://web.telegram.org/img/bg_0.png'); background-size: 400px; opacity: var(--pattern-opacity); pointer-events: none; }

.chat-header { padding: 8px 15px; background: var(--header-bg); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; z-index: 10; height: 60px; }
.header-left { display: flex; align-items: center; }
.header-right { display: flex; align-items: center; gap: 15px; color: var(--text-secondary); }
.back-btn { display: none; background: none; border: none; font-size: 18px; color: var(--text-secondary); margin-left: 10px; cursor: pointer; }
.chat-status { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.action-icon { cursor: pointer; font-size: 18px; transition: 0.2s; }
.action-icon:hover { color: var(--primary-color); }

#empty-state { flex: 1; display: flex; justify-content: center; align-items: center; }
.bubble { background: rgba(0,0,0,0.3); color: white; padding: 5px 15px; border-radius: 20px; font-size: 14px; }

.chat-messages { flex: 1; overflow-y: auto; padding: 10px 5%; display: flex; flex-direction: column; gap: 6px; z-index: 5; scroll-behavior: smooth; }
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }

/* Message Styles */
.message { max-width: 75%; padding: 6px 10px 6px 10px; border-radius: 12px; position: relative; font-size: 15px; box-shadow: var(--shadow); line-height: 1.4; word-wrap: break-word; }
.message.sent { background: var(--my-msg-bg); align-self: flex-start; border-bottom-right-radius: 2px; color: var(--text-primary); }
.message.sent.dark-mode-fix { color: white; }
.message.received { background: var(--other-msg-bg); align-self: flex-end; border-bottom-left-radius: 2px; color: var(--text-primary); }
.message.deleted-message { opacity: 0.6; border: 1px dashed #ff4444; background-color: #ffe6e6 !important; }
.message.deleted-message::after { content: "🗑️ حذف شده"; display: block; font-size: 10px; color: #cc0000; margin-top: 5px; font-weight: bold; }

/* Sticker Message (No Bubble) */
.message.sticker-msg { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.msg-sticker-img { width: 160px; height: 160px; object-fit: contain; display: block; cursor: pointer; }
.message.sticker-msg .msg-info { background: rgba(0, 0, 0, 0.3); color: white !important; padding: 2px 6px; border-radius: 10px; position: absolute; bottom: 5px; right: 5px; font-size: 10px; }

/* Media Content */
.msg-image { width: 200px; height: 200px; object-fit: cover; border-radius: 10px; margin-bottom: 5px; cursor: pointer; display: block; transition: transform 0.2s; }
.msg-image:hover { transform: scale(1.02); }
.msg-file { display: flex; align-items: center; background: rgba(0,0,0,0.05); padding: 10px; border-radius: 8px; text-decoration: none; color: inherit; margin-bottom: 5px; }
.msg-file i { font-size: 24px; margin-left: 10px; color: var(--primary-color); }
.file-name { font-size: 13px; font-weight: bold; word-break: break-all;}

.msg-info { float: left; display: flex; align-items: center; margin-right: 8px; margin-top: 2px; opacity: 0.6; font-size: 11px; user-select: none; }
.tick { margin-right: 2px; font-size: 12px; }
.read { color: #4fc3f7; }

/* Input Area */
.chat-input-area { padding: 8px 15px; background: var(--header-bg); display: flex; align-items: center; gap: 10px; z-index: 20; position: relative; }
.chat-input-area input { flex: 1; padding: 12px; border: none; background: transparent; color: var(--text-primary); font-size: 16px; }
.emoji-btn, .send-btn { color: var(--text-secondary); font-size: 22px; cursor: pointer; background: none; border: none; transition: 0.2s; }
.emoji-btn:hover { color: var(--primary-color); }
.send-btn { color: var(--primary-color); }
.attach-btn { font-size: 22px; color: var(--text-secondary); cursor: pointer; padding: 0 10px; transform: rotate(45deg); transition: 0.2s; }
.attach-btn:hover { color: var(--primary-color); }

/* Emoji/Sticker Picker */
.emoji-picker { display: none; position: absolute; bottom: 65px; right: 10px; width: 320px; height: 350px; background: var(--sidebar-bg); border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); border: 1px solid var(--border-color); flex-direction: column; overflow: hidden; z-index: 100; }
.picker-tabs { display: flex; background: var(--header-bg); border-bottom: 1px solid var(--border-color); }
.picker-tab { flex: 1; text-align: center; padding: 10px; cursor: pointer; font-size: 14px; color: var(--text-secondary); transition: 0.2s; border-bottom: 2px solid transparent; }
.picker-tab.active { color: var(--primary-color); border-bottom-color: var(--primary-color); font-weight: bold; }
.picker-tab:hover { background: var(--hover-color); }
.picker-content { flex: 1; overflow-y: auto; padding: 10px; display: none; }
.picker-content.active { display: grid; }
#emoji-view { grid-template-columns: repeat(8, 1fr); gap: 5px; }
.emoji-item { font-size: 22px; cursor: pointer; text-align: center; padding: 5px; border-radius: 5px; }
.emoji-item:hover { background: var(--hover-color); }
#sticker-view { grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sticker-item { width: 100%; aspect-ratio: 1; object-fit: contain; cursor: pointer; transition: transform 0.1s; }
.sticker-item:hover { transform: scale(1.1); }
.emoji-picker.show { display: flex; }

/* Reply Bar */
.reply-preview-bar { position: absolute; bottom: 100%; left: 0; right: 0; background: var(--header-bg); border-top: 1px solid var(--border-color); padding: 8px 15px; display: flex; justify-content: space-between; align-items: center; z-index: 15; animation: slideUp 0.2s ease-out; }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.reply-content { display: flex; align-items: center; overflow: hidden; border-right: 3px solid var(--primary-color); padding-right: 10px; }
.reply-info { display: flex; flex-direction: column; font-size: 13px; margin-right: 10px; }
.reply-to-name { color: var(--primary-color); font-weight: bold; font-size: 12px; }
.reply-to-text { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.msg-reply-quote { display: block; margin-bottom: 5px; padding: 4px 8px; background: rgba(0, 0, 0, 0.05); border-right: 3px solid var(--primary-color); border-radius: 4px; cursor: pointer; font-size: 12px; }
.dark-mode .msg-reply-quote { background: rgba(255, 255, 255, 0.1); }
.reply-sender { display: block; font-weight: bold; color: var(--primary-color); margin-bottom: 2px; }
.reply-text-preview { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Audio Player */
.custom-audio-player { display: flex; align-items: center; gap: 10px; padding: 5px 0; min-width: 250px; }
.audio-play-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background-color: var(--primary-color); color: white; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.audio-progress-container { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.audio-slider { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 2px; background: rgba(0,0,0,0.2); outline: none; cursor: pointer; margin-bottom: 4px; }
.audio-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--primary-color); cursor: pointer; }
.audio-time { font-size: 11px; opacity: 0.7; align-self: flex-start; }
.audio-speed-btn { background: rgba(0,0,0,0.1); border: none; border-radius: 12px; padding: 2px 8px; font-size: 11px; font-weight: bold; cursor: pointer; color: var(--text-primary); width: 35px; text-align: center; }

/* Search Bar */
.search-bar-container { display: none; flex-direction: row; align-items: center; background: var(--header-bg); padding: 8px 15px; border-bottom: 1px solid var(--border-color); z-index: 9; animation: slideDown 0.2s ease-out; }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.search-input-wrapper { flex: 1; position: relative; margin-left: 10px; }
.search-icon-inside { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 14px; }
#chat-search-input { width: 100%; padding: 8px 35px 8px 10px; border: 1px solid var(--border-color); border-radius: 20px; background: var(--hover-color); color: var(--text-primary); font-size: 14px; }
.search-controls { display: flex; align-items: center; gap: 5px; }
#search-counter { font-size: 12px; color: var(--text-secondary); margin-left: 10px; min-width: 40px; text-align: center; }
.search-controls button { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 5px; font-size: 14px; }
.close-search-btn { font-size: 12px !important; font-weight: bold; color: var(--primary-color) !important; }
mark { background-color: #ffeb3b; color: black; border-radius: 2px; padding: 0 2px; }
mark.current-highlight { background-color: #ff9800; color: white; }

/* Context & Modals */
.context-menu { display: none; position: absolute; z-index: 1000; background: var(--sidebar-bg); border: 1px solid var(--border-color); box-shadow: 0 5px 15px rgba(0,0,0,0.2); border-radius: 5px; width: 150px; }
.context-item { padding: 10px 15px; cursor: pointer; display: flex; align-items: center; gap: 10px; color: var(--text-primary); font-size: 14px; }
.context-item:hover { background: var(--hover-color); }
.context-item.delete-option { color: #ff4444; }
.profile-menu { display: none; position: absolute; top: 50px; right: 10px; background: var(--sidebar-bg); border: 1px solid var(--border-color); box-shadow: 0 5px 15px rgba(0,0,0,0.2); border-radius: 8px; z-index: 100; }
.profile-menu.show { display: block; }
.menu-item { padding: 10px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px; color: var(--text-primary); }
.menu-item:hover { background: var(--hover-color); }
.modal { display: none; position: fixed; z-index: 3000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.85); align-items: center; justify-content: center; }
.modal-content { max-width: 90%; max-height: 90%; border-radius: 10px; }
.close-modal { position: absolute; top: 20px; right: 30px; color: #fff; font-size: 40px; font-weight: bold; cursor: pointer; }
.edit-profile-form { display: flex; flex-direction: column; gap: 15px; width: 100%; }
.edit-profile-form input { padding: 10px; border: 1px solid #ccc; border-radius: 5px; background: #fff; color: #000; }
.edit-profile-form button { padding: 10px; background: var(--primary-color); color: white; border: none; border-radius: 5px; cursor: pointer; }
.dark-mode .edit-profile-form input { background: #2c2c2c; color: white; border-color: #444; }
.typing-indicator { font-size: 12px; color: var(--primary-color); font-style: italic; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container { position: relative; overflow: hidden; }
    .sidebar { width: 100%; height: 100%; position: absolute; z-index: 15; }
    .chat-area { width: 100%; height: 100%; position: absolute; z-index: 10; }
    .app-container.chat-active .sidebar { transform: translateX(100%); }
    .back-btn { display: block; }
}