/* ============================================================
   تسکا — ویجت ایجنت هوشمند (شناور، راست‌چین، پرمیوم)
   ============================================================ */
#aiFab {
  position: fixed; bottom: 22px; right: 22px; z-index: 9990;
  width: 60px; height: 60px; border: none; border-radius: 50%; cursor: pointer;
  background: linear-gradient(135deg, #141c42 0%, #3b2a7a 55%, #0aa45f 130%);
  color: #fff; font-size: 26px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 32px rgba(20, 28, 66, .45), 0 0 0 2px rgba(232, 196, 106, .55);
  transition: transform .25s ease, box-shadow .25s ease;
}
#aiFab:hover { transform: scale(1.08) rotate(-4deg); box-shadow: 0 16px 38px rgba(20, 28, 66, .55), 0 0 0 3px rgba(232, 196, 106, .8); }
#aiFab::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(232, 196, 106, .5); animation: aiPulse 2.4s ease-out infinite; pointer-events: none;
}
@keyframes aiPulse { 0% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
#aiFab .ai-dot {
  position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #22d07a; border: 2px solid #fff;
}

#aiPanel {
  position: fixed; bottom: 94px; right: 22px; z-index: 9991;
  width: 368px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 130px);
  display: flex; flex-direction: column; overflow: hidden;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px);
  border-radius: 20px; border: 1px solid rgba(20, 28, 66, .12);
  box-shadow: 0 24px 70px rgba(10, 15, 40, .35);
  transform: translateY(24px) scale(.97); opacity: 0; pointer-events: none;
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.15), opacity .25s ease;
  font-family: inherit; direction: rtl; text-align: right;
}
#aiPanel.open { transform: none; opacity: 1; pointer-events: auto; }
.ai-head {
  background: linear-gradient(135deg, #141c42, #2a1f5c); color: #fff;
  padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
.ai-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 42px;
  background: linear-gradient(135deg, #e8c46a, #f5e2ac); color: #141c42;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.ai-head b { display: block; font-size: 14.5px; }
.ai-head small { display: block; font-size: 11.5px; opacity: .75; }
.ai-close { margin-right: auto; background: rgba(255,255,255,.14); color: #fff; border: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 15px; }
.ai-close:hover { background: rgba(255,255,255,.3); }

#aiMsgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(180deg, #f4f6fb, #eef1f7); }
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 2; white-space: pre-wrap; word-break: break-word; }
.ai-msg.bot { align-self: flex-start; background: #fff; color: #1c2440; border: 1px solid #e2e8f2; border-bottom-right-radius: 4px; box-shadow: 0 3px 10px rgba(20,28,66,.07); }
.ai-msg.user { align-self: flex-end; background: linear-gradient(135deg, #1c2a5e, #3b2a7a); color: #fff; border-bottom-left-radius: 4px; }
.ai-msg.typing { display: flex; gap: 5px; padding: 14px 16px; }
.ai-msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: #8b93ad; animation: aiBlink 1.1s infinite; }
.ai-msg.typing i:nth-child(2) { animation-delay: .2s; } .ai-msg.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

#aiChips { display: flex; gap: 8px; padding: 10px 12px 4px; overflow-x: auto; background: #eef1f7; }
#aiChips button {
  flex: 0 0 auto; font-family: inherit; font-size: 12px; cursor: pointer;
  border: 1px solid #c9d3e8; background: #fff; color: #2a3560;
  padding: 7px 12px; border-radius: 20px; transition: all .2s;
}
#aiChips button:hover { background: #141c42; color: #e8c46a; border-color: #141c42; }

.ai-input { display: flex; gap: 8px; padding: 10px 12px 14px; background: #eef1f7; }
.ai-input input {
  flex: 1; font-family: inherit; font-size: 13.5px; padding: 11px 14px;
  border: 1px solid #c9d3e8; border-radius: 14px; outline: none; background: #fff; min-width: 0;
}
.ai-input input:focus { border-color: #3b2a7a; box-shadow: 0 0 0 3px rgba(59, 42, 122, .12); }
.ai-input button {
  flex: 0 0 46px; border: none; border-radius: 14px; cursor: pointer; font-size: 18px;
  background: linear-gradient(135deg, #0aa45f, #067a46); color: #fff; transition: transform .2s;
}
.ai-input button:hover { transform: scale(1.06); }
.ai-input button:disabled { opacity: .5; cursor: default; transform: none; }

@media (max-width: 480px) {
  #aiFab { bottom: 86px; right: 14px; width: 54px; height: 54px; }
  #aiPanel { bottom: 150px; right: 10px; left: 10px; width: auto; height: 62vh; }
}
