/* دستیار هوش مصنوعی آپ‌سئو — چت مرکزی | copilot.css */
html.up-copilot-on { --cp-w: 340px; }
@media (max-width: 1279px) { html.up-copilot-on { --cp-w: 310px; } }
#upseoCopilot, #upseoCopilot * { box-sizing: border-box; }
#upseoCopilot {
  --cp-1: #4f46e5; --cp-2: #6d5dfc; --cp-3: #8b7cff; --cp-ink: #1e1b4b; --cp-soft: #eeecff; --cp-line: #ddd9ff;
  position: fixed; left: 20px; bottom: 96px; z-index: 2147483000; /* بالای دکمه‌ی چت پشتیبانی که سر جای خودش مانده */
  font-family: 'Vazirmatn', 'IRANSans', Tahoma, sans-serif; direction: rtl; color: var(--cp-ink);
  font-size: 14px; line-height: 1.7;
}
#upseoCopilot button { font-family: inherit; cursor: pointer; }

/* دکمه‌ی شناور */
.cp-launcher {
  width: 58px; height: 58px; border-radius: 50%; border: 0; padding: 0; color: #fff;
  background: linear-gradient(135deg, var(--cp-1), var(--cp-3));
  box-shadow: 0 8px 24px rgba(79, 70, 229, .45); display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease; position: relative;
}
.cp-launcher:hover { transform: translateY(-2px) scale(1.04); }
.cp-launcher svg { width: 28px; height: 28px; }
.cp-launcher .cp-pulse { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 0 rgba(109, 93, 252, .5); animation: cp-pulse 2.8s infinite; pointer-events: none; }
@keyframes cp-pulse { 70% { box-shadow: 0 0 0 16px rgba(109, 93, 252, 0); } 100% { box-shadow: 0 0 0 0 rgba(109, 93, 252, 0); } }
#upseoCopilot.is-open .cp-launcher { display: none; }

/* پنجره */
.cp-window {
  display: none; flex-direction: column; width: 392px; max-width: calc(100vw - 24px);
  height: min(680px, calc(100vh - 40px)); border-radius: 26px; overflow: hidden;
  background: linear-gradient(180deg, #f3f1ff 0%, #ebe8ff 100%);
  box-shadow: 0 24px 60px rgba(49, 46, 129, .35), 0 0 0 1px rgba(255, 255, 255, .6) inset;
  transform-origin: bottom left; animation: cp-pop .22s ease;
}
@keyframes cp-pop { from { opacity: 0; transform: scale(.94) translateY(10px); } to { opacity: 1; transform: none; } }
#upseoCopilot.is-open .cp-window { display: flex; }

.cp-head {
  position: relative; flex: none; color: #fff; text-align: center; padding: 14px 16px 0;
  background: radial-gradient(120% 100% at 50% 0%, #6d5dfc 0%, #4338ca 70%, #3730a3 100%);
  transition: all .25s ease;
}
.cp-head::after { content: ''; display: block; height: 22px; margin: 0 -16px; background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .18)); clip-path: ellipse(75% 100% at 50% 100%); }
.cp-top { display: flex; align-items: center; justify-content: space-between; }
.cp-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; }
.cp-brand i { width: 26px; height: 26px; border-radius: 8px; background: #fff; display: inline-flex; align-items: flex-end; justify-content: center; gap: 3px; padding: 5px 5px 6px; }
.cp-brand i b { display: block; width: 4px; border-radius: 2px; background: var(--cp-1); }
.cp-icon-btn { width: 32px; height: 32px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .16); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.cp-icon-btn:hover { background: rgba(255, 255, 255, .28); }
.cp-icon-btn svg { width: 16px; height: 16px; }
.cp-tools { display: flex; gap: 6px; }
.cp-hero { padding: 6px 0 2px; }
.cp-hero svg.cp-robot { width: 118px; height: 118px; display: block; margin: 0 auto; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .25)); animation: cp-float 4s ease-in-out infinite; }
@keyframes cp-float { 50% { transform: translateY(-6px); } }
.cp-hero h2 { margin: 2px 0 0; font-size: 18px; font-weight: 800; color: #fff; }
.cp-hero p { margin: 0 0 4px; font-size: 13px; opacity: .85; }
.cp-window.is-chat .cp-hero { display: none; }
.cp-window.is-chat .cp-head { padding-bottom: 0; }
.cp-window.is-chat .cp-head::after { height: 10px; }
.cp-ctx-chip { display: none; margin: 8px auto 2px; max-width: 100%; font-size: 11.5px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .18); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-window.is-chat .cp-ctx-chip.has { display: block; }

.cp-body { flex: 1; overflow-y: auto; padding: 14px 14px 6px; scroll-behavior: smooth; }
.cp-body::-webkit-scrollbar { width: 6px; } .cp-body::-webkit-scrollbar-thumb { background: #c9c4ff; border-radius: 6px; }

.cp-bubble-hello { background: #fff; border-radius: 18px; padding: 11px 16px; box-shadow: 0 4px 14px rgba(79, 70, 229, .09); margin-bottom: 12px; }
.cp-bubble-hello b { display: block; font-size: 15px; margin-bottom: 2px; }
.cp-quick { display: flex; flex-direction: column; gap: 8px; }
.cp-quick button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: right; border: 1px solid #fff; background: rgba(255, 255, 255, .85);
  border-radius: 999px; padding: 9px 16px; color: var(--cp-ink); font-weight: 700; font-size: 14px;
  box-shadow: 0 3px 10px rgba(79, 70, 229, .08); transition: all .15s ease;
}
.cp-quick button:hover { transform: translateX(-2px); background: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .16); }
.cp-quick button svg { width: 22px; height: 22px; color: var(--cp-1); flex: none; }
.cp-or { text-align: center; font-weight: 700; margin: 12px 0 2px; font-size: 13.5px; border-top: 1px solid var(--cp-line); padding-top: 12px; }

.cp-msg { display: flex; margin: 0 0 10px; }
.cp-msg .cp-b { max-width: 88%; padding: 9px 13px; border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere; }
.cp-msg.user { justify-content: flex-start; }
.cp-msg.user .cp-b { background: linear-gradient(135deg, var(--cp-1), var(--cp-2)); color: #fff; border-bottom-right-radius: 4px; }
.cp-msg.bot { justify-content: flex-end; }
.cp-msg.bot .cp-b { background: #fff; border-bottom-left-radius: 4px; box-shadow: 0 2px 10px rgba(79, 70, 229, .08); }
.cp-msg.note { justify-content: center; }
.cp-msg.note .cp-b { background: transparent; box-shadow: none; font-size: 11.5px; color: #6b67a8; padding: 0; max-width: 100%; }
.cp-b p { margin: 0 0 6px; } .cp-b p:last-child { margin: 0; }
.cp-b ul { margin: 4px 0; padding: 0 18px 0 0; } .cp-b li { margin: 2px 0; }
.cp-b code { direction: ltr; unicode-bidi: embed; background: #f0eeff; border-radius: 5px; padding: 0 5px; font-size: 12.5px; }
.cp-b a { color: var(--cp-1); font-weight: 700; text-decoration: underline; }
.cp-msg.user .cp-b a { color: #fff; }

.cp-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cp-chip, .cp-act { border: 1px solid var(--cp-line); background: #fff; color: var(--cp-1); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 700; }
.cp-chip:hover, .cp-act:hover { background: var(--cp-soft); }
.cp-act.primary { background: linear-gradient(135deg, var(--cp-1), var(--cp-2)); color: #fff; border-color: transparent; }
.cp-act[disabled] { opacity: .6; cursor: default; }
.cp-list { margin: 6px 0 0; padding: 6px 10px; background: #f6f5ff; border-radius: 10px; font-size: 12.5px; }
.cp-list div { padding: 1px 0; }
.cp-cost { margin-top: 6px; font-size: 11.5px; color: #6b67a8; }
.cp-undo { margin-inline-start: 8px; border: 0; background: transparent; color: var(--cp-1); font-weight: 700; text-decoration: underline; font-size: 12.5px; }

.cp-typing .cp-b { padding: 12px 14px; }
.cp-dots i { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--cp-3); animation: cp-bounce 1.1s infinite; }
.cp-dots i:nth-child(2) { animation-delay: .15s; } .cp-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes cp-bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.cp-foot { flex: none; padding: 8px 14px 12px; background: rgba(255, 255, 255, .35); }
.cp-form { display: flex; align-items: flex-end; gap: 8px; background: #fff; border-radius: 20px; padding: 6px 6px 6px 8px; box-shadow: 0 4px 14px rgba(79, 70, 229, .12); border: 1px solid #fff; }
.cp-form:focus-within { border-color: var(--cp-3); }
.cp-input { flex: 1; border: 0; outline: 0; resize: none; background: transparent; font-family: inherit; font-size: 14px; color: var(--cp-ink); max-height: 110px; min-height: 40px; padding: 8px 10px; line-height: 1.6; }
.cp-input::placeholder { color: #8e8ab8; }
.cp-send { flex: none; width: 44px; height: 44px; border-radius: 14px; border: 0; color: #fff; background: linear-gradient(135deg, var(--cp-1), var(--cp-2)); display: inline-flex; align-items: center; justify-content: center; }
.cp-send:disabled { opacity: .5; cursor: default; }
.cp-send svg { width: 20px; height: 20px; transform: scaleX(-1); }
.cp-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 7px; font-size: 11.5px; color: #6b67a8; }
.cp-meta button { border: 0; background: transparent; color: var(--cp-1); font-weight: 700; font-size: 11.5px; padding: 0; text-decoration: underline; }

@media (max-width: 520px) {
  #upseoCopilot { left: 14px; bottom: 84px; }
  html.up-copilot-nosupport #upseoCopilot { bottom: 14px; }
  #upseoCopilot.is-open { left: 0; bottom: 0; right: 0; top: 0; }
  #upseoCopilot.is-open .cp-window { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; animation: none; }
  .cp-hero svg.cp-robot { width: 110px; height: 110px; }
}
@media (prefers-reduced-motion: reduce) { #upseoCopilot * { animation: none !important; transition: none !important; } }
/* روی ابزارهای تمام‌صفحه (ورد/اکسل) دکمه را بالاتر از نوار پایین می‌گذاریم */
html.up-copilot-nosupport #upseoCopilot { bottom: 20px; }
html.up-copilot-nosupport.up-copilot-tool #upseoCopilot { bottom: 56px; }
@media print { #upseoCopilot { display: none !important; } }

/* ردیف کارهای سریع (در حالت گفتگو، مخصوص ابزارها) */
.cp-qrow { display: none; gap: 6px; overflow-x: auto; padding: 0 0 8px; scrollbar-width: none; }
.cp-qrow::-webkit-scrollbar { display: none; }
.cp-window.is-chat .cp-qrow.has { display: flex; }
.cp-qrow button { flex: none; border: 1px solid var(--cp-line); background: #fff; color: var(--cp-1); border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.cp-qrow button:hover { background: var(--cp-soft); }
a.cp-act { text-decoration: none; display: inline-block; }

/* ==========================================================================
   حالت سایدبار (دسکتاپ ≥۱۰۲۴px): ثابت در سمت چپ، محتوای صفحه کنار می‌رود.
   موبایل/تبلت یا وقتی کاربر جمعش کند: دکمه‌ی شناور مثل قبل.
   ========================================================================== */
html.up-copilot-docked { margin-left: var(--cp-w); }
html.up-copilot-docked #geminiChatWidget { left: calc(var(--cp-w) + 24px) !important; } /* چت پشتیبانی کنار سایدبار، همان‌جا که بود */
#upseoCopilot.is-docked { left: 0; top: 0; bottom: 0; width: var(--cp-w); }
#upseoCopilot.is-docked .cp-launcher { display: none; }
#upseoCopilot.is-docked .cp-window { display: flex; width: 100%; max-width: none; height: 100%; border-radius: 0; animation: none; box-shadow: 6px 0 28px rgba(49, 46, 129, .22); }
#upseoCopilot.is-docked .cp-hero svg.cp-robot { width: 104px; height: 104px; }

/* چت پشتیبانی باز است: دکمه‌ی شناور دستیار (غیر از حالت سایدبار) پنهان می‌شود تا روی دکمه‌ی ارسال نیفتد */
html.up-support-open #upseoCopilot:not(.is-docked):not(.is-open) { display: none; }
