/* دکمه و پنل پیام شناور — پایین چپ */
.chat-widget {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 9990;
  font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}

.chat-widget__fab {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(0);
  pointer-events: none;
  transition:
    width 0.45s ease,
    height 0.45s ease,
    opacity 0.45s ease,
    box-shadow 0.45s ease,
    background 0.2s,
    transform 0.2s;
}

/* ورود جلب‌توجه — ۳ ثانیه بعد از لود */
.chat-widget.is-intro .chat-widget__fab {
  visibility: visible;
  pointer-events: auto;
  animation: chat-fab-enter 1s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

@keyframes chat-fab-enter {
  0% {
    opacity: 0;
    transform: scale(0) translateY(1.25rem);
    box-shadow: 0 0 0 rgba(37, 99, 235, 0);
  }
  55% {
    opacity: 1;
    transform: scale(1.12) translateY(0);
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.55);
  }
  75% {
    transform: scale(0.96);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.45);
  }
}

/* بعد از ورود همیشه قابل مشاهده بماند */
.chat-widget.is-visible .chat-widget__fab {
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
}

/* حالت آرام — کوچک‌تر و کم‌رنگ‌تر */
.chat-widget.is-subtle .chat-widget__fab {
  width: 3rem;
  height: 3rem;
  opacity: 0.72;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.22);
  animation: none;
}

.chat-widget.is-subtle .chat-widget__fab svg {
  width: 1.4rem;
  height: 1.4rem;
}

/* یادآوری ملایم هر ۱ دقیقه */
.chat-widget.is-subtle.is-nudge .chat-widget__fab {
  animation: chat-fab-nudge 0.65s ease;
}

@keyframes chat-fab-nudge {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.72;
  }
  45% {
    transform: scale(1.07);
    opacity: 0.88;
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.38);
  }
}

.chat-widget__fab:hover,
.chat-widget__fab:focus-visible {
  opacity: 1 !important;
  background: #1d4ed8;
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.5);
}

.chat-widget.is-subtle .chat-widget__fab:hover,
.chat-widget.is-subtle .chat-widget__fab:focus-visible {
  width: 3.15rem;
  height: 3.15rem;
}

.chat-widget__fab:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget.is-visible .chat-widget__fab,
  .chat-widget.is-subtle .chat-widget__fab {
    opacity: 0.85;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
    width: 3rem;
    height: 3rem;
    animation: none !important;
  }
}

.chat-widget__fab svg {
  width: 1.65rem;
  height: 1.65rem;
}

.chat-widget.is-subtle .chat-widget__panel {
  bottom: calc(3rem + 0.75rem);
}

.chat-widget__panel {
  position: absolute;
  left: 0;
  bottom: calc(3.5rem + 0.75rem);
  width: min(22rem, calc(100vw - 2.5rem));
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.chat-widget.is-open .chat-widget__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-widget__head {
  background: #2563eb;
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-widget__head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.chat-widget__close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: 6px;
  opacity: 0.9;
}

.chat-widget__close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.chat-widget__body {
  padding: 1rem;
}

.chat-widget__body label {
  display: block;
  font-size: 0.85rem;
  color: #475569;
  margin-bottom: 0.25rem;
}

.chat-widget__body label .req {
  color: #dc2626;
}

.chat-widget__body input,
.chat-widget__body textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  margin-bottom: 0.75rem;
  direction: rtl;
  text-align: right;
}

.chat-widget__body textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.chat-widget__body input:focus,
.chat-widget__body textarea:focus {
  outline: 2px solid #93c5fd;
  border-color: #2563eb;
}

.chat-widget__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.chat-widget__submit {
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  background: #2563eb;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-widget__submit:hover:not(:disabled) {
  background: #1d4ed8;
}

.chat-widget__submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.chat-widget__feedback {
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  display: none;
}

.chat-widget__feedback.is-error {
  display: block;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.chat-widget__feedback.is-success {
  display: block;
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

@media (max-width: 480px) {
  .chat-widget {
    left: 0.75rem;
    bottom: 0.75rem;
  }
}
