/* ============================================================
   Mova — تم کرم و قهوه‌ای روشن (روشن) + موکا (تاریک)
   ============================================================
   این فایل فقط رنگ‌ها را تعریف می‌کند و آخرین استایل بارگذاری‌شده است،
   بنابراین رنگ‌های ثابت داخل style.css و استایل‌های inline را با
   اولویت بالاتر بازنویسی می‌کند. ساختار و چیدمان دست‌نخورده می‌ماند.
   ============================================================ */

/* ---------------------------------------------------------- پالت روشن */
:root,
:root[data-theme="light"] {
    --mova-bg: #f6ecdd;            /* کرم پس‌زمینه */
    --mova-surface: #fffaf2;       /* کرم روشن‌تر برای کارت‌ها */
    --mova-surface-2: #f1e3cf;     /* کرم کمی تیره‌تر */
    --mova-surface-3: #ead8bf;
    --mova-border: #e2cfb4;
    --mova-text: #3b2a1d;          /* قهوه‌ای تیره */
    --mova-text-muted: #8a715c;
    --mova-accent: #9a6640;        /* قهوه‌ای روشن — کنتراست ۴.۶۵:۱ با متن کرم */
    --mova-accent-strong: #8c5b39;
    --mova-accent-soft: #f0dcc4;
    --mova-on-accent: #fffaf2;
    --mova-bubble-out: #eddbc0;    /* حباب پیام خودم */
    --mova-bubble-in: #fffdf9;     /* حباب پیام دیگران */
    --mova-header: #f7ecdb;
    --mova-shadow: rgba(90, 63, 42, 0.12);
    --mova-overlay: rgba(59, 42, 29, 0.35);
    color-scheme: light;
}

/* ---------------------------------------------------------- پالت تاریک */
:root[data-theme="dark"] {
    --mova-bg: #1f1712;            /* موکا */
    --mova-surface: #2a1f18;
    --mova-surface-2: #33261d;
    --mova-surface-3: #3f2f23;
    --mova-border: #4a3729;
    --mova-text: #f3e6d5;          /* کرم */
    --mova-text-muted: #bda58d;
    --mova-accent: #c99a6e;
    --mova-accent-strong: #e0b489;
    --mova-accent-soft: #3d2c20;
    --mova-on-accent: #241a15;
    --mova-bubble-out: #4a3527;
    --mova-bubble-in: #2f231b;
    --mova-header: #251b15;
    --mova-shadow: rgba(0, 0, 0, 0.45);
    --mova-overlay: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
}

/* ------------------------------------------------------------- پایه */
body {
    background: var(--mova-bg) !important;
    color: var(--mova-text);
}

/* صفحه ورود */
.login-container {
    background: var(--mova-surface) !important;
    border: 1px solid var(--mova-border);
    box-shadow: 0 10px 30px var(--mova-shadow) !important;
    color: var(--mova-text);
}
.login-container h1,
.login-container h2,
.login-header,
.login-header p { color: var(--mova-text) !important; }
.login-container label { color: var(--mova-text-muted) !important; }
.login-container input[type="text"],
.login-container input[type="password"],
.login-container input[type="number"],
.form-group input,
.form-group textarea,
.form-group select {
    background: var(--mova-surface-2) !important;
    border: 1px solid var(--mova-border) !important;
    color: var(--mova-text) !important;
}
.login-container input::placeholder,
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--mova-text-muted) !important; }
.login-container input:focus,
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--mova-accent) !important;
    box-shadow: 0 0 0 3px var(--mova-accent-soft) !important;
}

/* دکمه‌های عمومی */
.btn-primary,
.btn.btn-primary,
#loginBtn,
#changePasswordBtn {
    background: var(--mova-accent) !important;
    color: var(--mova-on-accent) !important;
    border-color: var(--mova-accent) !important;
}
.btn-primary:hover,
#loginBtn:hover { background: var(--mova-accent-strong) !important; }
.btn-secondary,
.btn.btn-secondary {
    background: var(--mova-surface-2) !important;
    color: var(--mova-text) !important;
    border: 1px solid var(--mova-border) !important;
}

/* ------------------------------------------------------------- هدر */
.app-header {
    background: var(--mova-header) !important;
    border-bottom: 1px solid var(--mova-border) !important;
    color: var(--mova-text) !important;
}
.app-header h2 { color: var(--mova-text) !important; }
.menu-btn {
    color: var(--mova-text) !important;
    background: transparent !important;
}
.menu-btn:hover { background: var(--mova-surface-2) !important; }

/* منوی کشویی */
.dropdown-menu {
    background: var(--mova-surface) !important;
    border: 1px solid var(--mova-border) !important;
    box-shadow: 0 12px 32px var(--mova-shadow) !important;
}
.dropdown-menu a { color: var(--mova-text) !important; }
.dropdown-menu a:hover { background: var(--mova-surface-2) !important; }
.menu-divider { background: var(--mova-border) !important; }

/* ------------------------------------------------------- لیست چت‌ها */
.chat-list {
    background: var(--mova-surface) !important;
    border-left: 1px solid var(--mova-border) !important;
}
.chat-search input {
    background: var(--mova-surface-2) !important;
    border: 1px solid var(--mova-border) !important;
    color: var(--mova-text) !important;
}
.chat-search input::placeholder { color: var(--mova-text-muted) !important; }
.chat-item {
    border-bottom: 1px solid var(--mova-border) !important;
    background: transparent;
}
.chat-item:hover { background: var(--mova-surface-2) !important; }
.chat-item.active { background: var(--mova-accent-soft) !important; }
.chat-item-name,
.chat-item .chat-name { color: var(--mova-text) !important; }
.chat-item-message,
.chat-item .chat-preview { color: var(--mova-text-muted) !important; }
.chat-item-time { color: var(--mova-text-muted) !important; }
.unread-badge, .chat-item .unread-count {
    background: var(--mova-accent) !important;
    color: var(--mova-on-accent) !important;
}

/* --------------------------------------------------------- پنجره چت */
.chat-window {
    background: var(--mova-bg) !important;
}
.chat-header {
    background: var(--mova-header) !important;
    border-bottom: 1px solid var(--mova-border) !important;
    color: var(--mova-text) !important;
}
.chat-user-details span,
#chatUserName { color: var(--mova-text) !important; }
.chat-user-status { color: var(--mova-text-muted) !important; }
.chat-window-empty { color: var(--mova-text-muted) !important; }

.messages-container {
    background: var(--mova-bg) !important;
}
.message { color: var(--mova-text) !important; }
.message.sent,
.message.own,
.message.outgoing {
    background: var(--mova-bubble-out) !important;
    color: var(--mova-text) !important;
}
.message.received,
.message.other,
.message.incoming {
    background: var(--mova-bubble-in) !important;
    color: var(--mova-text) !important;
}
.message-time { color: var(--mova-text-muted) !important; }
.edited-badge { color: var(--mova-text-muted) !important; }
.message-sender { color: var(--mova-accent) !important; }

/* نقل‌قول / ریپلای داخل پیام */
.message-reply {
    background: var(--mova-surface-2) !important;
    border-right-color: var(--mova-accent) !important;
    color: var(--mova-text-muted) !important;
}

/* ------------------------------------------------------ کادر نوشتن */
.message-input-container {
    background: var(--mova-header) !important;
    border-top: 1px solid var(--mova-border) !important;
}
.message-input-container input[type="text"],
.message-input-container textarea {
    background: var(--mova-surface) !important;
    border: 1px solid var(--mova-border) !important;
    color: var(--mova-text) !important;
}
.message-input-container input[type="text"]::placeholder,
.message-input-container textarea::placeholder { color: var(--mova-text-muted) !important; }
.message-input-container input[type="text"]:focus,
.message-input-container textarea:focus {
    border-color: var(--mova-accent) !important;
    box-shadow: 0 0 0 3px var(--mova-accent-soft) !important;
}
.typing-indicator-input { color: var(--mova-text-muted) !important; }

/* آیکون‌های فایل/ویس/ارسال در حالت تاریک روشن‌تر دیده شوند */
:root[data-theme="dark"] .attach-btn img,
:root[data-theme="dark"] .voice-btn img,
:root[data-theme="dark"] .send-btn img,
:root[data-theme="dark"] .back-btn img,
:root[data-theme="dark"] .call-btn img {
    filter: invert(0.86) sepia(0.22) saturate(1.6) hue-rotate(340deg);
}

/* ---------------------------------------------------------- مودال‌ها */
.modal { background: var(--mova-overlay) !important; }
.modal-content,
.modal-box {
    background: var(--mova-surface) !important;
    color: var(--mova-text) !important;
    border: 1px solid var(--mova-border) !important;
    box-shadow: 0 20px 50px var(--mova-shadow) !important;
}
.modal-header,
.modal-footer {
    border-color: var(--mova-border) !important;
    color: var(--mova-text) !important;
}
.modal-header h3,
.modal-body,
.modal-body p,
.modal-body label,
.settings-section h4,
.settings-section label { color: var(--mova-text) !important; }
.modal-body small,
.settings-section p,
.settings-hint { color: var(--mova-text-muted) !important; }
.settings-section { border-color: var(--mova-border) !important; }
.modal-close { color: var(--mova-text-muted) !important; }

/* منوی عملیات پیام */
.message-context-menu,
.context-menu {
    background: var(--mova-surface) !important;
    border: 1px solid var(--mova-border) !important;
    box-shadow: 0 14px 36px var(--mova-shadow) !important;
}
.message-context-menu .menu-item,
.context-menu .menu-item { color: var(--mova-text) !important; }
.message-context-menu .menu-item:hover,
.context-menu .menu-item:hover { background: var(--mova-surface-2) !important; }

/* نوار پاسخ و آپلود */
#replyBar {
    background: var(--mova-surface-2) !important;
    border-right-color: var(--mova-accent) !important;
}
#replySender { color: var(--mova-accent) !important; }
#replyContent { color: var(--mova-text-muted) !important; }
.upload-progress-bar {
    background: var(--mova-surface-2) !important;
    border-color: var(--mova-border) !important;
    color: var(--mova-text) !important;
}
.upload-progress-track { background: var(--mova-surface-3) !important; }
.upload-progress-fill { background: var(--mova-accent) !important; }

/* پنل‌های ویس (استایل inline دارند، پس با !important) */
#voiceRecordPanel,
#voicePreviewPanel {
    background: var(--mova-surface) !important;
    color: var(--mova-text) !important;
    box-shadow: 0 -6px 24px var(--mova-shadow) !important;
}
#voiceWaveform { background: var(--mova-surface-2) !important; }
#cancelVoiceBtn { background: #b0503f !important; }
#stopVoiceBtn, #sendVoiceBtn { background: var(--mova-accent) !important; color: var(--mova-on-accent) !important; }

/* نشانگرهای تایپ و بَج‌ها */
.inbox-badge-btn {
    background: var(--mova-surface-2) !important;
    color: var(--mova-text) !important;
    border: 1px solid var(--mova-border) !important;
}
.inbox-badge-count { background: var(--mova-accent) !important; color: var(--mova-on-accent) !important; }
.inbox-toast {
    background: var(--mova-surface) !important;
    color: var(--mova-text) !important;
    border: 1px solid var(--mova-border) !important;
    box-shadow: 0 12px 30px var(--mova-shadow) !important;
}
.scroll-to-bottom-btn {
    background: var(--mova-surface) !important;
    color: var(--mova-accent) !important;
    border: 1px solid var(--mova-border) !important;
}

/* ------------------------------------------------------- قفل صفحه */
.screen-lock-overlay { background: var(--mova-bg) !important; }
.screen-lock-card {
    background: var(--mova-surface) !important;
    box-shadow: 0 18px 46px var(--mova-shadow) !important;
    border: 1px solid var(--mova-border) !important;
}
.screen-lock-icon {
    background: var(--mova-surface-2) !important;
    box-shadow: none !important;
}
.screen-lock-card h2 { color: var(--mova-text) !important; }
.screen-lock-card p { color: var(--mova-text-muted) !important; }
.screen-lock-input {
    background: var(--mova-surface-2) !important;
    color: var(--mova-text) !important;
    box-shadow: inset 0 0 0 1px var(--mova-border) !important;
}
.screen-lock-input::placeholder { color: var(--mova-text-muted) !important; }
.screen-lock-input:focus {
    box-shadow: 0 0 0 3px var(--mova-accent-soft) !important;
}
.screen-lock-btn {
    background: var(--mova-accent) !important;
    color: var(--mova-on-accent) !important;
    box-shadow: none !important;
}
.screen-lock-btn:hover { background: var(--mova-accent-strong) !important; }
.screen-lock-logout { color: var(--mova-text-muted) !important; }
#screenLockToggleLabel { color: var(--mova-text) !important; }
.switch .slider { background: var(--mova-surface-3) !important; }
.switch input:checked + .slider { background: var(--mova-accent) !important; }

/* ----------------------------------------------------- پنل مدیریت */
/* استایل‌های پنل به‌صورت inline تعریف شده‌اند؛ پس با !important بازنویسی می‌شوند. */
body,
.admin-container,
.admin-main { background: var(--mova-bg) !important; color: var(--mova-text) !important; }

.admin-header {
    background: var(--mova-header) !important;
    border-bottom: 1px solid var(--mova-border) !important;
    color: var(--mova-text) !important;
}
.admin-header h1 { color: var(--mova-text) !important; }
.admin-header a { color: var(--mova-text) !important; background: var(--mova-surface-2) !important; }
.admin-header a:hover { background: var(--mova-accent) !important; color: var(--mova-on-accent) !important; }
.admin-header .btn-back { background: var(--mova-accent) !important; color: var(--mova-on-accent) !important; }

.admin-card,
.admin-panel,
.admin-section,
.admin-tab-content,
.admin-main > div,
.admin-container > div:not(.admin-header) {
    background: var(--mova-surface) !important;
    color: var(--mova-text) !important;
    border-color: var(--mova-border) !important;
}
.admin-card h2,
.admin-card h3,
.admin-container h2,
.admin-container h3,
.admin-container h4 { color: var(--mova-text) !important; }

/* جدول‌ها */
.admin-container table,
table { color: var(--mova-text) !important; }
.admin-container thead th,
table thead th {
    background: var(--mova-surface-2) !important;
    color: var(--mova-text) !important;
    border-color: var(--mova-border) !important;
}
.admin-container td,
.admin-container th { border-color: var(--mova-border) !important; }
.admin-container tbody tr:nth-child(even) { background: var(--mova-surface-2) !important; }

/* تب‌ها و دکمه‌ها */
.admin-tab,
.admin-tabs button {
    background: var(--mova-surface-2) !important;
    color: var(--mova-text) !important;
    border-color: var(--mova-border) !important;
}
.admin-tab.active,
.admin-tabs button.active {
    background: var(--mova-accent) !important;
    color: var(--mova-on-accent) !important;
}
.admin-container .btn-primary,
.admin-container button[onclick] { color: inherit; }

/* پیام‌های وضعیت */
.success-message, .alert-success { background: var(--mova-surface-2) !important; color: var(--mova-text) !important; }
.error-message { color: #b0503f !important; }
.admin-container input,
.admin-container select,
.admin-container textarea {
    background: var(--mova-surface-2) !important;
    color: var(--mova-text) !important;
    border: 1px solid var(--mova-border) !important;
}

/* --------------------------------------------------- پیام نصب PWA */
.pwa-install-banner {
    background: var(--mova-surface) !important;
    color: var(--mova-text) !important;
    border: 1px solid var(--mova-border) !important;
    box-shadow: 0 12px 30px var(--mova-shadow) !important;
}
.pwa-install-btn { background: var(--mova-accent) !important; color: var(--mova-on-accent) !important; }
.pwa-install-text span { color: var(--mova-text-muted) !important; }

/* ============================================================
   کلید تم روشن/تاریک
   ============================================================ */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--mova-border);
    background: var(--mova-surface-2);
    color: var(--mova-text);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    transition: background 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.theme-toggle-btn:hover { background: var(--mova-surface-3); }
.theme-toggle-btn:active { transform: scale(0.94); }
.theme-toggle-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--mova-accent-soft);
}
.theme-toggle-icon { font-size: 18px; }

/* کلید در صفحه ورود و تغییر رمز (بالا سمت چپ صفحه) */
.page-theme-toggle {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 50;
}

/* در هدر برنامه: اولین آیتم سمت چپ (RTL) */
.header-left .theme-toggle-btn { margin-left: 2px; }
@media (max-width: 768px) {
    .theme-toggle-btn { width: 36px; height: 36px; font-size: 16px; }
    .theme-toggle-icon { font-size: 16px; }
}

/* ============================================================
   چیدمان کادر نوشتن پیام — سبک آی‌مسج (iMessage)
   میکروفن و ارسال **داخل** کادر و سمت راست آن هستند
   (در هر لحظه فقط یکی) | ارسال فایل بیرون و سمت چپ
   ============================================================ */
.message-input-container .input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* کادر نوشتن با میکروفن شناور داخل خودش */
.message-input-container .input-field-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
}

/* ------------------------------------------------------------
   میکروفن و دکمهٔ ارسال: داخل کادر، روی لبهٔ چپ
   هر دو با position:absolute روی یک نقطه قرار می‌گیرند؛
   (بقیهٔ رابط RTL است؛ این دو دکمه در لبهٔ چپ کادر می‌نشینند
   و با تایپ اولین حرف، میکروفن محو و ارسال نمایان می‌شود)
   سمت راست متن هم با padding خالی می‌شود تا متن زیر دکمه نرود —
   جزئیات آن در بلوک بعد از دکمهٔ ارسال آمده است.
   ------------------------------------------------------------ */
.message-input-container .voice-btn {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.message-input-container .voice-btn:hover { background: var(--mova-surface-2); }
.message-input-container .voice-btn.recording { animation: mova-mic-pulse 1s infinite; }
.message-input-container .voice-btn img, .message-input-container .voice-btn svg { width: 40px; height: 40px; display: block; }
/* با اولین حرف مخفی می‌شود و جایش را به دکمه‌ی ارسال می‌دهد */
.message-input-container .voice-btn.is-hidden,
.message-input-container .send-btn.is-hidden {
    opacity: 0; pointer-events: none;
    transform: translateY(-50%) scale(0.6);
}
:root[data-theme="dark"] .message-input-container .voice-btn img {
    filter: invert(0.86) sepia(0.22) saturate(1.6) hue-rotate(340deg);
}
/* دکمه‌های فایل و ارسال */
.message-input-container .attach-btn,
/* ------------------------------------------------------------
   دکمهٔ ارسال دقیقاً روی جای میکروفن می‌نشیند (سمت چپ کادر)
   با تایپ اولین حرف، میکروفن محو می‌شود و ارسال ظاهر می‌شود؛
   فاصلهٔ متن از این دکمه در بلوک بعدی تنظیم شده است.
   ------------------------------------------------------------ */

.message-input-container .send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    flex: 0 0 auto;
}
.message-input-container .attach-btn:hover { background: var(--mova-surface-2); }
.message-input-container .attach-btn img,
.message-input-container .send-btn img { width: 48px; height: 48px; display: block; }
.message-input-container .send-btn {
    position: absolute;
    /* دقیقاً روی نقطهٔ میکروفن تا هنگام تعویض جابه‌جایی دیده نشود */
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: var(--mova-accent);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.message-input-container .send-btn:hover { background: var(--mova-accent-strong); }
.message-input-container .send-btn:disabled { opacity: 0.5; }

.message-input-container .input-field-wrap input[type="text"],
.message-input-container .input-field-wrap textarea {
    width: 100%;
    /* دکمه‌های میکروفن/ارسال روی لبهٔ چپ کادر هستند، پس متن باید از
       سمت چپ فاصله بگیرد تا زیر دکمه نرود؛ سمت راست آزاد است. */
    padding-left: 50px !important;
}

/* کادر قفل‌شده (مثلاً در «ذخیره مووا»): دکمه‌ها دیده می‌شوند ولی کار نمی‌کنند
   تا کادر هیچ‌وقت بی‌دکمه به نظر نرسد. */
.message-input-container.is-locked .voice-btn,
.message-input-container.is-locked .send-btn {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ============================================================
   نوار ویرایش داخل کادر نوشتن (جایگزین prompt)
   ============================================================ */
.edit-bar {
    display: none;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    background: var(--mova-surface-2);
    border-right: 4px solid var(--mova-accent);
}
.edit-bar.is-active { display: flex; }
.edit-bar-icon { font-size: 16px; flex: 0 0 auto; }
.edit-bar-body { flex: 1 1 auto; min-width: 0; }
.edit-bar-title {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--mova-accent);
    margin-bottom: 2px;
}
.edit-bar-text {
    display: block;
    font-size: 13px;
    color: var(--mova-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.edit-bar-cancel {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--mova-text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
}
.edit-bar-cancel:hover { background: var(--mova-surface-3); }

.message-input-container.is-editing .input-field-wrap input[type="text"],
.message-input-container.is-editing .input-field-wrap textarea {
    border-color: var(--mova-accent) !important;
    box-shadow: 0 0 0 3px var(--mova-accent-soft) !important;
}

.message-input-container.is-error .edit-bar {
    background: #f6dcd8;
    border-right-color: #b0503f;
}
.message-input-container.is-error .edit-bar-title { color: #9c3f2f; }
:root[data-theme="dark"] .message-input-container.is-error .edit-bar { background: #4a2a22; }
:root[data-theme="dark"] .message-input-container.is-error .edit-bar-title { color: #e3a294; }

/* کادر قفل صفحه در حالت خطا */
.screen-lock-card.is-error .screen-lock-input {
    box-shadow: 0 0 0 2px #b0503f !important;
}
.screen-lock-card.is-error .screen-lock-btn { display: block; }

@keyframes mova-mic-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.14); }
    100% { transform: scale(1); }
}
/* موبایل: کادر و دکمه‌ها جمع‌وجورتر، بدون سرریز */
@media (max-width: 480px) {
    .message-input-container .input-row { gap: 4px; }
    .message-input-container .attach-btn,
    .message-input-container .send-btn { width: 36px; height: 36px; }
    .message-input-container .attach-btn img,
    .message-input-container .send-btn img { width: 40px; height: 40px; }
    .message-input-container .voice-btn,
    .message-input-container .send-btn { width: 36px; height: 36px; left: 3px; }
    .message-input-container .voice-btn img,
    .message-input-container .send-btn img { width: 40px; height: 40px; }
    .message-input-container .input-field-wrap input[type="text"],
    .message-input-container .input-field-wrap textarea { padding-left: 50px !important; }
    .edit-bar { padding: 6px 10px; gap: 8px; }
    .edit-bar-text { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .message-input-container .voice-btn.recording { animation: none; }
    .theme-toggle-btn { transition: none; }
}

/* ============================================================
   پخش‌کنندهٔ موزیک داخل چت
   کاور سمت چپ | عنوان و نوار پیشرفت سمت راست
   ============================================================ */
.mova-track {
    display: block;
    width: 100%;
    min-width: 210px;
    max-width: 320px;
    margin: 2px 0;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    /* پلیر همیشه چپ‌به‌راست است، حتی داخل صفحه‌ی راست‌به‌چپ */
    direction: ltr;
    unicode-bidi: isolate;
}

.mova-track-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- کاور: دانلود / پخش ---------- */
.mova-track-cover {
    position: relative;
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background-color: var(--mova-surface-3);
    background-size: cover;
    background-position: center;
    color: var(--mova-on-accent);
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px var(--mova-shadow);
    transition: transform 0.15s ease;
}
.mova-track-cover:active { transform: scale(0.94); }

.mova-track-cover-fallback {
    font-size: 24px;
    color: var(--mova-text-muted);
    line-height: 1;
}

/* پوشش تیرهٔ روی کاور برای خوانایی آیکون‌ها */
.mova-track-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}
.mova-track-cover[data-state="idle"]::after,
.mova-track-cover[data-state="ready"]::after,
.mova-track-cover[data-state="downloading"]::after,
.mova-track-cover[data-state="playing"]::after { opacity: 1; }

/* آیکون‌های روی کاور */
.mova-track-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}
.mova-track-overlay svg { width: 22px; height: 22px; color: #fff; }

/* حالت ندانلودشده: علامت دانلود */
.mova-track-cover[data-state="idle"] .mova-track-overlay-download { opacity: 1; }

/* حالت دانلودشده / پخش: علامت پخش */
.mova-track-cover[data-state="ready"] .mova-track-overlay-play,
.mova-track-cover[data-state="playing"] .mova-track-overlay-play { opacity: 1; }

/* وسط کاور: پلی؛ در حال پخش: مکث */
.mova-track-icon-pause { display: none; }
.mova-track-cover[data-state="playing"] .mova-track-icon-play { display: none; }
.mova-track-cover[data-state="playing"] .mova-track-icon-pause { display: inline; }

/* ---------- چرخهٔ دانلود ---------- */
.mova-track-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    z-index: 3;
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}
.mova-track-cover[data-state="downloading"] .mova-track-ring { opacity: 1; }

.mova-track-ring-bg,
.mova-track-ring-fill {
    fill: none;
    stroke-width: 3;
}
.mova-track-ring-bg { stroke: rgba(255, 255, 255, 0.28); }
.mova-track-ring-fill {
    stroke: #fff;
    stroke-linecap: round;
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    transition: stroke-dashoffset 0.25s ease;
}

/* درصد وسط کاور */
.mova-track-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}
.mova-track-cover[data-state="downloading"] .mova-track-percent { opacity: 1; }
.mova-track-cover[data-state="downloading"] .mova-track-overlay { opacity: 0; }

/* ---------- متن، نوار پیشرفت و زمان ---------- */
.mova-track-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mova-track-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--mova-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    text-align: left;
}

.mova-track-artist {
    font-size: 11.5px;
    color: var(--mova-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    text-align: left;
}

.mova-track-progress {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 3px;
}

/* نوار پیشرفت (input range) با ظاهر باریک */
.mova-track-seek {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    background: transparent;
    cursor: pointer;
    margin: 0;
    padding: 0;
}
.mova-track-seek::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: var(--mova-surface-3);
}
.mova-track-seek::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: var(--mova-surface-3);
}
.mova-track-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 11px;
    height: 11px;
    margin-top: -3.5px;
    border-radius: 50%;
    background: var(--mova-accent);
    border: none;
    box-shadow: 0 0 0 3px var(--mova-accent-soft);
    transition: transform 0.12s ease;
}
.mova-track-seek::-moz-range-thumb {
    width: 11px;
    height: 11px;
    border: none;
    border-radius: 50%;
    background: var(--mova-accent);
    box-shadow: 0 0 0 3px var(--mova-accent-soft);
}
.mova-track-seek:active::-webkit-slider-thumb { transform: scale(1.2); }

.mova-track-times {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10.5px;
    color: var(--mova-text-muted);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: isolate;
}
/* چیدمان چپ‌به‌راست: زمان گذشته چپ، مدت کل راست */
.mova-track-elapsed { order: 1; }
.mova-track-duration { order: 2; }

.mova-track-audio { display: none; }

/* در حالت پخش، عنوان کمی رنگ لهجه می‌گیرد */
.mova-track.is-playing .mova-track-title { color: var(--mova-accent-strong); }

/* پیام موزیک نباید حباب اضافی داشته باشد */
.message.has-track { padding-bottom: 6px; }

/* ---------- منوی لمس طولانی ---------- */
.mova-track-menu {
    position: fixed;
    z-index: 10050;
    min-width: 210px;
    padding: 6px;
    border-radius: 12px;
    background: var(--mova-surface);
    border: 1px solid var(--mova-border);
    box-shadow: 0 8px 28px var(--mova-shadow);
    animation: mova-track-menu-in 0.14s ease;
}
@keyframes mova-track-menu-in {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.mova-track-menu-item {
    display: block;
    width: 100%;
    padding: 11px 12px;
    border: none;
    background: transparent;
    border-radius: 9px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--mova-text);
    text-align: right;
    cursor: pointer;
}
.mova-track-menu-item:hover,
.mova-track-menu-item:active { background: var(--mova-surface-2); }
.mova-track-menu-item.is-danger { color: #c0392b; }
:root[data-theme="dark"] .mova-track-menu-item.is-danger { color: #ff8a7a; }
.mova-track-menu-item + .mova-track-menu-item { margin-top: 1px; }

/* ---------- توست ---------- */
.mova-track-toast {
    position: fixed;
    left: 50%;
    bottom: 92px;
    transform: translate(-50%, 12px);
    z-index: 10060;
    max-width: 82vw;
    padding: 10px 16px;
    border-radius: 22px;
    background: var(--mova-accent-strong);
    color: var(--mova-on-accent);
    font-family: inherit;
    font-size: 13px;
    box-shadow: 0 6px 22px var(--mova-shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.mova-track-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- موبایل ---------- */
@media (max-width: 480px) {
    .mova-track { min-width: 190px; max-width: 260px; }
    .mova-track-cover { width: 48px; height: 48px; border-radius: 10px; }
    .mova-track-title { font-size: 12.5px; }
    .mova-track-artist { font-size: 11px; }
}

/* ---------- دسترس‌پذیری: احترام به کاهش حرکت ---------- */
@media (prefers-reduced-motion: reduce) {
    .mova-track-cover,
    .mova-track-ring-fill,
    .mova-track-percent,
    .mova-track-overlay,
    .mova-track-toast { transition: none !important; }
    .mova-track-menu { animation: none; }
}

/* ============================================================
   لایک پیام — دوبار ضربه و قلب کوچک پایین پیام
   ============================================================ */
.message[data-message-id] {
    position: relative;
}

/* قلب پایین پیام: بدون کادر و پس‌زمینه، روی لبه‌ی پیام می‌نشیند
   و کمی از آن بیرون می‌زند (سبک آی‌مسج) */
.mova-like-badge {
    position: absolute;
    bottom: -9px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    font-size: 15px;
    line-height: 1;
    color: var(--mova-text-muted);
    transform-origin: bottom center;
    animation: mova-like-in 0.32s cubic-bezier(0.22, 1.4, 0.4, 1);
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;   /* ضربه‌های بعدی به خود پیام برسد */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* پیام‌های دیگران: قلب سمت راست لبه، پیام‌های خودم: سمت چپ لبه */
.message.received > .mova-like-badge { right: 6px; }
.message.sent > .mova-like-badge,
.message.own > .mova-like-badge { left: 6px; }
/* اگر کلاس جهت نبود، پیش‌فرض سمت راست */
.message > .mova-like-badge { right: 6px; }

.mova-like-badge .mova-like-heart {
    font-size: 15px;
    line-height: 1;
    display: inline-block;
}

.mova-like-badge .mova-like-count {
    font-size: 11px;
    font-weight: 700;
}
.mova-like-badge .mova-like-count:empty { display: none; }

/* وقتی خود کاربر لایک کرده، قلب پررنگ‌تر دیده می‌شود (بدون کادر) */
.mova-like-badge.is-mine {
    color: var(--mova-accent-strong);
}

@keyframes mova-like-in {
    0%   { opacity: 0; transform: translateY(5px) scale(0.4); }
    60%  { opacity: 1; transform: translateY(0) scale(1.18); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* تکان کوتاه بعد از هر تغییر */
.mova-like-badge.is-pop .mova-like-heart {
    animation: mova-like-thump 0.45s ease;
}
@keyframes mova-like-thump {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.55) rotate(-8deg); }
    65%  { transform: scale(0.92) rotate(4deg); }
    100% { transform: scale(1) rotate(0); }
}

/* قلبی که از مرکز پیام پرواز می‌کند */
.mova-like-burst {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 5;
    font-size: 42px;
    line-height: 1;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: mova-like-burst 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.22));
}

@keyframes mova-like-burst {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
    25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
    55%  { opacity: 0.95; transform: translate(-50%, -62%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -105%) scale(0.72); }
}

/* قلب بیرون از حباب می‌نشیند؛ حباب نباید آن را ببرد */
.message.has-likes { overflow: visible; }

/* در تم تاریک قلب کمی روشن‌تر دیده شود */
:root[data-theme="dark"] .mova-like-burst {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

/* ---------- دسترس‌پذیری ---------- */
@media (prefers-reduced-motion: reduce) {
    .mova-like-badge { animation: none; }
    .mova-like-badge.is-pop .mova-like-heart { animation: none; }
    .mova-like-burst { animation: mova-like-burst-fade 0.3s ease forwards; }
    @keyframes mova-like-burst-fade {
        from { opacity: 0; }
        to   { opacity: 0; }
    }
}

/* ============================================================
   حباب آپلود درون‌خطی (سبک تلگرام)
   درصد پیشرفت روی خود پیام نوشته می‌شود
   ============================================================ */
.mova-upload-bubble {
    position: relative;
    max-width: 280px;
    animation: mova-upload-in 0.2s ease;
}
@keyframes mova-upload-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* پیام آپلود عکس/ویدیو نباید حباب رنگی داشته باشد */
.mova-upload-bubble-media {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.mova-upload-media {
    position: relative;
    display: inline-block;
    max-width: 240px;
    border-radius: 14px;
    overflow: hidden;
    background: var(--mova-surface-3);
    line-height: 0;
}

.mova-upload-media .mova-upload-preview {
    display: block;
    max-width: 240px;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: cover;
    filter: brightness(0.62);   /* تصویر زیر لایهٔ پیشرفت تیره می‌شود */
}

.mova-upload-video .mova-upload-preview { min-width: 160px; }

/* حلقهٔ درصد دور عکس/ویدیو */
.mova-upload-ring {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 56px;
    height: 56px;
    transform: rotate(-90deg);
    pointer-events: none;
    z-index: 2;
}
.mova-upload-ring-bg,
.mova-upload-ring-fill {
    fill: none;
    stroke-width: 3.5;
}
.mova-upload-ring-bg { stroke: rgba(255, 255, 255, 0.3); }
.mova-upload-ring-fill {
    stroke: #fff;
    stroke-linecap: round;
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    transition: stroke-dashoffset 0.25s ease;
}

/* درصد وسط حلقه */
.mova-upload-media .mova-upload-percent {
    position: absolute;
    inset: 0;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    line-height: 1;
}

/* دکمهٔ ▶ روی ویدیو (فقط زمانی که آپلود تمام شد معنا دارد) */
.mova-upload-video-play {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 3;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: default;
    pointer-events: none;
}

/* زیرنویس نام و حجم فایل */
.mova-upload-caption {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 10.5px;
    color: var(--mova-text-muted);
}
.mova-upload-caption .mova-upload-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 170px;
    direction: ltr;
    text-align: left;
}

/* فایل‌های غیرتصویری */
.mova-upload-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--mova-surface-2);
    border: 1px solid var(--mova-border);
}
.mova-upload-file-icon { font-size: 20px; line-height: 1; }
.mova-upload-file-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}
.mova-upload-file .mova-upload-percent {
    font-size: 12px;
    font-weight: 700;
    color: var(--mova-accent-strong);
    font-variant-numeric: tabular-nums;
}

/* حالت خطا */
.mova-upload-bubble.is-failed .mova-upload-percent,
.mova-upload-bubble.is-failed .mova-track-percent { color: #ffb4a8; }
.mova-upload-error {
    margin-top: 4px;
    font-size: 11px;
    color: #c0392b;
}
:root[data-theme="dark"] .mova-upload-error { color: #ff8a7a; }

/* حباب موزیک در حال آپلود، همان ظاهر پلیر را دارد */
.mova-track-upload .mova-track-artist { color: var(--mova-accent-strong); }
.mova-track-upload .mova-track-seek { pointer-events: none; opacity: 0.55; }

@media (max-width: 480px) {
    .mova-upload-media,
    .mova-upload-media .mova-upload-preview { max-width: 190px; }
    .mova-upload-media .mova-upload-preview { max-height: 220px; }
    .mova-upload-ring { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    .mova-upload-bubble { animation: none; }
    .mova-upload-ring-fill { transition: none; }
}

/* ============================================================
   عکس و ویدیو بدون حباب
   --------------------------------------------
   پیام عکس/ویدیو فقط خود تصویر است؛ ساعت، وضعیت دیده‌شدن،
   دکمهٔ دانلود و لایک روی خود تصویر می‌نشینند.
   ============================================================ */

/* حباب رنگی برای پیام‌های رسانه‌ای حذف می‌شود */
.message.media-only,
.message.media-only.sent,
.message.media-only.received {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: min(320px, 78vw);
    overflow: visible;
}

.mova-media {
    position: relative;
    display: inline-block;
    border-radius: 16px;
    overflow: hidden;
    background: var(--mova-surface-3);
    line-height: 0;
    max-width: 100%;
    box-shadow: 0 1px 4px var(--mova-shadow);
}

.mova-media .mova-media-el {
    display: block;
    max-width: 100%;
    max-height: 320px;
    /* ارتفاع رزرو‌شده: تا عکس/ویدیو بارگذاری شود، ارتفاع صفر نگیرد و
       فهرست پیام‌ها جابه‌جا (پرش) نشود. نسبت واقعی با aspect-ratio
       می‌آید و MovaMedia.freeze آن را تثبیت می‌کند. */
    min-height: 120px;
    width: auto;
    height: auto;
    border-radius: 0;
    margin: 0;
    object-fit: cover;
    cursor: pointer;
}

/* وقتی ابعاد واقعی معلوم شد، ارتفاع رزرو آزاد می‌شود */
.mova-media .mova-media-el.is-frozen {
    min-height: 0;
}
.mova-media[data-media-kind="video"] .mova-media-el {
    min-width: 180px;
    cursor: default;
}

/* نوار اطلاعات روی تصویر */
.mova-media-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 18px 8px 6px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
    pointer-events: none;
    z-index: 2;
    line-height: 1.2;
}

.mova-media-time {
    font-size: 10.5px;
    color: #fff;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.mova-media-status {
    font-size: 10.5px;
    color: #fff;
    letter-spacing: -2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.mova-media-status.seen { color: #8ecdf7; }

/* دکمه‌های قابل کلیک روی تصویر باید pointer-events داشته باشند */
.mova-media-btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    margin-right: auto;   /* دکمه به سمت چپ نوار می‌رود */
    transition: background 0.15s ease, transform 0.15s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.mova-media-btn svg { width: 15px; height: 15px; }
.mova-media-btn:hover { background: rgba(255, 255, 255, 0.32); }
.mova-media-btn:active { transform: scale(0.92); }
.mova-media-btn.is-done { background: var(--mova-accent); }

/* لایک روی عکس/ویدیو هم باید دیده شود */
.message.media-only > .mova-like-badge {
    bottom: -10px;
    font-size: 16px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    z-index: 3;
}
.message.media-only.has-likes { margin-bottom: 8px; }

/* در تم تاریک، نوار اطلاعات کمی تیره‌تر */
:root[data-theme="dark"] .mova-media-overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
}

@media (max-width: 480px) {
    .message.media-only { max-width: 80vw; }
    .mova-media .mova-media-el { max-height: 260px; }
    .mova-media-btn { width: 24px; height: 24px; }
}
