/* Same corner as WhatsApp: LTR = bottom-right, RTL = bottom-left (واتساب فوق، المساعد تحته — home-v3.css) */
.ac-chat {
  --ac-accent: #2b6bff;
  position: fixed;
  left: auto;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  font-family: 'Tajawal', 'Cairo', system-ui, -apple-system, Segoe UI, Arial, sans-serif;
}

.ac-chat__fab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  user-select: none;
}

.ac-chat__fab:focus {
  outline: 3px solid rgba(43, 107, 255, 0.4);
  outline-offset: 2px;
}

.ac-chat__fab-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #3b4bd4);
  display: inline-grid;
  place-items: center;
  font-weight: 800;
}

.ac-chat__fab-icon:has(img) {
  background: transparent;
  overflow: hidden;
}

.ac-chat__fab-icon img {
  display: block;
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.ac-chat__fab-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: start;
}

.ac-chat__fab-text strong {
  font-size: 0.95rem;
}

.ac-chat__fab-text span {
  font-size: 0.8rem;
  opacity: 0.85;
}

.ac-chat__panel {
  position: absolute;
  left: auto;
  right: 0;
  bottom: 58px;
  width: min(380px, calc(100vw - 36px));
  max-height: min(520px, calc(100vh - 120px));
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  display: none;
}

.ac-chat[data-open="true"] .ac-chat__panel {
  display: flex;
  flex-direction: column;
}

.ac-chat__panel-head {
  padding: 14px 14px;
  background: linear-gradient(135deg, rgba(10, 14, 58, 0.96), rgba(30, 41, 156, 0.92));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ac-chat__panel-title {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: start;
}

.ac-chat__panel-title strong {
  font-size: 0.95rem;
}

.ac-chat__panel-title span {
  font-size: 0.78rem;
  opacity: 0.85;
}

.ac-chat__close {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
}

.ac-chat__messages {
  padding: 14px;
  overflow: auto;
  background: linear-gradient(180deg, rgba(248, 249, 254, 1), rgba(255, 255, 255, 1));
  flex: 1;
}

.ac-chat__msg {
  display: flex;
  margin-bottom: 10px;
}

.ac-chat__bubble {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(13, 18, 89, 0.08);
  box-shadow: 0 8px 18px rgba(30, 41, 156, 0.08);
  font-size: 0.95rem;
  line-height: 1.6;
}

.ac-chat__msg--bot .ac-chat__bubble {
  background: #ffffff;
  color: #0f1222;
  border-top-left-radius: 6px;
}

.ac-chat__msg--user {
  justify-content: flex-end;
}

.ac-chat__msg--user .ac-chat__bubble {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(30, 41, 156, 0.10));
  border-top-right-radius: 6px;
}

.ac-chat__composer {
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid rgba(13, 18, 89, 0.08);
}

.ac-chat__input {
  width: 100%;
  border: 1px solid rgba(13, 18, 89, 0.14);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.ac-chat__send {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #6366f1, #3b4bd4);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.ac-chat__hint {
  padding: 10px 14px 14px;
  font-size: 0.78rem;
  color: rgba(15, 18, 34, 0.65);
  text-align: start;
}

[dir="rtl"] .ac-chat {
  left: 18px;
  right: auto;
}

[dir="rtl"] .ac-chat__panel {
  left: 0;
  right: auto;
}
