@font-face {
  font-family: "Vazirmatn";
  src: url("https://rexsun.ir/wp-content/uploads/2026/04/Vazirmatnwght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

.rex-support-widget,
.rex-widget-preview-page {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --brand-navy: #0f1e36;
  --brand-navy-light: #1e293b;
  --brand-navy-soft: #f1f5f9;
  --brand-red: #d7192d;
  --brand-red-hover: #b91424;
  --brand-red-soft: #fff1f2;
  --brand-red-gradient: linear-gradient(135deg, #d7192d 0%, #b91424 100%);
  --bg-canvas: #f8fafc;
  --surface-main: #fff;
  --surface-soft: #f1f5f9;
  --surface-hover: #e2e8f0;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f1e36;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #fff;
  --status-success: #0f9f62;
  --status-success-soft: #eaf8f1;
  --status-warning: #c97708;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 9999px;
  --shadow-xs: 0 1px 2px rgba(15, 30, 54, .05);
  --shadow-sm: 0 2px 8px rgba(15, 30, 54, .08);
  --shadow-md: 0 8px 24px -4px rgba(15, 30, 54, .12);
  --shadow-lg: 0 16px 36px -6px rgba(15, 30, 54, .18);
  --shadow-xl: 0 24px 50px -8px rgba(15, 30, 54, .28);
  --widget-width: 380px;
  --widget-height: 600px;
}

.rex-widget-preview-page { min-height: 100vh; margin: 0; overflow-x: clip; background: #eef2f6; }
.rex-support-widget button:focus-visible, .rex-support-widget input:focus-visible, .rex-support-widget a:focus-visible, .rex-support-widget [tabindex]:focus-visible { outline: 3px solid rgba(215, 25, 45, .26); outline-offset: 2px; }
.rex-support-widget .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Local preview only; the production bundle mounts only .rex-support-widget. */
.preview-canvas { position: fixed; inset: 0; overflow: hidden; padding: clamp(32px, 6vw, 90px); background: radial-gradient(circle at 17% 20%, rgba(215, 25, 45, .08), transparent 23%), linear-gradient(135deg, #f9fbfd, #e9eff4); }
.preview-canvas::before { content: ""; position: absolute; inset: 0; opacity: .32; background-image: linear-gradient(rgba(15, 30, 54, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(15, 30, 54, .06) 1px, transparent 1px); background-size: 42px 42px; }
.preview-brand { position: relative; display: grid; width: fit-content; color: var(--brand-navy); }
.preview-brand span { font: 900 clamp(34px, 6vw, 82px)/1 "Segoe UI", sans-serif; letter-spacing: .08em; }
.preview-brand small { margin-top: 10px; color: var(--text-secondary); font-size: clamp(11px, 1.4vw, 16px); }
.preview-line { position: relative; width: min(38vw, 480px); height: 12px; margin-top: 28px; border-radius: 20px; background: rgba(15, 30, 54, .1); }
.preview-line-wide { width: min(52vw, 680px); margin-top: 70px; }
.preview-modules { position: relative; display: flex; gap: 18px; margin-top: 50px; }
.preview-modules i { width: min(18vw, 220px); aspect-ratio: 1.5; border: 1px solid rgba(15, 30, 54, .08); border-radius: 18px; background: rgba(255, 255, 255, .58); }
.preview-label { position: absolute; right: 34px; bottom: 28px; color: rgba(15, 30, 54, .28); font: 800 10px/1 "Segoe UI", sans-serif; letter-spacing: .16em; }

.rex-support-widget { position: fixed; z-index: 2147483000; inset: 0; direction: rtl; color: var(--text-main); font: 13.5px/1.6 "Vazirmatn", Tahoma, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; pointer-events: none; }
.rex-support-widget *, .rex-support-widget *::before, .rex-support-widget *::after { box-sizing: border-box; }
.rex-support-widget button, .rex-support-widget input { font: inherit; }
.rex-support-widget button { cursor: pointer; }
.rex-support-widget button > span {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  color: #0f1e36 !important;
  -webkit-text-fill-color: #0f1e36 !important;
  font: inherit !important;
}
.rex-support-widget svg { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rex-support-widget ::-webkit-scrollbar { width: 4px; height: 4px; }
.rex-support-widget ::-webkit-scrollbar-track { background: transparent; }
.rex-support-widget ::-webkit-scrollbar-thumb { border-radius: var(--radius-pill); background: var(--border-strong); }

.rex-widget-launcher-wrap { position: fixed; bottom: max(20px, var(--sab)); left: max(20px, var(--sal)); z-index: 9999; display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.rex-launcher-callout-pill { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-main); color: var(--brand-navy); box-shadow: var(--shadow-md); font-size: 11.5px; font-weight: 700; user-select: none; animation: floatBadge 3.5s infinite ease-in-out; transition: border-color .2s ease, transform .2s ease; }
.rex-launcher-callout-pill:hover { border-color: var(--brand-red); transform: scale(1.03); }
.neutral-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-main); color: var(--text-secondary); font-size: 10px; font-weight: 600; white-space: nowrap; }
.status-mini-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-success); }
.rex-launcher-btn { position: relative; width: 54px; height: 54px; flex: 0 0 54px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; border-radius: 50%; background: var(--brand-red-gradient); color: #fff; box-shadow: 0 6px 20px rgba(215, 25, 45, .4); transition: transform .25s cubic-bezier(.16, 1, .3, 1), box-shadow .25s ease; }
.rex-launcher-btn svg { width: 23px; height: 23px; }
.rex-launcher-btn:hover { transform: scale(1.08); box-shadow: 0 10px 25px rgba(215, 25, 45, .55); }
.rex-launcher-btn:active { transform: scale(.94); }
.launcher-close-icon { display: none !important; }
.rex-support-widget.chat-open .launcher-open-icon { display: none; }
.rex-support-widget.chat-open .launcher-close-icon { display: block !important; }
.rex-support-widget.chat-open .rex-launcher-callout-pill { opacity: 0; pointer-events: none; }
.rex-launcher-online-dot { position: absolute; top: -1px; right: -1px; width: 13px; height: 13px; border: 2px solid #fff; border-radius: 50%; background: var(--status-success); animation: pulseGlow 1.8s infinite; }

.rex-chat-popup { position: fixed; bottom: max(86px, calc(var(--sab) + 74px)); left: max(20px, var(--sal)); width: var(--widget-width); height: var(--widget-height); max-width: calc(100vw - 32px); max-height: calc(100dvh - 106px); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); background: var(--surface-main); box-shadow: var(--shadow-xl); opacity: 0; pointer-events: none; transform: scale(.88) translateY(20px); transform-origin: bottom left; transition: opacity .3s cubic-bezier(.16, 1, .3, 1), transform .3s cubic-bezier(.16, 1, .3, 1); }
.rex-chat-popup.open { opacity: 1; pointer-events: auto; transform: scale(1) translateY(0); }

.history-drawer-menu { position: absolute; z-index: 20; inset: 0 auto 0 0; width: 260px; display: flex; flex-direction: column; padding: 14px; border-right: 1px solid var(--border-subtle); background: var(--surface-main); box-shadow: 6px 0 20px rgba(15, 30, 54, .15); transform: translateX(-100%); transition: transform .25s cubic-bezier(.16, 1, .3, 1); }
.history-drawer-menu.open { transform: translateX(0); }
.history-drawer-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border-subtle); }
.history-drawer-header strong { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.history-drawer-header strong svg { width: 18px; height: 18px; color: var(--brand-red); }
.btn-close-drawer { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: var(--surface-soft); color: var(--text-secondary); transition: background .15s ease, color .15s ease; }
.btn-close-drawer:hover { background: var(--brand-red-soft); color: var(--brand-red); }
.drawer-backdrop { position: absolute; z-index: 15; inset: 0; display: none; border: 0; background: rgba(15, 30, 54, .35); backdrop-filter: blur(2px); }
.drawer-backdrop.active { display: block; }
.btn-new-session { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 12px; padding: 9px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-soft); color: var(--brand-navy); font-size: 12px; font-weight: 700; transition: all .15s ease; }
.btn-new-session:hover { border-color: var(--brand-red); background: var(--brand-red-soft); color: var(--brand-red); }
.sessions-scroll-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.session-card { min-height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--brand-red-soft); color: var(--brand-red); font-size: 11.5px; font-weight: 700; }
.session-card-title { display: flex; align-items: center; gap: 6px; }
.session-card svg { width: 16px; height: 16px; }
.drawer-privacy-note { margin: 0; padding: 11px; border-radius: var(--radius-sm); background: var(--surface-soft); color: var(--text-secondary); font-size: 10.5px; line-height: 1.8; }

.popup-header { flex: 0 0 auto; min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, .1); background: var(--brand-navy); color: #fff; }
.header-profile-wrap { min-width: 0; display: flex; align-items: center; gap: 10px; }
.avatar-badge { position: relative; width: 36px; height: 36px; flex: 0 0 36px; display: flex; align-items: center; justify-content: center; border: 1.5px solid rgba(255, 255, 255, .2); border-radius: 11px; background: var(--brand-red-gradient); }
.avatar-badge img { width: 21px; height: 21px; object-fit: contain; }
.avatar-dot { position: absolute; bottom: -2px; left: -2px; width: 9px; height: 9px; border: 1.5px solid var(--brand-navy); border-radius: 50%; background: var(--status-success); }
.header-info-title { min-width: 0; }
.header-info-title h2 { display: flex; align-items: center; gap: 5px; margin: 0; color: #fff; font-size: 13.5px; font-weight: 800; white-space: nowrap; }
.header-info-title h2 span { overflow: hidden; text-overflow: ellipsis; }
.header-info-title p { margin: 1px 0 0; overflow: hidden; color: #94a3b8; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.verified-icon { width: 16px !important; height: 16px !important; flex: 0 0 16px; color: #6ee7b7; }
.header-ctrl-btns { display: flex; align-items: center; gap: 4px; }
.btn-header-ctrl { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); color: #e2e8f0; transition: all .15s ease; }
.btn-header-ctrl svg { width: 15px; height: 15px; }
.btn-header-ctrl:hover { background: var(--brand-red); color: #fff; }

.popup-status-bar { flex: 0 0 auto; min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 14px; border-bottom: 1px solid var(--border-subtle); background: var(--surface-soft); color: var(--text-secondary); font-size: 10.5px; }
.status-pills { min-width: 0; display: flex; gap: 4px; }
.status-pills .neutral-pill:first-child svg { width: 13px; height: 13px; color: var(--brand-red); }
.brand-caption { white-space: nowrap; }

.popup-messages-area { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px; padding: 14px; overflow-x: hidden; overflow-y: auto; background: var(--bg-canvas); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.msg-item { max-width: 86%; display: flex; align-items: flex-start; gap: 8px; animation: fadeIn .2s ease-out; }
.msg-item.sender-user { align-self: flex-start; flex-direction: row; }
.msg-item.sender-bot { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar-icon { width: 28px; height: 28px; flex: 0 0 28px; display: flex; align-items: center; justify-content: center; border-radius: 9px; font-size: 10px; font-weight: 800; }
.sender-user .msg-avatar-icon { background: var(--brand-red-gradient); color: #fff; }
.sender-bot .msg-avatar-icon { border: 1px solid rgba(255, 255, 255, .2); background: var(--brand-navy); }
.sender-bot .msg-avatar-icon img { width: 16px; height: 16px; object-fit: contain; }
.msg-body-wrapper { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.msg-text-bubble { min-width: 0; padding: 10px 14px; border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); font-size: 12.5px; line-height: 1.75; overflow-wrap: anywhere; white-space: pre-wrap; }
.sender-user .msg-text-bubble { border-top-right-radius: 3px; background: var(--brand-navy); color: #fff; }
.sender-bot .msg-text-bubble { border: 1px solid var(--border-subtle); border-top-left-radius: 3px; background: var(--surface-main); color: var(--text-main); }
.msg-time-stamp { margin: 0 4px; color: var(--text-muted); font-size: 9.5px; }
.sender-user .msg-time-stamp { align-self: flex-start; }
.sender-bot .msg-time-stamp { align-self: flex-end; }
.technical-card-preview { margin-top: 7px; padding: 8px 10px; border: 1px solid var(--border-subtle); border-right: 3px solid var(--brand-red); border-radius: var(--radius-sm); background: var(--surface-soft); font-size: 11px; white-space: normal; }
.technical-card-preview strong { display: block; margin-bottom: 3px; color: var(--brand-navy); }
.technical-card-preview ul { margin: 0; padding-right: 17px; color: var(--text-secondary); }
.technical-card-preview a { display: flex; align-items: center; gap: 5px; min-height: 30px; color: #075985; font-weight: 700; text-decoration: none; }
.technical-card-preview a:hover { color: var(--brand-red); text-decoration: underline; }
.technical-card-preview.warning { border-right-color: var(--status-warning); background: #fffaf0; }
.handoff-action { width: 100%; min-height: 40px !important; justify-content: center; margin-top: 7px; border-radius: var(--radius-sm); background: var(--brand-red); color: #fff !important; text-decoration: none !important; }
.handoff-action:hover { background: var(--brand-red-hover); }
.copy-summary-button, .feedback-button, .retry-button { min-height: 36px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; color: var(--brand-navy); font-size: 10.5px; font-weight: 700; }
.copy-summary-button { width: 100%; margin-top: 6px; }
.feedback-row { display: flex; align-items: center; gap: 5px; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border-subtle); color: var(--text-muted); font-size: 9.5px; white-space: normal; }
.feedback-row span { margin-left: auto; }
.feedback-button { min-width: 42px; padding: 0 8px; }
.feedback-button:disabled { opacity: .5; cursor: default; }
.typing-pill { width: fit-content; display: flex; align-items: center; gap: 3px; padding: 8px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-main); }
.typing-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--brand-red); animation: bounceDot 1.4s infinite ease-in-out; }
.typing-dot:nth-child(1) { animation-delay: -.32s; }
.typing-dot:nth-child(2) { animation-delay: -.16s; }
.inline-error { max-width: 100%; align-self: stretch; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid #fecdd3; border-radius: var(--radius-md); background: var(--brand-red-soft); color: #9f1239; font-size: 10.5px; }
.inline-error[hidden] { display: none; }
.retry-button { min-width: 72px; padding: 0 9px; color: var(--brand-red); }

.privacy-inline { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 5px 12px; border-top: 1px solid var(--border-subtle); background: #fff; color: var(--text-secondary); font-size: 9.5px; line-height: 1.5; text-align: center; }
.privacy-inline svg { width: 13px; height: 13px; flex: 0 0 13px; color: var(--status-success); }
.quick-actions-grid { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--border-subtle); background: var(--surface-main); }
.quick-action-card { min-width: 0; min-height: 36px; display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-soft); color: var(--brand-navy); font-size: 11px; font-weight: 600; text-align: right; transition: all .15s ease; }
.quick-action-card svg { width: 14px; height: 14px; flex: 0 0 14px; color: var(--brand-red); }
.quick-action-card span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-action-card:hover { border-color: var(--brand-red); background: var(--brand-red-soft); color: var(--brand-red); transform: translateY(-1px); }

.popup-composer-box { flex: 0 0 auto; padding: 10px 14px; border-top: 1px solid var(--border-subtle); background: var(--surface-main); }
.composer-form-row { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-soft); transition: all .2s ease; }
.composer-form-row:focus-within { border-color: var(--brand-red); background: #fff; box-shadow: 0 0 0 3px rgba(215, 25, 45, .1); }
.composer-input-field { min-width: 0; height: 36px; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text-main); font-size: 12.5px; }
.composer-input-field::placeholder { color: var(--text-muted); }
.btn-action-tool { width: 36px; height: 36px; flex: 0 0 36px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; background: transparent; color: var(--text-secondary); transition: color .15s ease; }
.btn-action-tool svg { width: 17px; height: 17px; }
.btn-action-tool:hover { color: var(--brand-red); }
.btn-send-trigger { width: 36px; height: 36px; flex: 0 0 36px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: var(--brand-red-gradient); color: #fff; transition: all .2s ease; }
.btn-send-trigger svg { width: 16px; height: 16px; }
.btn-send-trigger:hover { box-shadow: 0 3px 10px rgba(215, 25, 45, .35); }
.btn-send-trigger:active { transform: scale(.95); }
.btn-send-trigger:disabled, .composer-input-field:disabled { cursor: not-allowed; opacity: .55; }
.popup-footer-tag { flex: 0 0 auto; padding: 5px 14px; border-top: 1px solid var(--border-subtle); background: var(--surface-main); color: var(--text-muted); font-size: 10px; text-align: center; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounceDot { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes pulseGlow { 0% { transform: scale(.95); box-shadow: 0 0 0 0 rgba(15, 159, 98, .7); } 70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(15, 159, 98, 0); } 100% { transform: scale(.95); box-shadow: 0 0 0 0 rgba(15, 159, 98, 0); } }
@keyframes floatBadge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

@media (max-width: 640px) {
  html.rex-chat-open, html.rex-chat-open body { overflow: hidden; }
  .rex-launcher-callout-pill { display: none; }
  .rex-chat-popup { inset: 0; width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; padding-top: var(--sat); padding-bottom: var(--sab); border: 0; border-radius: 0; transform-origin: bottom center; }
  .rex-support-widget.chat-open .rex-widget-launcher-wrap { display: none; }
  .msg-item { max-width: 90%; }
  .quick-actions-grid { padding: 8px 10px; }
  .btn-header-ctrl, .btn-close-drawer, .btn-action-tool, .btn-send-trigger { width: 44px; height: 44px; flex-basis: 44px; }
  .quick-action-card { min-height: 44px; }
}
@media (max-width: 350px) { .brand-caption, .status-pills .neutral-pill:last-child { display: none; } .quick-action-card { padding-inline: 7px; font-size: 10.5px; } .popup-header { padding-inline: 10px; } }
@media (prefers-reduced-motion: reduce) { .rex-support-widget *, .rex-support-widget *::before, .rex-support-widget *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
