/* آرین بات — ویجت شناور + چت محلی */
.abw-root {
  --abw-primary: #0a3d62;
  --abw-primary-dark: #072a47;
  --abw-primary-mid: #0c4a74;
  --abw-gold: #f7b731;
  --abw-gold-soft: #fde68a;
  --abw-blue: #1e90ff;
  --abw-bg: #eef3f8;
  --abw-surface: #ffffff;
  --abw-text: #0a3d62;
  --abw-muted: #5a6b7d;
  --abw-shadow: 0 22px 60px rgba(7, 42, 71, 0.32);
  --abw-radius: 24px;
  position: fixed;
  z-index: 99990;
  left: 18px;
  bottom: 18px;
  font-family: Sans, Tahoma, sans-serif;
  direction: rtl;
}

.abw-launcher {
  position: relative;
  width: 92px;
  height: 102px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.abw-launcher:hover { transform: scale(1.04); }
.abw-launcher:focus-visible {
  outline: 3px solid var(--abw-gold);
  outline-offset: 4px;
  border-radius: 24px;
}

.abw-ring {
  position: absolute;
  inset: 6px 2px -2px;
  border-radius: 50%;
  border: 2px solid rgba(247, 183, 49, 0.45);
  animation: abw-ring 2.8s ease-out infinite;
  pointer-events: none;
  z-index: -1;
}

.abw-bot {
  width: 86px;
  height: 96px;
  display: block;
  margin: 0 auto;
  animation: abw-float 3.2s ease-in-out infinite;
  filter: drop-shadow(0 12px 20px rgba(10, 61, 98, 0.32));
  transform-origin: center bottom;
}

.abw-bot .ab-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: abw-blink 4.8s infinite;
}

.abw-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  min-width: 180px;
  max-width: 240px;
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
  color: var(--abw-primary);
  border: 1px solid rgba(10, 61, 98, 0.1);
  border-radius: 18px 18px 18px 6px;
  padding: 0.75rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.55;
  box-shadow: var(--abw-shadow);
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.abw-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 24px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid rgba(10, 61, 98, 0.1);
  border-bottom: 1px solid rgba(10, 61, 98, 0.1);
  transform: rotate(45deg);
}

.abw-bubble.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.abw-pulse {
  position: absolute;
  inset: 14px 10px 6px;
  border-radius: 50%;
  background: rgba(30, 144, 255, 0.2);
  animation: abw-pulse 2.4s ease-out infinite;
  z-index: -1;
  pointer-events: none;
}

.abw-panel {
  position: fixed;
  inset: 12px;
  max-width: 420px;
  margin: 0;
  left: 12px;
  right: auto;
  width: min(420px, calc(100vw - 24px));
  height: min(700px, calc(100vh - 24px));
  background: var(--abw-surface);
  border-radius: var(--abw-radius);
  overflow: hidden;
  box-shadow: var(--abw-shadow);
  border: 1px solid rgba(10, 61, 98, 0.08);
  display: none;
  flex-direction: column;
  animation: abw-panel-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 99991;
}

.abw-root.is-open .abw-panel { display: flex; }
.abw-root.is-open .abw-bubble { display: none; }
.abw-root.is-open .abw-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

.abw-panel-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 1.05rem;
  background:
    radial-gradient(circle at 90% 20%, rgba(247, 183, 49, 0.28), transparent 42%),
    linear-gradient(145deg, var(--abw-primary-mid), var(--abw-primary-dark));
  color: #fff;
  flex-shrink: 0;
}

.abw-panel-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--abw-gold), transparent);
}

.abw-panel-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.abw-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.abw-avatar img {
  width: 34px;
  height: 38px;
  object-fit: contain;
}

.abw-online {
  position: absolute;
  left: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--abw-primary-dark);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.abw-panel-title strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.abw-sub {
  display: block;
  font-size: 0.78rem;
  opacity: 0.88;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.abw-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.abw-close:hover {
  background: var(--abw-gold);
  color: var(--abw-primary-dark);
  transform: rotate(90deg);
}

.abw-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0.9rem;
  background:
    radial-gradient(circle at 12% 8%, rgba(247, 183, 49, 0.14), transparent 36%),
    radial-gradient(circle at 88% 0%, rgba(30, 144, 255, 0.1), transparent 34%),
    linear-gradient(180deg, #f7fafc 0%, var(--abw-bg) 100%);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

.abw-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  animation: abw-msg-in 0.28s ease;
}

.abw-msg--bot { justify-content: flex-start; }
.abw-msg--user { justify-content: flex-end; }

.abw-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  flex-shrink: 0;
  background:
    url("../img/aryan-bot-mascot.svg") center / 70% no-repeat,
    linear-gradient(145deg, #0c4a74, #072a47);
  box-shadow: 0 4px 10px rgba(10, 61, 98, 0.18);
}

.abw-msg-bubble {
  max-width: 88%;
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  line-height: 1.75;
  font-size: 0.92rem;
  color: var(--abw-text);
  box-shadow: 0 6px 18px rgba(10, 61, 98, 0.07);
}

.abw-msg--bot .abw-msg-bubble {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(10, 61, 98, 0.07);
  border-bottom-right-radius: 6px;
  backdrop-filter: blur(6px);
}

.abw-msg--user .abw-msg-bubble {
  background: linear-gradient(145deg, var(--abw-primary-mid), var(--abw-primary-dark));
  color: #fff;
  border-bottom-left-radius: 6px;
}

.abw-msg-bubble p { margin: 0 0 0.55rem; }
.abw-msg-bubble p:last-child { margin-bottom: 0; }

.abw-msg-bubble a {
  color: #0b6bcb;
  font-weight: 700;
  text-decoration: none;
}
.abw-msg--user .abw-msg-bubble a { color: #fff; text-decoration: underline; }

.abw-inline-link {
  display: inline-flex;
  align-items: center;
  margin-top: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(10, 61, 98, 0.1), rgba(247, 183, 49, 0.18));
  color: var(--abw-primary) !important;
  border: 1px solid rgba(10, 61, 98, 0.1);
  transition: transform 0.15s ease, background 0.15s ease;
}
.abw-inline-link:hover {
  transform: translateY(-1px);
  background: linear-gradient(145deg, var(--abw-primary), var(--abw-primary-dark));
  color: #fff !important;
}

.abw-list {
  margin: 0.4rem 0 0.7rem;
  padding-right: 1.1rem;
}

.abw-shop-card {
  display: block;
  margin: 0.55rem 0;
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f7fafc);
  border: 1px solid rgba(10, 61, 98, 0.08);
  box-shadow: 0 4px 12px rgba(10, 61, 98, 0.04);
}

.abw-shop-card strong { display: block; margin-bottom: 0.15rem; }
.abw-shop-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--abw-muted);
  margin-bottom: 0.35rem;
}
.abw-shop-card p {
  margin: 0.2rem 0;
  font-size: 0.86rem;
  color: #334155;
}
.abw-shop-links {
  margin-top: 0.45rem;
  font-size: 0.84rem;
}

.abw-escalate {
  margin-top: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(247, 183, 49, 0.22), rgba(10, 61, 98, 0.06));
  border: 1px solid rgba(247, 183, 49, 0.5);
}

.abw-escalate-btn {
  display: inline-flex !important;
  margin-top: 0.45rem;
  padding: 0.55rem 0.95rem !important;
  border-radius: 999px !important;
  background: linear-gradient(145deg, var(--abw-primary-mid), var(--abw-primary-dark)) !important;
  color: #fff !important;
  font-weight: 700;
}

.abw-typing .abw-msg-bubble {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-width: 54px;
  padding: 0.85rem 1rem;
}
.abw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8aa0b5;
  animation: abw-dot 1.1s infinite ease-in-out;
}
.abw-typing span:nth-child(2) { animation-delay: 0.15s; }
.abw-typing span:nth-child(3) { animation-delay: 0.3s; }

.abw-quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  padding: 0.7rem 0.75rem;
  background: linear-gradient(180deg, #fff, #f8fafc);
  border-top: 1px solid rgba(10, 61, 98, 0.06);
  flex-shrink: 0;
}

.abw-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  min-height: 64px;
  padding: 0.45rem 0.35rem;
  border: 1px solid rgba(10, 61, 98, 0.1);
  background: #fff;
  color: var(--abw-primary);
  border-radius: 16px;
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
  font-family: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  box-shadow: 0 4px 10px rgba(10, 61, 98, 0.04);
}

.abw-chip-ico {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(10, 61, 98, 0.08), rgba(247, 183, 49, 0.22));
  color: var(--abw-primary);
}

.abw-chip-ico svg {
  width: 15px;
  height: 15px;
}

.abw-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(247, 183, 49, 0.65);
  background: linear-gradient(180deg, #fff, #fff8e8);
  box-shadow: 0 10px 20px rgba(10, 61, 98, 0.12);
  color: var(--abw-primary-dark);
}

.abw-chip:hover .abw-chip-ico {
  background: linear-gradient(145deg, var(--abw-primary), var(--abw-primary-dark));
  color: var(--abw-gold);
}

.abw-composer {
  display: flex;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem 0.5rem;
  background: #fff;
  border-top: 1px solid rgba(10, 61, 98, 0.06);
  flex-shrink: 0;
}

.abw-input {
  flex: 1;
  border: 1px solid rgba(10, 61, 98, 0.12);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  background: #f4f7fb;
  color: var(--abw-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.abw-input:focus {
  border-color: rgba(247, 183, 49, 0.7);
  box-shadow: 0 0 0 4px rgba(247, 183, 49, 0.18);
  background: #fff;
}

.abw-send {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--abw-gold), #e0a800);
  color: var(--abw-primary-dark);
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(247, 183, 49, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.abw-send:hover {
  transform: scale(1.06);
  filter: brightness(1.05);
}

.abw-foot {
  text-align: center;
  padding: 0.25rem 0.75rem 0.7rem;
  background: #fff;
  flex-shrink: 0;
}

.abw-foot a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--abw-muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}
.abw-foot a:hover {
  color: var(--abw-primary);
  background: rgba(10, 61, 98, 0.06);
}

@keyframes abw-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-8px) rotate(1.5deg); }
}
@keyframes abw-blink {
  0%, 42%, 48%, 100% { transform: scaleY(1); }
  45% { transform: scaleY(0.12); }
}
@keyframes abw-pulse {
  0% { transform: scale(0.75); opacity: 0.55; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { opacity: 0; }
}
@keyframes abw-ring {
  0% { transform: scale(0.85); opacity: 0.7; }
  70% { transform: scale(1.2); opacity: 0; }
  100% { opacity: 0; }
}
@keyframes abw-panel-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes abw-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes abw-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 576px) {
  .abw-root { left: 12px; bottom: 12px; }
  .abw-panel {
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    left: 0;
  }
  .abw-launcher { width: 82px; height: 92px; }
  .abw-bot { width: 76px; height: 86px; }
  .abw-quick {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }
  .abw-chip {
    min-height: 58px;
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .abw-bot,
  .abw-bot .ab-eye,
  .abw-pulse,
  .abw-ring,
  .abw-panel,
  .abw-msg,
  .abw-typing span {
    animation: none !important;
  }
}
