:root[data-theme="dark"] {
    --bg-primary: #1a1a1a; --bg-secondary: #2d2d2d; --bg-tertiary: #3d3d3d; --bg-input: #3d3d3d;
    --text-primary: #ffffff; --text-secondary: #b0b0b0; --text-muted: #808080;
    --accent: #ff8800; --accent-hover: #ff9920; --accent-light: rgba(255, 136, 0, 0.15);
    --border: #404040; --shadow: rgba(0, 0, 0, 0.5);
    --bubble-out: #ff8800; --bubble-in: #3d3d3d; --success: #4caf50; --error: #f44336;
}
:root[data-theme="light"] {
    --bg-primary: #ffffff; --bg-secondary: #f5f5f5; --bg-tertiary: #e0e0e0; --bg-input: #f0f0f0;
    --text-primary: #1a1a1a; --text-secondary: #666666; --text-muted: #999999;
    --accent: #ff8800; --accent-hover: #ff9920; --accent-light: rgba(255, 136, 0, 0.1);
    --border: #e0e0e0; --shadow: rgba(0, 0, 0, 0.1);
    --bubble-out: #ff8800; --bubble-in: #f0f0f0; --success: #4caf50; --error: #f44336;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
@import url('/assets/fonts/vazirmatn/vazirmatn.css');

body { font-family: 'Vazirmatn', Tahoma, system-ui, -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); overflow: hidden; height: 100vh; transition: background 0.3s ease, color 0.3s ease; }
.icon { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bounceSlight { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-8px); } }

.animate-fade-in { animation: fadeIn 0.6s ease-out forwards; }
.animate-slide-up { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-scale-in { animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-bounce-slight { animation: bounceSlight 3s ease-in-out infinite; }
.cat-btn:hover .btn-icon-animate { animation: slideUp 0.6s ease-in-out infinite alternate; }

.screen { display: none; height: 100vh; }
.screen.active { display: flex; animation: fadeIn 0.4s ease; }
#authScreen { justify-content: center; align-items: center; background: var(--bg-primary); padding: 20px; }
.auth-container { width: 100%; max-width: 400px; }
.cat-logo { text-align: center; margin-bottom: 40px; }
.cat-icon { width: 100px; height: 100px; color: var(--accent); margin-bottom: 16px; animation: bounceSlight 2s infinite; }
.app-title { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.app-subtitle { font-size: 14px; color: var(--text-secondary); }

.auth-form { background: var(--bg-secondary); padding: 32px; border-radius: 24px; box-shadow: 0 8px 32px var(--shadow); }
.input-group { position: relative; margin-bottom: 20px; }
.input-icon { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group input { width: 100%; padding: 14px 48px 14px 16px; background: var(--bg-input); border: 2px solid transparent; border-radius: 16px; color: var(--text-primary); font-size: 15px; transition: all 0.3s ease; }
.input-group input:focus { outline: none; border-color: var(--accent); background: var(--bg-primary); }
.checkbox-group { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; cursor: pointer; color: var(--text-secondary); font-size: 14px; }
.checkbox-group input { accent-color: var(--accent); width: 18px; height: 18px; }
.btn-primary { width: 100%; padding: 14px; background: var(--accent); color: white; border: none; border-radius: 16px; font-size: 16px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.3s ease; box-shadow: 0 4px 16px rgba(255, 136, 0, 0.3); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.auth-switch { text-align: center; margin-top: 24px; color: var(--text-secondary); font-size: 14px; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }

#mainScreen.active { display: flex; }
.panel { height: 100vh; overflow: hidden; }
#sidebar { width: 380px; background: var(--bg-secondary); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-header { padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.header-left h2 { font-size: 22px; font-weight: 700; }
.icon-btn { width: 40px; height: 40px; background: transparent; border: none; color: var(--text-secondary); border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; }
.icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-icon-primary { width: 44px; height: 44px; background: var(--accent); border: none; border-radius: 50%; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(255, 136, 0, 0.3); transition: all 0.2s ease; }
.btn-icon-primary:hover { background: var(--accent-hover); transform: scale(1.05); }

.search-wrapper { padding: 16px 24px; }
.search-box { position: relative; background: var(--bg-input); border-radius: 20px; display: flex; align-items: center; padding: 0 16px; transition: all 0.3s ease; }
.search-box:focus-within { box-shadow: 0 0 0 2px var(--accent-light); }
.search-icon { font-size: 18px; margin-left: 8px; color: var(--text-muted); display: flex; }
.search-box input { flex: 1; background: transparent; border: none; padding: 12px 0; color: var(--text-primary); font-size: 14px; }
.search-box input:focus { outline: none; }

.chat-list { flex: 1; overflow-y: auto; padding: 0 12px; }
.chat-item { display: flex; align-items: center; padding: 12px; border-radius: 16px; cursor: pointer; transition: all 0.2s ease; margin-bottom: 4px; }
.chat-item:hover { background: var(--bg-tertiary); }
.chat-item.active { background: var(--accent-light); }
.avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--bg-tertiary); margin-left: 12px; flex-shrink: 0; }
.chat-item-content { flex: 1; min-width: 0; }
.chat-item-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.chat-item-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.chat-item-preview { font-size: 14px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#chatArea { flex: 1; background: var(--bg-primary); display: flex; flex-direction: column; }
.empty-state { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 40px; }
.empty-cat { margin-bottom: 24px; }
.cat-illustration { width: 150px; height: 150px; color: var(--accent); }
.empty-state h3 { font-size: 22px; margin-bottom: 8px; color: var(--text-primary); }
.empty-state p { color: var(--text-secondary); font-size: 15px; }

.chat-container { display: flex; flex-direction: column; height: 100%; }
.chat-container.hidden { display: none; }
.chat-header { padding: 16px 24px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; }
.chat-user-info { flex: 1; display: flex; align-items: center; gap: 12px; }
.chat-user-info .avatar { width: 44px; height: 44px; }
.user-details { display: flex; flex-direction: column; }
.user-details h3 { font-size: 16px; font-weight: 600; }
.status { font-size: 13px; color: var(--accent); }
.chat-actions { display: flex; gap: 8px; }

.messages-area { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.message { display: flex; animation: slideUp 0.3s ease; }
.message.outgoing { justify-content: flex-start; }
.message.incoming { justify-content: flex-end; }
.message.sending { opacity: 0.7; }
.message-bubble { max-width: 75%; padding: 12px 16px; font-size: 15px; line-height: 1.5; border-radius: 18px; position: relative; word-wrap: break-word; }
.message.outgoing .message-bubble { background: var(--bubble-out); color: white; border-bottom-right-radius: 4px; }
.message.incoming .message-bubble { background: var(--bubble-in); color: var(--text-primary); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.message-time { font-size: 11px; margin-top: 4px; opacity: 0.8; display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.message-ticks { font-size: 14px; }

.message-input-area { padding: 16px 24px; background: var(--bg-secondary); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.input-container { flex: 1; background: var(--bg-input); border-radius: 24px; padding: 4px 16px; display: flex; align-items: center; }
#messageInput { width: 100%; background: transparent; border: none; color: var(--text-primary); font-size: 15px; padding: 10px 0; resize: none; max-height: 120px; font-family: inherit; }
#messageInput:focus { outline: none; }
.btn-send { width: 48px; height: 48px; background: var(--accent); border: none; border-radius: 50%; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(255, 136, 0, 0.3); transition: all 0.2s ease; }
.btn-send:hover { background: var(--accent-hover); transform: scale(1.05); }

/* مودال‌ها */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
.modal-content { position: relative; background: var(--bg-secondary); border-radius: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: 0 16px 48px var(--shadow); animation: scaleIn 0.3s ease; z-index: 1001; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; }

.profile-card { text-align: center; margin-bottom: 24px; }
.avatar-wrapper { position: relative; display: inline-block; margin-bottom: 20px; }
.avatar-large { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }
.avatar-edit-btn { position: absolute; bottom: 0; right: 0; width: 36px; height: 36px; background: var(--accent); border: 3px solid var(--bg-secondary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; cursor: pointer; transition: all 0.2s ease; }
.avatar-edit-btn:hover { background: var(--accent-hover); transform: scale(1.1); }
.form-field { margin-bottom: 20px; text-align: right; }
.form-field label { display: block; margin-bottom: 8px; color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.form-field input, .form-field textarea { width: 100%; padding: 12px 16px; background: var(--bg-input); border: 2px solid transparent; border-radius: 12px; color: var(--text-primary); font-size: 15px; transition: all 0.3s ease; font-family: inherit; }
.form-field input:focus, .form-field textarea:focus { outline: none; border-color: var(--accent); }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.settings-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.btn-danger { width: 100%; padding: 14px; background: rgba(244, 67, 54, 0.1); color: var(--error); border: 1px solid rgba(244, 67, 54, 0.2); border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s ease; }
.btn-danger:hover { background: rgba(244, 67, 54, 0.2); }

.search-large { margin-bottom: 20px; }
.search-results { max-height: 300px; overflow-y: auto; }
.search-result-item { display: flex; align-items: center; padding: 12px; border-radius: 12px; cursor: pointer; transition: all 0.2s ease; }
.search-result-item:hover { background: var(--bg-tertiary); }
.search-result-info { flex: 1; margin-right: 12px; }
.search-result-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.search-result-username { font-size: 13px; color: var(--text-muted); }
.empty-message { text-align: center; padding: 32px 16px; color: var(--text-muted); font-size: 14px; }

/* Toast */
.toast-container { position: fixed; top: 24px; left: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 12px; }
.toast { background: var(--bg-secondary); color: var(--text-primary); padding: 14px 20px; border-radius: 12px; box-shadow: 0 8px 24px var(--shadow); border-right: 4px solid var(--accent); animation: slideUp 0.3s ease; min-width: 280px; font-size: 14px; }
.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--error); }

/* آپلود و ضبط صدا */
.upload-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.upload-option { cursor: pointer; }
.upload-option input { display: none; }
.option-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; background: var(--bg-input); border: 2px solid var(--border); border-radius: 12px; transition: all 0.2s ease; }
.upload-option input:checked + .option-card { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.upload-icon { width: 32px; height: 32px; }

.upload-area { border: 2px dashed var(--border); border-radius: 12px; padding: 40px 20px; text-align: center; cursor: pointer; transition: all 0.2s ease; margin-bottom: 20px; background: var(--bg-input); }
.upload-area:hover, .upload-area.drag-over { border-color: var(--accent); background: var(--accent-light); }
.upload-placeholder-icon { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 12px; }

.upload-progress { margin-bottom: 20px; }
.progress-bar { height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s ease; }
.progress-text { font-size: 14px; color: var(--text-secondary); text-align: center; display: block; }

/* نشانگر تایپ */
.typing-indicator { display: flex; gap: 4px; padding: 12px 16px; background: var(--bubble-in); border-radius: 18px; border-bottom-left-radius: 4px; width: fit-content; margin-bottom: 12px; animation: slideUp 0.2s ease; }
.typing-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-secondary); animation: typingBounce 1.4s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* مدیا در پیام */
.message-media { max-width: 300px; border-radius: 12px; overflow: hidden; margin-bottom: 8px; }
.message-media img { width: 100%; height: auto; display: block; cursor: pointer; }
.message-media audio { width: 100%; }
.message-file { display: flex; align-items: center; gap: 12px; padding: 12px; background: rgba(0,0,0,0.1); border-radius: 8px; cursor: pointer; margin-bottom: 8px; }
.message-file .icon { width: 40px; height: 40px; color: var(--accent); flex-shrink: 0; }
.message-file-info { flex: 1; min-width: 0; }
.message-file-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-file-size { font-size: 12px; color: var(--text-secondary); }

@media (max-width: 768px) {
    #sidebar { width: 100%; }
    #chatArea { position: absolute; top: 0; right: 0; width: 100%; height: 100%; transform: translateX(100%); transition: transform 0.3s ease; z-index: 100; }
    #chatArea.active { transform: translateX(0); }
    .mobile-only { display: flex !important; }
    .message-bubble { max-width: 85%; }
    .modal-content { max-width: 100%; max-height: 100vh; border-radius: 24px 24px 0 0; position: absolute; bottom: 0; }
}
@media (min-width: 769px) { .mobile-only { display: none !important; } }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.hidden { display: none !important; }
.unread-badge {
    background: var(--accent);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 8px;
    float: left;
}
.file-preview-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: 12px;
    margin-bottom: 8px;
}

.file-preview-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

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

.file-preview-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-size {
    font-size: 12px;
    color: var(--text-muted);
}

.file-preview-remove {
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}
/* Badge پیام‌های خوانده‌نشده */
.unread-badge {
    background: var(--accent);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 8px;
    float: left;
    min-width: 20px;
    text-align: center;
}

/* پیش‌نمایش فایل‌ها */
.file-preview-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: 12px;
    margin-bottom: 8px;
}

.file-preview-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.file-preview-item .icon {
    width: 40px;
    height: 40px;
    color: var(--accent);
}

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

.file-preview-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-size {
    font-size: 12px;
    color: var(--text-muted);
}

.file-preview-remove {
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.file-preview-remove:hover {
    background: #c62828;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ضبط صدا */
.voice-recorder {
    padding: 20px;
    text-align: center;
}

.recorder-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
}

.btn-record {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--accent);
    color: white;
}

.btn-record.stop {
    background: var(--error);
}

.btn-record:hover {
    transform: scale(1.05);
}

.recording-timer {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    font-family: monospace;
}

/* ویدیو در پیام */
.message-media video {
    max-width: 100%;
    border-radius: 12px;
}
/* انیمیشن چرخش برای لودینگ */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* حالت فعال ضبط صدا (ضربان قرمز) */
.btn-send.recording-active {
    background: var(--error) !important;
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(244, 67, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0); }
}
/* ==========================================
   PROGRESS RING - مثل تلگرام
   ========================================== */
.message-file.uploading {
    position: relative;
    min-width: 200px;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.file-icon-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon-wrapper .file-icon {
    font-size: 24px;
    z-index: 1;
}

.progress-ring {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 52px;
    height: 52px;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    stroke: var(--border);
    stroke-width: 3;
    fill: none;
}

.progress-ring-fill {
    stroke: var(--accent);
    stroke-width: 3;
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease;
}

.progress-percent {
    position: absolute;
    font-size: 9px;
    font-weight: bold;
    color: var(--text-secondary);
    z-index: 2;
    bottom: -2px;
    right: -4px;
    background: var(--bg-primary);
    border-radius: 50%;
    padding: 1px 3px;
    font-size: 8px;
    min-width: 20px;
    text-align: center;
}

/* ==========================================
   SENDING ANIMATION
   ========================================== */
.message.sending .message-bubble {
    opacity: 0.85;
}

.message.sending .message-time {
    color: var(--text-muted);
}

/* ==========================================
   VOICE BUTTON RECORDING
   ========================================== */
.voice-btn.recording-active {
    background: var(--error) !important;
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7); }
    70% { box-shadow: 0 0 0 12px rgba(244, 67, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0); }
}

/* ==========================================
   PROGRESS BAR IN CHAT (برای فایل‌های بزرگ)
   ========================================== */
.upload-progress-inline {
    margin-top: 8px;
    width: 100%;
}

.upload-progress-inline .progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-inline .progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

.upload-progress-inline .progress-text {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    text-align: center;
    margin-top: 4px;
}

/* ==========================================
   MESSAGE FILE UPLOADING STATE
   ========================================== */
.message-file .file-info {
    flex: 1;
    min-width: 0;
}

.message-file .file-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.message-file .file-size {
    font-size: 12px;
    color: var(--text-muted);
}

.message-file .file-status {
    font-size: 12px;
    color: var(--accent);
    margin-top: 2px;
}

/* ==========================================
   MESSAGE MEDIA - IMAGE
   ========================================== */
.message-image {
    max-width: 280px;
    max-height: 400px;
    border-radius: 12px;
    cursor: pointer;
    display: block;
    width: auto;
    height: auto;
}

.message-audio {
    max-width: 280px;
    width: 100%;
    border-radius: 8px;
}

.message-video {
    max-width: 280px;
    max-height: 400px;
    border-radius: 12px;
    width: 100%;
}

.message-file-error {
    padding: 15px;
    background: rgba(255, 0, 0, 0.1);
    border-radius: 12px;
    color: #ff6b6b;
    text-align: center;
    font-size: 13px;
}

.message-file-download {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--text-muted);
}

/* ==========================================
   DATE DIVIDER
   ========================================== */
.message-date-divider {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 0;
    margin: 8px 0;
    position: relative;
}

.message-date-divider::before,
.message-date-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--border);
}

.message-date-divider::before {
    left: 0;
}

.message-date-divider::after {
    right: 0;
}
/* نوار ریپلای */
.reply-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    margin-bottom: -8px; /* چسبیدن به اینپوت */
}
.reply-bar.hidden { display: none; }
.reply-content { display: flex; align-items: center; gap: 12px; flex: 1; }
.reply-line { width: 4px; height: 32px; background: var(--accent); border-radius: 2px; }
.reply-info { display: flex; flex-direction: column; }
.reply-name { font-size: 13px; font-weight: 600; color: var(--accent); }
.reply-text { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

/* منوی راست‌کلیک (Context Menu) */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 2000;
    min-width: 180px;
    padding: 6px 0;
    animation: scaleIn 0.15s ease;
}
.context-menu.hidden { display: none; }
.context-menu ul { list-style: none; margin: 0; padding: 0; }
.context-menu li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}
.context-menu li:hover { background: var(--bg-hover); }
.context-menu li.text-danger { color: var(--error); }
.context-menu li.text-danger:hover { background: rgba(244, 67, 54, 0.1); }
.context-menu li.hidden { display: none; }

/* استایل پیام‌های ویژه */
.message-bubble.deleted {
    background: transparent !important;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    font-style: italic;
}
.reply-quote {
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.1);
    border-right: 3px solid var(--accent);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.edited-tag {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    margin-left: 4px;
}
.message.incoming .edited-tag { color: var(--text-muted); }
/* =========================================
   اصلاح پلیر صدا (ویس) برای ویس‌های کوتاه
   ========================================= */
.message-media.voice-media {
    min-width: 240px;       /* حداقل عرض برای جلوگیری از جمع شدن */
    max-width: 280px;
    padding: 8px 12px;
    border-radius: 16px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

/* رنگ پس‌زمینه متفاوت برای پیام‌های ارسالی و دریافتی */
.message.incoming .message-media.voice-media {
    background: rgba(0, 0, 0, 0.08);
}

.message.outgoing .message-media.voice-media {
    background: rgba(255, 255, 255, 0.15);
}

/* استایل خود تگ audio */
.message-audio {
    width: 100%;
    min-width: 220px;       /* حیاتی: مرورگر را مجبور به رندر دکمه‌ها می‌کند */
    height: 40px;           /* ارتفاع ثابت برای نمایش صحیح نوار زمان */
    border-radius: 20px;
    outline: none;
}

/* رفع باگ‌های ظاهری در مرورگر کروم/اج */
.message-audio::-webkit-media-controls-panel {
    background-color: transparent;
}

.message-audio::-webkit-media-controls-play-button {
    background-color: var(--accent);
    border-radius: 50%;
    color: white;
}