/* =============================================================
   Massager(i) — Premium Mobile-First UI (Fixed Inputs)
   ============================================================= */
@font-face { font-family: 'Vazirmatn'; src: url('/assets/fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/assets/fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

[hidden] { display: none !important; }

:root {
  --nx-bg: #050914; --nx-bg-2: #0a0f24; --nx-surface: rgba(20, 27, 55, 0.65); --nx-surface-solid: #121838;
  --nx-surface-hover: rgba(35, 45, 85, 0.75); --nx-border: rgba(120, 150, 220, 0.15); --nx-border-strong: rgba(120, 150, 220, 0.3);
  --nx-text: #eaf0ff; --nx-text-2: #a9b5d6; --nx-text-3: #6b7a9e; --nx-primary: #2b6cff; --nx-primary-2: #00e5ff;
  --nx-danger: #ff4560; --nx-success: #22d18b;
  --nx-grad: linear-gradient(135deg, #00e5ff 0%, #2b6cff 50%, #a06bff 100%);
  --nx-grad-btn: linear-gradient(135deg, #2b6cff 0%, #a06bff 100%);
  --nx-radius: 16px; --nx-radius-lg: 24px; --nx-blur: 24px;
  --nx-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; }
body { font-family: 'Vazirmatn', system-ui, sans-serif; font-size: 15px; background: var(--nx-bg); color: var(--nx-text); -webkit-text-size-adjust: 100%; height: 100dvh; }

/* 🔴 اصلاح اصلی: رنگ اجباری متن در تمام inputها و textareaها */
button, input, textarea, select { font: inherit; outline: none; }
input, textarea { 
  color: var(--nx-text) !important; 
  -webkit-text-fill-color: var(--nx-text) !important; 
  caret-color: var(--nx-primary-2) !important; 
  font-size: 16px !important; /* جلوگیری از زوم در iOS */
}
button { cursor: pointer; background: none; border: 0; }

.nx-splash { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; background: radial-gradient(ellipse at 30% 20%, #141f4a 0%, #050914 60%); overflow: hidden; }
.nx-splash.nx-hide { animation: nxFadeOut 500ms ease forwards; pointer-events: none; }
.nx-splash__orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.5; }
.nx-splash__orb--1 { width: 380px; height: 380px; background: radial-gradient(circle, #00e5ff, transparent 70%); top: 10%; left: 8%; animation: nxOrbFloat 8s ease-in-out infinite; }
.nx-splash__orb--2 { width: 420px; height: 420px; background: radial-gradient(circle, #a06bff, transparent 70%); bottom: 5%; right: 5%; animation: nxOrbFloat 10s ease-in-out infinite reverse; }
.nx-splash__card { position: relative; z-index: 2; text-align: center; color: #fff; }
.nx-splash__title { font-size: 2.5rem; font-weight: 700; margin: 16px 0 0; background: var(--nx-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nx-splash__sub { color: #8fa2c9; margin: 0; font-size: 1rem; }
.nx-loader { display: flex; gap: 8px; justify-content: center; margin-top: 28px; }
.nx-loader span { width: 10px; height: 10px; border-radius: 50%; background: var(--nx-grad-btn); animation: nxBounce 1.2s ease-in-out infinite; }

.nx-app { position: relative; width: 100%; height: 100%; display: flex; overflow: hidden; }
.nx-view { flex: 1; display: flex; min-width: 0; min-height: 0; height: 100%; }

/* AUTH */
.nx-view--auth { position: relative; justify-content: center; align-items: center; padding: 20px; background: radial-gradient(ellipse at 50% 0%, #141f4a 0%, #050914 55%); }
.nx-auth-bg__orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.55; }
.nx-auth-bg__orb--a { width: 300px; height: 300px; background: radial-gradient(circle, #2b6cff, transparent 70%); top: -10%; left: -8%; }
.nx-auth-bg__orb--b { width: 350px; height: 350px; background: radial-gradient(circle, #a06bff, transparent 70%); bottom: -20%; right: -10%; }
.nx-auth-card { position: relative; z-index: 1; width: 100%; max-width: 400px; padding: 24px; background: var(--nx-surface); backdrop-filter: blur(var(--nx-blur)); border: 1px solid var(--nx-border-strong); border-radius: var(--nx-radius-lg); box-shadow: var(--nx-shadow); }
.nx-auth-card__logo { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.nx-auth-card__brand { margin: 0; font-size: 1.5rem; background: var(--nx-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nx-auth-card__tag { margin: 0; color: var(--nx-text-2); font-size: 0.85rem; }
.nx-tabs { position: relative; display: flex; gap: 4px; padding: 4px; background: rgba(0,0,0,0.25); border-radius: var(--nx-radius); margin-bottom: 20px; }
.nx-tab { flex: 1; padding: 10px; border-radius: 12px; color: var(--nx-text-2); font-weight: 500; z-index: 2; text-align: center; }
.nx-tab.is-active { color: #fff; }
.nx-tabs__indicator { position: absolute; top: 4px; bottom: 4px; width: calc(50% - 4px); border-radius: 12px; background: var(--nx-grad-btn); transition: transform 0.3s; z-index: 1; }
.nx-tab:nth-child(2).is-active ~ .nx-tabs__indicator { transform: translateX(calc(-100% - 4px)); }

.nx-form { display: flex; flex-direction: column; gap: 14px; }
.nx-field { display: flex; flex-direction: column; gap: 6px; }
.nx-field__label { font-size: 0.85rem; color: var(--nx-text-2); }
.nx-field input { width: 100%; padding: 12px; background: rgba(0,0,0,0.25); border: 1px solid var(--nx-border); border-radius: 12px; color: var(--nx-text); transition: 0.2s; }
.nx-field input:focus { border-color: var(--nx-primary-2); box-shadow: 0 0 0 3px rgba(0,229,255,0.15); }

.nx-btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 18px; border-radius: 12px; font-weight: 600; transition: 0.2s; min-height: 48px; }
.nx-btn:active { transform: scale(0.97); }
.nx-btn--primary { background: var(--nx-grad-btn); color: #fff; box-shadow: 0 4px 15px rgba(43,108,255,0.3); }
.nx-btn--danger { background: var(--nx-danger); color: #fff; }
.nx-btn--ghost { background: rgba(255,255,255,0.1); color: #fff; }
.nx-btn--lg { font-size: 1rem; }
.nx-btn--sm { padding: 8px 12px; min-height: 38px; font-size: 0.85rem; }
.nx-btn--icon { width: 48px; height: 48px; padding: 0; border-radius: 50%; }
.nx-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--nx-text-2); }

/* CHAT LAYOUT */
.nx-view--chat { position: relative; overflow: hidden; }
.nx-sidebar { display: flex; flex-direction: column; width: 100%; height: 100%; background: var(--nx-bg-2); }
.nx-sidebar__head { display: flex; align-items: center; justify-content: center; padding: 16px; border-bottom: 1px solid var(--nx-border); }
.nx-sidebar__brandname { font-weight: 700; font-size: 1.2rem; background: var(--nx-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nx-sidebar__search { padding: 12px 16px; }
.nx-sidebar__search input { width: 100%; padding: 12px 40px 12px 12px; background: var(--nx-surface); border: 1px solid var(--nx-border); border-radius: 12px; color: var(--nx-text); }
.nx-chatlist { flex: 1; overflow-y: auto; padding: 8px; }
.nx-chatitem { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; cursor: pointer; transition: background 0.2s; }
.nx-chatitem:active { background: var(--nx-surface-hover); }
.nx-chatitem.is-active { background: rgba(43,108,255,0.15); }
.nx-chatitem__body { flex: 1; min-width: 0; }
.nx-chatitem__name { font-weight: 600; font-size: 1rem; }
.nx-chatitem__preview { font-size: 0.85rem; color: var(--nx-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.nx-sidebar__foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-bottom: env(safe-area-inset-bottom, 16px); border-top: 1px solid var(--nx-border); background: var(--nx-bg-2); }
.nx-userbtn { display: flex; align-items: center; gap: 12px; flex: 1; text-align: right; }
.nx-userbtn__name { font-weight: 600; font-size: 1rem; display: block; }
.nx-userbtn__handle { font-size: 0.8rem; color: var(--nx-text-3); }
.nx-avatar { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: var(--nx-grad-btn); color: #fff; font-weight: 700; background-size: cover; background-position: center; flex-shrink: 0; }
.nx-avatar--sm { width: 38px; height: 38px; font-size: 0.9rem; }
.nx-avatar--xl { width: 80px; height: 80px; font-size: 1.5rem; }

.nx-chatpanel { display: none; flex-direction: column; width: 100%; height: 100%; background: var(--nx-bg); position: absolute; inset: 0; z-index: 20; }
.nx-view--chat.is-chat-open .nx-chatpanel { display: flex; }

.nx-chatpanel__head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--nx-border); background: var(--nx-surface); backdrop-filter: blur(10px); }
.nx-chatpanel__peer { display: flex; align-items: center; gap: 10px; flex: 1; }
.nx-chatpanel__peer-name { font-weight: 600; font-size: 1rem; }
.nx-chatpanel__body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
.nx-messages { display: flex; flex-direction: column; gap: 10px; max-width: 900px; margin: 0 auto; width: 100%; margin-top: auto; }

/* MESSAGE */
.nx-msg { display: flex; flex-direction: column; max-width: 85%; align-self: flex-start; position: relative; }
.nx-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.nx-msg__bubble { padding: 12px 16px; border-radius: 20px; background: var(--nx-surface-solid); border: 1px solid var(--nx-border); color: var(--nx-text); word-wrap: break-word; font-size: 0.95rem; line-height: 1.5; }
.nx-msg.is-mine .nx-msg__bubble { background: var(--nx-grad-btn); color: #fff; border: none; border-bottom-right-radius: 6px; }
.nx-msg:not(.is-mine) .nx-msg__bubble { border-bottom-left-radius: 6px; }
.nx-msg__meta { font-size: 0.75rem; color: var(--nx-text-3); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.nx-msg__edited { color: var(--nx-primary-2); font-style: italic; font-size: 0.7rem; }
.nx-msg__deleted { font-style: italic; opacity: 0.6; font-size: 0.9rem; }
.nx-msg.is-deleted .nx-msg__bubble { background: transparent !important; border: 1px dashed var(--nx-border-strong); color: var(--nx-text-3) !important; }

/* دکمه‌های ویرایش/حذف */
.nx-msg__actions { display: flex; gap: 4px; margin-top: 4px; opacity: 0.6; transition: opacity 0.2s; }
.nx-msg:hover .nx-msg__actions { opacity: 1; }
.nx-msg__action { width: 26px; height: 26px; border-radius: 8px; background: var(--nx-surface); border: 1px solid var(--nx-border); display: inline-flex; align-items: center; justify-content: center; color: var(--nx-text-2); cursor: pointer; transition: 0.15s; }
.nx-msg__action:hover { color: var(--nx-text); background: var(--nx-surface-hover); border-color: var(--nx-border-strong); }
.nx-msg__action:active { transform: scale(0.9); }

/* 🔴 اصلاح کادر ویرایش پیام */
.nx-msg__bubble.is-editing { background: rgba(10, 15, 36, 0.95) !important; border: 1px solid var(--nx-border-strong) !important; padding: 12px !important; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.nx-msg__edit-input { 
  width: 100%; min-width: 220px; background: rgba(0,0,0,0.4) !important; 
  border: 1px solid var(--nx-border); border-radius: 12px; 
  color: var(--nx-text) !important; 
  font-size: 0.95rem; line-height: 1.5; resize: none; font-family: inherit; padding: 10px; outline: none; transition: border 0.2s;
}
.nx-msg__edit-input:focus { border-color: var(--nx-primary-2); }
.nx-msg__edit-actions { display: flex; gap: 6px; margin-top: 10px; justify-content: flex-end; }

/* 🔴 اصلاح کادر ارسال پیام (Composer) */
.nx-composer { 
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; 
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); 
  border-top: 1px solid var(--nx-border); 
  background: var(--nx-surface); 
  backdrop-filter: blur(10px);
  flex-shrink: 0; 
}
.nx-composer__wrap { 
  flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--nx-border); 
  border-radius: 24px; padding: 4px 12px; display: flex; align-items: center; 
  transition: all 0.2s ease; 
}
/* افکت درخشش هنگام تایپ */
.nx-composer__wrap:focus-within { 
  border-color: var(--nx-primary-2); 
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2); 
  background: rgba(0,0,0,0.5);
}
.nx-composer__input { 
  width: 100%; background: transparent !important; border: 0; padding: 10px 4px; 
  color: var(--nx-text) !important; 
  resize: none; max-height: 120px; font-size: 16px !important; font-family: inherit;
}
.nx-composer__input::placeholder { color: var(--nx-text-3); }

/* SETTINGS & ADMIN */
.nx-view--settings, .nx-view--admin { flex-direction: column; overflow-y: auto; height: 100%; width: 100%; position: absolute; inset: 0; z-index: 30; background: var(--nx-bg); }
.nx-pagehead { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--nx-border); background: var(--nx-surface); position: sticky; top: 0; z-index: 5; }
.nx-settings, .nx-admin { padding: 16px; width: 100%; display: flex; flex-direction: column; gap: 16px; padding-bottom: 40px; }
.nx-card { background: var(--nx-surface); border: 1px solid var(--nx-border); border-radius: 16px; padding: 16px; }
.nx-card__title { margin: 0 0 12px; font-size: 1rem; font-weight: 700; }
.nx-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--nx-border); }
.nx-row:last-child { border-bottom: 0; padding-bottom: 0; }
.nx-muted { color: var(--nx-text-3); font-size: 0.85rem; }
.nx-profile-edit { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 16px; }
.nx-switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.nx-switch input { display: none; }
.nx-switch span { position: absolute; inset: 0; background: var(--nx-border-strong); border-radius: 999px; transition: 0.3s; }
.nx-switch span::before { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: 0.3s; }
.nx-switch input:checked + span { background: var(--nx-grad-btn); }
.nx-switch input:checked + span::before { transform: translateX(-22px); }

/* MODALS */
.nx-modal { position: fixed; inset: 0; z-index: 800; display: flex; align-items: center; justify-content: center; padding: 16px; }
.nx-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); }
.nx-modal__panel { position: relative; width: 100%; max-width: 500px; max-height: 90dvh; overflow-y: auto; background: var(--nx-surface-solid); border: 1px solid var(--nx-border-strong); border-radius: 20px; }
.nx-modal__head { display: flex; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--nx-border); position: sticky; top: 0; background: var(--nx-surface-solid); z-index: 10; }
.nx-modal__body { padding: 16px; }

.nx-toasts { position: fixed; top: 16px; left: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.nx-toast { padding: 12px 16px; background: var(--nx-surface-solid); border-right: 3px solid var(--nx-primary); border-radius: 10px; box-shadow: var(--nx-shadow); pointer-events: auto; font-size: 0.9rem; }
.nx-toast.is-error { border-color: var(--nx-danger); }
.nx-toast.is-success { border-color: var(--nx-success); }

.nx-mobile-only { display: inline-flex; }

@media (min-width: 901px) {
  .nx-mobile-only { display: none !important; }
  .nx-view--chat { flex-direction: row; }
  .nx-sidebar { width: 340px; border-left: 1px solid var(--nx-border); border-bottom: none; }
  .nx-sidebar__head { justify-content: space-between; padding: 16px 20px; }
  .nx-sidebar__foot { padding-bottom: 16px; }
  .nx-chatpanel { display: flex !important; position: relative; inset: auto; }
  .nx-view--chat.is-chat-open .nx-chatpanel { display: flex !important; }
  .nx-view--settings, .nx-view--admin { position: relative; inset: auto; max-width: 800px; margin: 0 auto; border-left: 1px solid var(--nx-border); border-right: 1px solid var(--nx-border); }
  .nx-settings, .nx-admin { padding: 24px; }
  .nx-msg { max-width: 70%; }
  .nx-modal { padding: 40px; }
  .nx-toasts { max-width: 350px; right: auto; }
}

@keyframes nxFadeOut { to { opacity: 0; visibility: hidden; } }
@keyframes nxOrbFloat { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(30px, -30px); } }
@keyframes nxBounce { 0%, 100% { transform: scale(0.7); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }