/* =========================================
   Reset Box Model
   ========================================= */
*, *::before, *::after {
    box-sizing: border-box;
}

/* =========================================
   متغیرهای رنگی
   ========================================= */
:root {
    --bg-color: #e5ddd5;
    --sidebar-bg: #ffffff;
    --header-bg: #f0f2f5;
    --chat-bg: #efeae2;
    --msg-sent-bg: #d9fdd3;
    --msg-received-bg: #ffffff;
    --text-main: #111b21;
    --text-muted: #667781;
    --border-color: #d1d7db;
    --primary-color: #00a884;
    --blue-tick: #53bdeb;
}

/* =========================================
   تنظیمات پایه
   ========================================= */
html, body {
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    font-family: 'VazirFD', Tahoma, sans-serif;
    width: 100%;
    height: 100dvh;
    position: fixed;
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    overflow: hidden !important; 
    overscroll-behavior-y: none;
}

.app-container {
    position: absolute;
    inset: 0;
    width: 100%; 
    height: 100%; 
    display: flex; 
    overflow: hidden;
    background-color: #fff;
}

/* =========================================
   اسکرول سفارشی
   ========================================= */
.dialogs-list-container {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.dialogs-list {
    overflow: visible;
    background: transparent;
}

.chat-body {
    flex: 1 1 auto !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 15px;
    display: flex;
    flex-direction: column;
    background-image: url('../images/bg.png'); 
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    -webkit-overflow-scrolling: touch;
}

.settings-drawer-body,
.profile-drawer-content,
.modal-body,
.drawer-menu {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* اسکرول‌بار سفارشی */
.dialogs-list-container::-webkit-scrollbar,
.chat-body::-webkit-scrollbar,
#message-input::-webkit-scrollbar,
.settings-drawer-body::-webkit-scrollbar,
.profile-drawer-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar { 
    width: 6px; 
}

.dialogs-list-container::-webkit-scrollbar-thumb,
.chat-body::-webkit-scrollbar-thumb,
#message-input::-webkit-scrollbar-thumb,
.settings-drawer-body::-webkit-scrollbar-thumb,
.profile-drawer-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb { 
    background-color: rgba(0,0,0,0.2); 
    border-radius: 10px; 
}

/* =========================================
   Sidebar
   ========================================= */
.sidebar, aside.sidebar {
    width: 350px;
    min-width: 300px;
    background-color: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    overflow: hidden;
}

.sidebar-header, #main-sidebar-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    min-height: 65px;
    padding-top: max(15px, env(safe-area-inset-top)) !important;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.dialog-item-wrapper {
    position: relative;
    background: #fff;
    border-bottom: 1px solid #f0f2f5;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 0.2s;
}

.dialog-item-wrapper:hover, .dialog-item.active { 
    background-color: #f5f6f6; 
}

.dialog-item {
    position: relative;
    z-index: 2;
    width: 100%;
    border-bottom: none !important;
}

/* =========================================
   Chat Area
   ========================================= */
.chat-area {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    background-color: var(--chat-bg);
    position: relative;
    height: 100% !important;
    width: 100%;
    overflow: hidden !important;
    z-index: 5;
}

.chat-header, #chat-header-section {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
    flex: 0 0 auto !important;
    padding-top: max(10px, env(safe-area-inset-top)) !important;
    display: flex;
    align-items: center;
    min-height: 65px;
    width: 100% !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

.back-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0 10px 0 0;
}

/* =========================================
   حباب پیام‌ها
   ========================================= */
.message-bubble {
    position: relative;
    padding: 8px 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    word-wrap: break-word;
    font-size: 14.5px;
    line-height: 1.5;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    display: inline-block;
    color: var(--text-main);
    word-break: break-word;
    max-width: 75%;
}

.msg-text {
    word-break: break-word;
}

.message-link {
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: break-word;
}

.msg-meta {
    font-size: 11px;
    color: var(--text-muted);
    float: left;
    margin-top: 4px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    gap: 3px;
    line-height: 1;
}

.msg-meta .tick { 
    font-size: 14px; 
}

.msg-meta .tick.read { 
    color: var(--blue-tick); 
}

.reply-box {
    border-right: 4px solid var(--primary-color);
    background: rgba(0, 0, 0, 0.05);
    padding: 5px 10px;
    border-radius: 5px;
    margin-bottom: 5px;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
}

.msg-search-highlight { 
    background-color: #ffc107 !important; 
    transition: background-color 0.5s; 
}

.unread-divider { 
    text-align: center; 
    margin: 15px 0; 
    position: relative; 
}

.unread-divider::before { 
    content: ""; 
    position: absolute; 
    top: 50%; 
    left: 0; 
    right: 0; 
    border-top: 1px solid var(--primary-color); 
    z-index: 1; 
    opacity: 0.5; 
}

.unread-divider span { 
    background: #fff; 
    padding: 0 10px; 
    color: var(--primary-color); 
    font-size: 12px; 
    font-weight: bold; 
    position: relative; 
    z-index: 2; 
    border-radius: 10px; 
    border: 1px solid var(--primary-color); 
}

/* =========================================
   Input Area
   ========================================= */
.chat-footer, #chat-footer-section {
    background-color: var(--header-bg);
    border-top: 1px solid var(--border-color);
    padding: 8px 12px;
    padding-bottom: max(0px, env(safe-area-inset-bottom)) !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    z-index: 100 !important;
    position: relative;
}

#message-input {
    resize: none;
    overflow-y: auto;
    min-height: 40px;
    max-height: 120px;
    font-size: 15px;
    direction: rtl;
    text-align: right;
    line-height: 1.5;
    touch-action: pan-y;
    border-radius: 20px;
}

/* =========================================
   Drawer منوی کناری (به سبک تلگرام)
   ========================================= */
.drawer-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100dvh; 
    background: rgba(0,0,0,0.5); 
    z-index: 1040; 
    display: none; 
    opacity: 0; 
    transition: opacity 0.3s; 
}

.drawer-overlay.show { 
    display: block; 
    opacity: 1; 
}

.telegram-drawer { 
    position: fixed; 
    top: 0; 
    right: -300px; 
    width: 300px;
    height: 100dvh; 
    background: #fff; 
    z-index: 1050; 
    transition: right 0.3s ease; 
    box-shadow: -2px 0 8px rgba(0,0,0,0.1); 
    display: flex; 
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.telegram-drawer.open { 
    right: 0; 
}

.drawer-header {
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-right: 16px;
    padding-bottom: 16px;
    padding-left: 16px;
    border-bottom: 1px solid #e4e4e5;
    background: #00a884;
}

.drawer-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.drawer-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    background: #e4e4e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 500;
    color: #fff;
}

.drawer-info {
    flex: 1;
    text-align: right;
}

.drawer-name {
    font-size: 18px;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 2px;
}

.drawer-phone {
    font-size: 13px;
    color: #2d2f30;
}

.drawer-username {
    font-size: 12px;
    color: #ffffff;
    margin-top: 2px;
    direction: ltr;
}

.drawer-menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.drawer-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 16px;
    cursor: pointer;
    transition: background 0.2s;
    color: #000;
    text-decoration: none;
}

.drawer-menu-item:hover {
    background: #f5f5f5;
}

.drawer-menu-item .menu-icon {
    width: 24px;
    text-align: center;
    font-size: 20px;
    color: #707579;
}

.drawer-menu-item .menu-text {
    font-size: 16px;
    flex: 1;
}

.drawer-menu-item.danger .menu-text {
    color: #e53935;
}

.drawer-menu-item.danger .menu-icon {
    color: #e53935;
}

.drawer-divider {
    height: 8px;
    background: #f5f5f5;
    margin: 4px 0;
}

.drawer-version {
    padding: 20px 20px 30px;
    font-size: 12px;
    color: #a2acb4;
    text-align: center;
}

/* =========================================
   منوهای راست کلیک
   ========================================= */
.custom-context-menu {
    display: none; 
    position: absolute; 
    background: #fff; 
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    border-radius: 8px; 
    overflow: hidden;
    min-width: 160px; 
    padding: 5px 0; 
    border: 1px solid #eaeaea; 
    direction: rtl;
}

.context-item { 
    padding: 10px 15px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-size: 14px; 
    color: #333; 
    transition: background 0.2s; 
}

.context-item:hover { 
    background: #f0f2f5; 
}

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

.context-item.danger:hover { 
    background: #ffebee; 
}

.custom-dropdown-menu { 
    display: none; 
    position: absolute; 
    top: 50px; 
    left: 15px; 
    background: white; 
    border-radius: 8px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.15); 
    min-width: 180px; 
    z-index: 1060; 
    padding: 5px 0; 
}

.custom-dropdown-menu a { 
    display: block; 
    padding: 10px 15px; 
    text-decoration: none; 
    color: #333; 
    font-size: 14px; 
}

.custom-dropdown-menu a:hover { 
    background-color: #f8f9fa; 
}

/* =========================================
   Media Viewer
   ========================================= */
.media-viewer-modal { 
    display: none; 
    position: fixed; 
    z-index: 9999; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.9); 
    backdrop-filter: blur(5px); 
}

.media-viewer-header { 
    position: absolute; 
    top: 20px; 
    right: 20px; 
    left: 20px; 
    display: flex; 
    justify-content: space-between; 
    z-index: 10000; 
    padding-top: env(safe-area-inset-top); 
}

.media-viewer-header button, 
.media-viewer-header a { 
    background: none; 
    border: none; 
    color: white; 
    font-size: 24px; 
    cursor: pointer; 
    text-decoration: none; 
    padding: 10px; 
    text-shadow: 0 2px 4px rgba(0,0,0,0.5); 
}

.media-viewer-content { 
    width: 100%; 
    height: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
}

.media-viewer-content img, 
.media-viewer-content video { 
    max-width: 90%; 
    max-height: 90%; 
    object-fit: contain; 
    border-radius: 4px; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.5); 
    cursor: default; 
}

/* =========================================
   پروفایل کاربری
   ========================================= */
.profile-drawer {
    position: fixed;
    top: 0;
    right: -400px; 
    width: 380px;
    height: 100dvh !important;
    max-height: 100% !important;
    background: #ffffff;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.profile-drawer.open { 
    right: 0; 
}

.profile-drawer-header {
    position: absolute; 
    top: 0; 
    left: 0; 
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    padding-top: max(15px, env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 100%); 
    border-bottom: none;
    z-index: 1050;
    pointer-events: none; 
}

.close-drawer-btn { 
    background: rgba(0,0,0,0.3); 
    border-radius: 50%;
    width: 40px; 
    height: 40px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    border: none; 
    font-size: 24px; 
    color: #ffffff; 
    cursor: pointer; 
    padding: 0; 
    pointer-events: auto; 
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    transition: background 0.2s;
}

.close-drawer-btn:hover { 
    background: rgba(0,0,0,0.5); 
}

.drawer-title { 
    display: none; 
}

.profile-drawer-content { 
    flex: 1 1 auto !important; 
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important; 
    overflow-x: hidden !important;
    padding-bottom: max(30px, env(safe-area-inset-bottom)) !important; 
    background: #fff; 
    -webkit-overflow-scrolling: touch !important;
}

/* اسلایدر */
.profile-slider-container { 
    position: relative; 
    width: 100%; 
    height: 380px; 
    background: #000; 
    overflow: hidden; 
}

.slider-wrapper { 
    display: flex; 
    transition: transform 0.3s ease; 
    height: 100%; 
    width: 100%; 
}

.slider-wrapper img { 
    width: 100%; 
    flex-shrink: 0; 
    height: 100%; 
    object-fit: cover; 
    cursor: pointer; 
}

.slider-control {
    position: absolute; 
    top: 50%; 
    transform: translateY(-50%);
    background: rgba(0,0,0,0.4); 
    color: white; 
    border: none;
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    cursor: pointer; 
    z-index: 5;
}

.slider-control.prev { 
    left: 10px; 
}

.slider-control.next { 
    right: 10px; 
}

.slider-control.hidden { 
    display: none; 
}

.slider-indicators { 
    position: absolute; 
    bottom: 10px; 
    width: 100%; 
    display: flex; 
    justify-content: center; 
    gap: 5px; 
    z-index: 5; 
}

.slider-dot { 
    width: 8px; 
    height: 8px; 
    background: rgba(255,255,255,0.5); 
    border-radius: 50%; 
}

.slider-dot.active { 
    background: white; 
}

/* اطلاعات پروفایل */
.profile-info-block { 
    padding: 15px 20px; 
    border-bottom: 8px solid #f4f4f5; 
    background: #fff; 
}

.profile-name-container { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-bottom: 5px; 
}

.profile-name-container h2 { 
    margin: 0; 
    font-size: 20px; 
    color: #222; 
}

.verified-badge { 
    color: #3390ec; 
    font-size: 18px; 
}

.last-seen-text { 
    margin: 0; 
    color: #707579; 
    font-size: 14px; 
}

.profile-details-block { 
    padding: 10px 0; 
    border-bottom: 8px solid #f4f4f5; 
    background: #fff;
}

.detail-row { 
    display: flex; 
    align-items: center; 
    padding: 12px 20px; 
    gap: 20px; 
}

.detail-icon { 
    color: #707579; 
    font-size: 22px; 
    width: 25px; 
    text-align: center; 
}

.detail-text { 
    display: flex; 
    flex-direction: column; 
}

.detail-value { 
    font-size: 16px; 
    color: #222; 
}

.detail-label { 
    font-size: 13px; 
    color: #707579; 
    margin-top: 2px; 
}

/* گرید مدیاها */
.shared-media-section { 
    padding: 10px 0; 
    background: #fff;
}

.media-tabs { 
    padding: 0 20px 10px; 
    border-bottom: 1px solid #eaeaea; 
}

.media-tab { 
    font-weight: bold; 
    color: #3390ec; 
    display: inline-block; 
    padding-bottom: 10px; 
    border-bottom: 3px solid #3390ec; 
}

.shared-media-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 2px; 
    padding: 2px; 
}

/* =========================================
   لایت باکس
   ========================================= */
.lightbox { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.95); 
    z-index: 10000; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    opacity: 0; 
    visibility: hidden; 
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.lightbox:not(.hidden) { 
    opacity: 1; 
    visibility: visible; 
}

.lightbox-close { 
    position: absolute; 
    top: max(20px, env(safe-area-inset-top)); 
    right: 30px; 
    color: white; 
    font-size: 45px; 
    cursor: pointer; 
    z-index: 10001; 
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
}

.lightbox-content { 
    max-width: 95vw; 
    max-height: 90vh; 
    object-fit: contain; 
    border-radius: 8px; 
    box-shadow: 0 8px 30px rgba(0,0,0,0.6); 
}

/* =========================================
   پلیر ویس تلگرامی
   ========================================= */
.telegram-voice-player {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.05);
    padding: 6px 12px;
    border-radius: 30px;
    width: 260px;
    max-width: 100%;
    margin-bottom: 5px;
    direction: ltr;
}

.telegram-voice-player .play-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--primary-color, #0d6efd);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.telegram-voice-player .play-btn i {
    font-size: 22px;
    margin-left: 3px;
}

.telegram-voice-player .voice-slider-container {
    flex-grow: 1;
    margin: 0 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.telegram-voice-player .voice-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #d1d1d1;
    outline: none;
    cursor: pointer;
    accent-color: var(--primary-color, #0d6efd);
}

.telegram-voice-player .voice-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: 11px;
    color: #666;
}

.telegram-voice-player .speed-btn {
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    color: #333;
}

.telegram-voice-player .speed-btn.active {
    background: var(--primary-color, #0d6efd);
    color: white;
}

.voice-upload-progress {
    width: 100%;
    height: 3px;
    background: #ddd;
    margin-top: 5px;
    border-radius: 2px;
}

.voice-upload-progress .progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    border-radius: 2px;
}

/* =========================================
   فایل پیوست
   ========================================= */
.tg-file-message {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 5px;
    max-width: 300px;
    cursor: pointer;
    transition: background 0.2s;
}

.tg-file-message:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.tg-file-icon-wrapper {
    width: 48px;
    height: 48px;
    background-color: #3390ec;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    margin-right: 12px;
    flex-shrink: 0;
}

.tg-file-icon-wrapper i {
    font-size: 24px;
}

.tg-file-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tg-file-name {
    font-weight: bold;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #000;
}

.tg-file-size {
    font-size: 12px;
    color: #707579;
    margin-top: 2px;
}

/* =========================================
   پروگرس دایره‌ای آپلود
   ========================================= */
.media-upload-wrapper {
    position: relative;
    display: inline-block;
}

.upload-progress-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circular-chart {
    width: 50px;
    height: 50px;
}

.circle-bg {
    fill: none;
    stroke: rgba(255,255,255,0.3);
    stroke-width: 3.8;
}

.circle-fg {
    fill: none;
    stroke: #fff;
    stroke-width: 3.8;
    stroke-linecap: round;
    transition: stroke-dasharray 0.2s;
}

.percentage {
    fill: #fff;
    font-size: 10px;
    text-anchor: middle;
    dominant-baseline: middle;
}

/* =========================================
   ضبط صدا
   ========================================= */
#voice-ui { 
    display: none; 
    flex-grow: 1; 
    align-items: center; 
    gap: 10px; 
    background: #f8f9fa; 
    padding: 5px 15px; 
    border-radius: 20px; 
}

#voice-canvas { 
    height: 35px; 
    flex-grow: 1; 
    border-radius: 10px; 
    background: #e9ecef; 
}

.recording-indicator { 
    color: #dc3545; 
    animation: blink 1s infinite; 
}

@keyframes blink { 
    0% { opacity: 1; } 
    50% { opacity: 0; } 
    100% { opacity: 1; } 
}

.typing-indicator-text { 
    font-size: 12px; 
    color: var(--primary-color); 
    font-weight: bold; 
    animation: pulse 1.5s infinite; 
}

@keyframes pulse { 
    0% { opacity: 0.5; } 
    50% { opacity: 1; } 
    100% { opacity: 0.5; } 
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 768px) {
    .sidebar, aside.sidebar { 
        width: 100% !important; 
        max-width: 100%; 
        flex-shrink: 0; 
    }

  .sidebar, aside.sidebar {
    width: 350px;
    min-width: 300px;
    background-color: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom); /* ← اضافه شود */
}
  
    .chat-area {
        position: fixed !important;
        top: 0; 
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%; 
        height: 100dvh;
        z-index: 1050;
        transform: translateX(100%); 
        transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        pointer-events: none;
        background-color: #fff;
    }
    
    .chat-area.show-mobile { 
        transform: translateX(0); 
        pointer-events: auto; 
    }
    
    .back-btn { 
        display: block !important; 
    }

    .profile-drawer {
        width: 100% !important;
        right: -100%;
    }

    body, .app-container, .sidebar, .chat-header, .chat-footer {
        -webkit-user-select: none; 
        -moz-user-select: none; 
        -ms-user-select: none; 
        user-select: none; 
        //position: fixed;
    }
    
    .msg-text, input, textarea, .form-control {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
}

/* =========================================
   سایر استایل‌ها
   ========================================= */
.archive-return-header { 
    display: flex; 
    align-items: center; 
    padding: 12px 15px; 
    padding-top: max(15px, env(safe-area-inset-top)) !important; 
    background: #f8f9fa; 
    border-bottom: 1px solid #dee2e6; 
    cursor: pointer; 
    color: var(--primary-color); 
    font-weight: bold; 
}

.archive-return-header:hover { 
    background: #e2e6ea; 
}

.gc-edit-overlay { 
    position: absolute; 
    bottom: 0; 
    right: 0; 
    background: var(--primary-color); 
    color: white; 
    border-radius: 50%; 
    width: 28px; 
    height: 28px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    border: 2px solid white; 
}

.tab-btn { 
    transition: 0.3s; 
}

.tab-btn:hover { 
    background: #f8f9fa; 
}

.msg-animate-in { 
    animation: slideInUpMsg 0.25s ease-out forwards; 
}

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

@keyframes highlightMessage {
    0% { background-color: #ffeb3b; }
    100% { background-color: transparent; }
}

.msg-highlighted-jump {
    animation: highlightMessage 2s ease-out forwards;
    border: 2px solid #ff9800 !important;
}

/* =========================================
   اسپلش اسکرین (Splash Screen)
   ========================================= */
#app-splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color, #0088cc), #005f8f);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}
#app-splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}
.splash-content {
    text-align: center;
    color: white;
}
.splash-logo {
    margin-bottom: 20px;
    animation: splashPulse 1.5s infinite ease-in-out;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.2));
}
.splash-title {
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 1px;
    animation: splashFadeInUp 1s ease-out;
    margin-top: 10px;
}
.splash-subtitle {
    font-size: 13px;
    opacity: 0.8;
    animation: splashFadeInUp 1.2s ease-out;
}
@keyframes splashPulse {
    0% { transform: scale(0.95); opacity: 0.85; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.85; }
}
@keyframes splashFadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   نوار وضعیت اتصال (Connection Status)
   ========================================= */
.connection-status-bar {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(-150px);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.connection-status-bar.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.connection-status-bar.offline { background: rgba(85, 85, 85, 0.9); }
.connection-status-bar.connecting { background: var(--primary-color, rgba(0, 136, 204, 0.9)); }
.connection-status-bar.updating { background: var(--primary-color, rgba(0, 136, 204, 0.9)); }

/* =========================================
   تنظیمات دراور (Settings Drawer)
   ========================================= */
.settings-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1070;
    visibility: hidden;
    transition: visibility 0.3s;
}
.settings-drawer.open {
    visibility: visible;
}
.settings-drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s;
}
.settings-drawer.open .settings-drawer-overlay {
    opacity: 1;
}
.settings-drawer-content {
    position: absolute;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
@media (min-width: 768px) {
    .settings-drawer-content {
        right: -400px;
        width: 380px;
    }
}
.settings-drawer.open .settings-drawer-content {
    right: 0;
}
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    border-bottom: 1px solid #e4e4e5;
    background: #fff;
    flex-shrink: 0;
}
.settings-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #707579;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}
.settings-header-title {
    font-size: 18px;
    font-weight: 600;
    color: #000;
}
.settings-body {
    flex: 1;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background: #f5f5f5;
    min-height: 0;
    height: 100%;
}

/* =========================================
   مودال پروفایل رسمی سیستم (System Profile Modal)
   ========================================= */
.system-profile-modal {
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
}
.system-profile-header {
    background: linear-gradient(135deg, #3390ec, #1a5f9e);
    padding: 30px 20px 20px;
    text-align: center;
    position: relative;
}
.system-profile-avatar {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}
.system-profile-avatar i {
    font-size: 48px;
    color: #fff;
}
.system-profile-header h5 {
    color: #fff;
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.system-profile-info {
    padding: 20px;
    background: #fff;
}
.system-info-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
}
.system-info-item i {
    font-size: 22px;
    color: #3390ec;
    margin-top: 2px;
}
.system-info-text {
    flex: 1;
}
.system-info-text strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
    color: #000;
}
.system-info-text span {
    font-size: 13px;
    color: #707579;
    line-height: 1.4;
}

.modal-dialog-centered {
margin-left: auto;
    margin-right: auto;
}

/* =========================================
   استایل‌های فرمت متن (Bold, Italic, Code, etc.)
   ========================================= */
.msg-text strong {
    font-weight: 700;
    color: var(--text-main);
}

.msg-text em {
    font-style: italic;
    color: var(--text-main);
}

.msg-text del {
    text-decoration: line-through;
    opacity: 0.7;
}

.msg-text code {
    font-family: monospace;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
    direction: ltr;
    display: inline-block;
}

.msg-text pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 8px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.9em;
    direction: ltr;
    margin: 6px 0;
}

.msg-text pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.modal-dialog-scrollable .modal-content {
    max-height: 80% !important;
    overflow: hidden;
}

/* ==========================================
   استایل‌های اسپلش اسکرین (Splash Screen)
   ========================================== */
#app-splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color, #0088cc), #005f8f);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}

#app-splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    color: white;
}

.splash-logo {
    margin-bottom: 20px;
    animation: splashPulse 1.5s infinite ease-in-out;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
}

.splash-title {
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 1px;
    animation: splashFadeInUp 1s ease-out;
    margin-top: 10px;
}

.splash-subtitle {
    font-size: 13px;
    opacity: 0.8;
    animation: splashFadeInUp 1.2s ease-out;
}

@keyframes splashPulse {
    0% {
        transform: scale(0.95);
        opacity: 0.85;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.85;
    }
}

@keyframes splashFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   استایل‌های سیستم وضعیت اتصال
   ========================================== */
.connection-status-bar {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(-150px);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.connection-status-bar.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.connection-status-bar.offline {
    background: rgba(85, 85, 85, 0.9);
}

.connection-status-bar.connecting {
    background: var(--primary-color, rgba(0, 136, 204, 0.9));
}

.connection-status-bar.updating {
    background: var(--primary-color, rgba(0, 136, 204, 0.9));
}

/* استایل‌های اصلاحی برای نمایش صحیح لینک‌ها */
.message-bubble {
    word-break: break-word;
    max-width: 75%;
}

.msg-text {
    word-break: break-word;
}

.message-link {
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* ==========================================
   استایل‌های منوی کناری (Drawer) به سبک تلگرام
   ========================================== */
.telegram-drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100dvh;
    background: #fff;
    z-index: 1050;
    transition: right 0.3s ease;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.telegram-drawer.open {
    right: 0;
}

/* اصلاح padding-top برای در نظر گرفتن ناچ در موبایل */
.drawer-header {
    padding-top: calc(20px + env(safe-area-inset-top)) !important;
    padding-right: 16px;
    padding-bottom: 16px;
    padding-left: 16px;
    border-bottom: 1px solid #e4e4e5;
    background: #00a884;
}

.drawer-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.drawer-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    background: #e4e4e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 500;
    color: #fff;
}

.drawer-menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.drawer-menu-item {
    display: flex !important;
    align-items: center;
    padding: 12px 20px;
    gap: 16px;
    cursor: pointer;
    transition: background 0.2s;
    color: #000;
    text-decoration: none;
}

.drawer-menu-item:hover {
    background: #f5f5f5;
}

.drawer-menu-item .menu-icon {
    width: 24px;
    text-align: center;
    font-size: 20px;
    color: #707579;
}

.drawer-menu-item .menu-text {
    font-size: 16px;
    flex: 1;
}

.drawer-menu-item.danger .menu-text {
    color: #e53935;
}

.drawer-menu-item.danger .menu-icon {
    color: #e53935;
}

.drawer-divider {
    height: 8px;
    background: #f5f5f5;
    margin: 4px 0;
}

.drawer-version {
    padding: 20px 20px 30px;
    font-size: 12px;
    color: #a2acb4;
    text-align: center;
}

/* ==========================================
   مودال پروفایل رسمی سیستم (System Profile Modal)
   ========================================== */
.system-profile-modal {
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
}

.system-profile-header {
    background: linear-gradient(135deg, #3390ec, #1a5f9e);
    padding: 30px 20px 20px;
    text-align: center;
    position: relative;
}

.system-profile-avatar {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.system-profile-avatar i {
    font-size: 48px;
    color: #fff;
}

.system-profile-header h5 {
    color: #fff;
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.system-profile-info {
    padding: 20px;
    background: #fff;
}

.system-info-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
}

.system-info-item i {
    font-size: 22px;
    color: #3390ec;
    margin-top: 2px;
}

.system-info-text {
    flex: 1;
}

.system-info-text strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
    color: #000;
}

.system-info-text span {
    font-size: 13px;
    color: #707579;
    line-height: 1.4;
}

/* =========================================
   حل قطعی مشکل اسکرول در موبایل و دسکتاپ
   ========================================= */
.profile-drawer {
    display: flex !important;
    flex-direction: column !important;
    height: 100dvh !important;
    max-height: 100% !important;
    overflow: hidden !important;
}

.profile-drawer-header {
    flex: 0 0 auto !important;
    z-index: 100 !important;
}

.profile-drawer-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    padding-bottom: max(40px, env(safe-area-inset-bottom)) !important;
    background: #fff;
    position: relative;
}

.profile-drawer-content::-webkit-scrollbar {
    width: 5px;
}
.profile-drawer-content::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 10px;
}

/* =========================================
   بقیه استایل‌های فایل
   ========================================= */
.profile-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 8px solid #f4f4f5;
}
.profile-action-btn {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}
.profile-action-btn.primary { background: #3390ec; color: #fff; }
.profile-action-btn.secondary { background: #f0f2f5; color: #333; }
.profile-action-btn.danger { background: #fff; color: #e53935; border: 1px solid #e53935; }

.media-item-wrapper {
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    background: #000;
    overflow: hidden;
}
.media-item-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}
.media-play-icon, .media-file-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    pointer-events: none;
}
.media-play-icon { font-size: 24px; }
.media-file-icon { font-size: 32px; }
.loading-media, .no-media, .error-media {
    grid-column: span 3;
    text-align: center;
    padding: 20px;
    color: #707579;
}
.slider-img {
    width: 100%;
    flex-shrink: 0;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

/* استایل لایت‌باکس پروفایل */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.lightbox.hidden {
    display: none !important;
}
.lightbox-top-btn {
    position: absolute;
    top: max(20px, env(safe-area-inset-top));
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    font-size: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}
.lightbox-top-btn.close-lightbox {
    right: max(20px, env(safe-area-inset-right));
}
.lightbox-top-btn.download-lightbox {
    left: max(20px, env(safe-area-inset-left));
}
.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10001;
}
.lightbox-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    font-size: 32px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-nav-btn.prev-btn {
    right: 20px;
}
.lightbox-nav-btn.next-btn {
    left: 20px;
}
.lightbox-content-wrapper {
    max-width: 95vw;
    max-height: 90vh;
}
.lightbox-content-wrapper img,
.lightbox-content-wrapper video {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

/* ==========================================
   استایل‌های اسپلش اسکرین (Splash Screen)
   ========================================== */
#app-splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color, #0088cc), #005f8f);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}
#app-splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}
.splash-content {
    text-align: center;
    color: white;
}
.splash-logo {
    margin-bottom: 20px;
    animation: splashPulse 1.5s infinite ease-in-out;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.2));
}
.splash-title {
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 1px;
    animation: splashFadeInUp 1s ease-out;
    margin-top: 10px;
}
.splash-subtitle {
    font-size: 13px;
    opacity: 0.8;
    animation: splashFadeInUp 1.2s ease-out;
}
@keyframes splashPulse {
    0% { transform: scale(0.95); opacity: 0.85; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.85; }
}
@keyframes splashFadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   استایل‌های سیستم وضعیت اتصال
   ========================================== */
.connection-status-bar {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(-150px);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.connection-status-bar.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.connection-status-bar.offline { background: rgba(85, 85, 85, 0.9); }
.connection-status-bar.connecting { background: var(--primary-color, rgba(0, 136, 204, 0.9)); }
.connection-status-bar.updating { background: var(--primary-color, rgba(0, 136, 204, 0.9)); }

/* استایل‌های اصلاحی برای نمایش صحیح لینک‌ها */
.message-bubble {
    word-break: break-word;
    max-width: 75%;
}
.msg-text {
    word-break: break-word;
}
.message-link {
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* ==========================================
   استایل‌های منوی کناری (Drawer) به سبک تلگرام
   ========================================== */
.telegram-drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100dvh;
    background: #fff;
    z-index: 1050;
    transition: right 0.3s ease;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.telegram-drawer.open {
    right: 0;
}
.drawer-header {
    padding-top: calc(20px + env(safe-area-inset-top)) !important;
    padding-right: 16px;
    padding-bottom: 16px;
    padding-left: 16px;
    border-bottom: 1px solid #e4e4e5;
    background: #00a884;
}
.drawer-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.drawer-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    background: #e4e4e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 500;
    color: #fff;
}
.drawer-menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}
.drawer-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 16px;
    cursor: pointer;
    transition: background 0.2s;
    color: #000;
    text-decoration: none;
}
.drawer-menu-item:hover {
    background: #f5f5f5;
}
.drawer-menu-item .menu-icon {
    width: 24px;
    text-align: center;
    font-size: 20px;
    color: #707579;
}
.drawer-menu-item .menu-text {
    font-size: 16px;
    flex: 1;
}
.drawer-menu-item.danger .menu-text {
    color: #e53935;
}
.drawer-menu-item.danger .menu-icon {
    color: #e53935;
}
.drawer-divider {
    height: 8px;
    background: #f5f5f5;
    margin: 4px 0;
}
.drawer-version {
    padding: 20px 20px 30px;
    font-size: 12px;
    color: #a2acb4;
    text-align: center;
}

/* ==========================================
   مودال پروفایل رسمی سیستم (System Profile Modal)
   ========================================== */
.system-profile-modal {
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
}
.system-profile-header {
    background: linear-gradient(135deg, #3390ec, #1a5f9e);
    padding: 30px 20px 20px;
    text-align: center;
    position: relative;
}
.system-profile-avatar {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}
.system-profile-avatar i {
    font-size: 48px;
    color: #fff;
}
.system-profile-header h5 {
    color: #fff;
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.system-profile-info {
    padding: 20px;
    background: #fff;
}
.system-info-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
}
.system-info-item i {
    font-size: 22px;
    color: #3390ec;
    margin-top: 2px;
}
.system-info-text {
    flex: 1;
}
.system-info-text strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
    color: #000;
}
.system-info-text span {
    font-size: 13px;
    color: #707579;
    line-height: 1.4;
}

/* ==========================================
   استایل پنل پیش‌نمایش پیوست (Attachment Preview)
   ========================================== */
.attachment-preview-area {
    background: #f0f2f5;
    border-top: 1px solid #ddd;
    padding: 8px 12px;
}
.attachment-container {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.attachment-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #e4e6e8;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    overflow: hidden;
}
.attachment-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.attachment-thumbnail i {
    font-size: 24px;
    color: #6c757d;
}
.attachment-info {
    flex: 1;
    min-width: 0;
}
.attachment-filename {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    font-size: 14px;
}
.attachment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
}
.attachment-progress-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.attachment-progress-bar-bg {
    flex: 1;
    height: 4px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}
.attachment-progress-bar {
    height: 100%;
    width: 0%;
    background: #3390ec;
    transition: width 0.1s;
}
.attachment-progress-text {
    font-size: 11px;
    min-width: 40px;
    text-align: right;
}
.attachment-actions {
    display: flex;
    align-items: center;
    margin-left: 8px;
}
.attachment-actions button {
    background: none;
    border: none;
    font-size: 20px;
    padding: 4px;
    color: #6c757d;
    cursor: pointer;
}
.attachment-caption-input {
    margin-top: 8px;
    width: 100%;
    border: none;
    background: #f0f2f5;
    border-radius: 18px;
    padding: 8px 16px;
    font-size: 14px;
}


/* ==========================================
   استایل‌های اسپلش اسکرین (Splash Screen)
   ========================================== */
#app-splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color, #0088cc), #005f8f);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}

#app-splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    color: white;
}

.splash-logo {
    margin-bottom: 20px;
    animation: splashPulse 1.5s infinite ease-in-out;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
}

.splash-title {
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 1px;
    animation: splashFadeInUp 1s ease-out;
    margin-top: 10px;
}

.splash-subtitle {
    font-size: 13px;
    opacity: 0.8;
    animation: splashFadeInUp 1.2s ease-out;
}

@keyframes splashPulse {
    0% {
        transform: scale(0.95);
        opacity: 0.85;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.85;
    }
}

@keyframes splashFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   استایل‌های سیستم وضعیت اتصال
   ========================================== */
.connection-status-bar {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(-150px);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.connection-status-bar.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.connection-status-bar.offline {
    background: rgba(85, 85, 85, 0.9);
}

.connection-status-bar.connecting {
    background: var(--primary-color, rgba(0, 136, 204, 0.9));
}

.connection-status-bar.updating {
    background: var(--primary-color, rgba(0, 136, 204, 0.9));
}

/* استایل‌های اصلاحی برای نمایش صحیح لینک‌ها */
.message-bubble {
    word-break: break-word;
    max-width: 75%;
}

.msg-text {
    word-break: break-word;
}

.message-link {
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* ==========================================
   استایل‌های منوی کناری (Drawer) به سبک تلگرام
   ========================================== */
.telegram-drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100dvh;
    background: #fff;
    z-index: 1050;
    transition: right 0.3s ease;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.telegram-drawer.open {
    right: 0;
}

.drawer-header {
    padding-top: calc(20px + env(safe-area-inset-top)) !important;
    padding-right: 16px;
    padding-bottom: 16px;
    padding-left: 16px;
    border-bottom: 1px solid #e4e4e5;
    background: #00a884;
}

.drawer-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.drawer-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    background: #e4e4e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 500;
    color: #fff;
}

.drawer-menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.drawer-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    gap: 16px;
    cursor: pointer;
    transition: background 0.2s;
    color: #000;
    text-decoration: none;
}

.drawer-menu-item:hover {
    background: #f5f5f5;
}

.drawer-menu-item .menu-icon {
    width: 24px;
    text-align: center;
    font-size: 20px;
    color: #707579;
}

.drawer-menu-item .menu-text {
    font-size: 16px;
    flex: 1;
}

.drawer-menu-item.danger .menu-text {
    color: #e53935;
}

.drawer-menu-item.danger .menu-icon {
    color: #e53935;
}

.drawer-divider {
    height: 8px;
    background: #f5f5f5;
    margin: 4px 0;
}

.drawer-version {
    padding: 20px 20px 30px;
    font-size: 12px;
    color: #a2acb4;
    text-align: center;
}

/* ==========================================
   مودال پروفایل رسمی سیستم (System Profile Modal)
   ========================================== */
.system-profile-modal {
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
}

.system-profile-header {
    background: linear-gradient(135deg, #3390ec, #1a5f9e);
    padding: 30px 20px 20px;
    text-align: center;
    position: relative;
}

.system-profile-avatar {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.system-profile-avatar i {
    font-size: 48px;
    color: #fff;
}

.system-profile-header h5 {
    color: #fff;
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.system-profile-info {
    padding: 20px;
    background: #fff;
}

.system-info-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
}

.system-info-item i {
    font-size: 22px;
    color: #3390ec;
    margin-top: 2px;
}

.system-info-text {
    flex: 1;
}

.system-info-text strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
    color: #000;
}

.system-info-text span {
    font-size: 13px;
    color: #707579;
    line-height: 1.4;
}

/* ==========================================
   استایل پنل پیش‌نمایش پیوست (Attachment Preview)
   ========================================== */
.attachment-preview-area {
    background: #f0f2f5;
    border-top: 1px solid #ddd;
    padding: 8px 12px;
}

.attachment-container {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.attachment-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #e4e6e8;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    overflow: hidden;
}

.attachment-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-thumbnail i {
    font-size: 24px;
    color: #6c757d;
}

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

.attachment-filename {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    font-size: 14px;
}

.attachment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
}

.attachment-progress-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.attachment-progress-bar-bg {
    flex: 1;
    height: 4px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.attachment-progress-bar {
    height: 100%;
    width: 0%;
    background: #3390ec;
    transition: width 0.1s;
}

.attachment-progress-text {
    font-size: 11px;
    min-width: 40px;
    text-align: right;
}

.attachment-actions {
    display: flex;
    align-items: center;
    margin-left: 8px;
}

.attachment-actions button {
    background: none;
    border: none;
    font-size: 20px;
    padding: 4px;
    color: #6c757d;
    cursor: pointer;
}

.attachment-caption-input {
    margin-top: 8px;
    width: 100%;
    border: none;
    background: #f0f2f5;
    border-radius: 18px;
    padding: 8px 16px;
    font-size: 14px;
}

/* ================================
   Attach Menu Fix
================================ */
#attach-menu{
    position: fixed;
    z-index: 12000;
    min-width: 180px;
}

/* ================================
   Upload Overlay Telegram Style
================================ */

.uploading-media-wrapper{
    position:relative;
    display:inline-block;
}

.upload-dim{
    filter: brightness(0.45);
}

.upload-overlay{
    position:absolute;
    top:0;
    left:0;
    width:100%;
    height:100%;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    pointer-events:none;
}

.upload-circle{
    width:60px;
    height:60px;
    position:relative;
}

.upload-circle svg{
    width:60px;
    height:60px;
    transform:rotate(-90deg);
}

.upload-circle circle{
    fill:none;
    stroke-width:3;
}

.upload-bg{
    stroke:rgba(255,255,255,0.25);
}

.upload-fg{
    stroke:#fff;
    stroke-linecap:round;
    stroke-dasharray:113;
    stroke-dashoffset:113;
}

.upload-cancel{
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%,-50%);
    font-size:18px;
    color:#fff;
    cursor:pointer;
    pointer-events:auto;
}

.upload-info{
    position:absolute;
    top:6px;
    left:0;
    width:100%;
    text-align:center;
    color:#fff;
    font-size:11px;
    font-weight:500;
    text-shadow:0 1px 2px rgba(0,0,0,0.6);
}

.upload-video-duration{
    position:absolute;
    bottom:6px;
    right:6px;
    background:rgba(0,0,0,0.65);
    color:#fff;
    font-size:11px;
    padding:2px 6px;
    border-radius:6px;
}

/* =========================================
   مدیریت تمام‌صفحه و نوار پایین در iOS (PWA)
   ========================================= */
@supports (-webkit-touch-callout: none) {
    html, body, .app-container {
        height: 100vh !important;
        height: 100dvh !important; /* پشتیبانی از ارتفاع داینامیک در iOS 15+ */
        width: 100%;
        overflow: hidden !important;
    }

    .chat-area {
        height: 100dvh !important;
    }

    /* تنظیم منوی پایین و بخش تایپ پیام برای چسبیدن دقیق به پایین آیفون */
    #chat-footer-section, .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom) !important;
        background-color: #ffffff !important;
        /* جلوگیری از ایجاد فاصله اضافه */
        margin-bottom: 0 !important; 
        bottom: 0 !important;
    }

    /* تنظیم ارتفاع چت بادی برای اینکه زیر هدر و فوتر نرود */
    .chat-body {
        height: calc(100dvh - 120px - env(safe-area-inset-bottom)) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Aidy Messenger v2.1.10 - stable dialog list, no blinking refresh */
.dialog-item-wrapper {
    contain: layout paint;
}
.dialog-item-wrapper .dialog-item {
    transition: background-color .18s ease, transform .18s ease;
}
.dialog-avatar-img,
.avatar-container {
    width: 50px;
    height: 50px;
    object-fit: cover;
    flex: 0 0 50px;
}
.online-badge {
    width: 14px;
    height: 14px;
    margin-left: -10px;
    margin-bottom: 5px;
}
.dialog-name {
    font-size: 15px;
    max-width: 100%;
}
.dialog-time {
    font-size: 11px;
    white-space: nowrap;
}
.dialog-last-msg {
    font-size: 13px;
    min-height: 19px;
    line-height: 19px;
    transition: opacity .16s ease;
    unicode-bidi: plaintext;
}
.dialog-last-msg .dialog-preview-text,
.dialog-last-msg .typing-indicator-text {
    font-size: inherit;
    line-height: inherit;
}
.dialog-last-msg img,
.dialog-last-msg .chat-emoji {
    width: 1em !important;
    height: 1em !important;
    vertical-align: -0.12em !important;
}
.dialog-last-msg.dialog-preview-updated {
    opacity: .72;
}
.dialog-tick {
    font-size: 14px;
    vertical-align: -1px;
}
.dialog-state-icon {
    font-size: 13px;
}
.unread-badge {
    font-size: .7rem;
}

/* Aidy Messenger v2.1.10 - dialog preview custom emoji/sticker alignment */
.dialog-last-msg {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: isolate !important;
    display: block;
}
.dialog-last-msg .dialog-preview-text,
.dialog-last-msg .typing-indicator-text {
    direction: rtl !important;
    unicode-bidi: isolate !important;
    text-align: right !important;
}
.dialog-last-msg .ady-emoji-inline,
.dialog-last-msg img.ady-emoji-inline {
    width: 1.08em !important;
    height: 1.08em !important;
    max-width: 1.08em !important;
    max-height: 1.08em !important;
    vertical-align: -0.16em !important;
    margin: 0 1px !important;
    object-fit: contain !important;
}
.dialog-last-msg .ady-big-emoji,
.dialog-last-msg .ady-big-emoji-1,
.dialog-last-msg .ady-big-emoji-2,
.dialog-last-msg .ady-big-emoji-3 {
    font-size: inherit !important;
    line-height: inherit !important;
}
