/* Affiracle live-chat widget — self-contained, RTL-aware. No 135deg #667eea gradient. */
#affiracle-livechat {
  --lc-accent: #4F46E5;
  --lc-accent-dark: #4338CA;
  --lc-bg: #ffffff;
  --lc-ink: #1f2937;
  --lc-muted: #6b7280;
  --lc-line: #e5e7eb;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
#affiracle-livechat * { box-sizing: border-box; }
#affiracle-livechat .lc-hidden { display: none !important; }

/* ── Launcher ───────────────────────────────────────────── */
#lc-launcher {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--lc-accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
}
#lc-launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.45);
  animation: lc-pulse 2.4s infinite;
}
@keyframes lc-pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
  70% { box-shadow: 0 0 0 16px rgba(79, 70, 229, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}
#lc-launcher:hover { transform: scale(1.07); box-shadow: 0 10px 28px rgba(79, 70, 229, 0.55); }
#lc-launcher:active { transform: scale(0.97); }
.lc-launcher-icon { position: relative; z-index: 1; }

#lc-badge {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
  z-index: 2;
}

/* ── Panel ──────────────────────────────────────────────── */
#lc-panel {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  background: var(--lc-bg);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(17, 24, 39, 0.28);
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--lc-ink);
  transform-origin: bottom right;
  animation: lc-pop .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes lc-pop {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ─────────────────────────────────────────────── */
#lc-header {
  background: var(--lc-accent);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.lc-header-info { display: flex; align-items: center; gap: 10px; }
.lc-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.lc-header-text { display: flex; flex-direction: column; line-height: 1.2; }
#lc-title { font-weight: 700; font-size: 15px; }
.lc-subtitle { font-size: 11px; opacity: .9; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.lc-online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34d399; box-shadow: 0 0 0 2px rgba(52,211,153,.3);
  display: inline-block;
}
.lc-header-actions { display: flex; align-items: center; gap: 2px; }
#lc-close {
  background: none; border: none; color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; opacity: .85;
}
#lc-close:hover { opacity: 1; }
#lc-newchat {
  background: rgba(255,255,255,0.16);
  border: none; color: #fff; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  opacity: .9; transition: background .15s ease;
}
#lc-newchat:hover { background: rgba(255,255,255,0.28); opacity: 1; }

#lc-newchat-cta {
  align-self: center;
  margin: 4px auto 10px;
  padding: 8px 16px;
  border: 1px solid var(--lc-accent);
  background: #fff;
  color: var(--lc-accent);
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}
#lc-newchat-cta:hover { background: var(--lc-accent); color: #fff; }

/* ── Screens (forms) ────────────────────────────────────── */
.lc-screen { padding: 18px; overflow-y: auto; flex: 1 1 auto; display: flex; flex-direction: column; gap: 11px; }
.lc-intro { margin: 0 0 2px; font-size: 14px; color: var(--lc-muted); line-height: 1.45; }

#lc-prechat input, #lc-prechat select, #lc-offline textarea, #lc-input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--lc-line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--lc-ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
#lc-prechat input:focus, #lc-prechat select:focus, #lc-offline textarea:focus, #lc-input:focus {
  outline: none;
  border-color: var(--lc-accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
#lc-prechat button, #lc-offline button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--lc-accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
#lc-prechat button:hover, #lc-offline button:hover { background: var(--lc-accent-dark); }
#lc-prechat button:disabled { opacity: .6; cursor: default; }
#lc-hp, #lc-offline-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; }

/* ── Conversation ───────────────────────────────────────── */
#lc-chat { padding: 0; gap: 0; }
#lc-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f6f7fb;
}
.lc-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
  animation: lc-msg-in .18s ease;
}
@keyframes lc-msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.lc-msg .lc-time { display: block; font-size: 10px; opacity: .6; margin-top: 4px; }
.lc-msg-visitor { align-self: flex-end; background: var(--lc-accent); color: #fff; border-bottom-right-radius: 5px; }
.lc-msg-agent   { align-self: flex-start; background: #fff; border: 1px solid var(--lc-line); border-bottom-left-radius: 5px; }
.lc-msg-system  { align-self: center; background: #eef2ff; color: var(--lc-accent-dark); font-size: 12.5px; text-align: center; max-width: 92%; box-shadow: none; }

#lc-composer { display: flex; align-items: center; gap: 8px; padding: 12px; border-top: 1px solid var(--lc-line); flex: 0 0 auto; background: #fff; }
#lc-composer #lc-input { border-radius: 22px; }
#lc-attach {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  color: var(--lc-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: background .15s ease, color .15s ease;
}
#lc-attach:hover { background: #f3f4f6; color: var(--lc-accent); }
.lc-img {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border-radius: 12px;
  margin-bottom: 4px;
  cursor: pointer;
}
#lc-composer button {
  border: none; border-radius: 50%;
  width: 42px; height: 42px; flex: 0 0 auto;
  background: var(--lc-accent); color: #fff;
  font-size: 0;
  cursor: pointer;
  position: relative;
  transition: background .15s ease;
}
#lc-composer button:hover { background: var(--lc-accent-dark); }
#lc-composer button::before {
  content: "➤"; font-size: 16px; display: block;
}
#affiracle-livechat[dir="rtl"] #lc-composer button::before { transform: scaleX(-1); }

#lc-status { padding: 14px 18px; font-size: 13.5px; color: var(--lc-muted); text-align: center; line-height: 1.5; }

/* ── RTL bubble mirroring ───────────────────────────────── */
#affiracle-livechat[dir="rtl"] #lc-launcher { inset-inline-end: 24px; }
#affiracle-livechat[dir="rtl"] .lc-msg-visitor { border-bottom-right-radius: 16px; border-bottom-left-radius: 5px; }
#affiracle-livechat[dir="rtl"] .lc-msg-agent   { border-bottom-left-radius: 16px; border-bottom-right-radius: 5px; }

@media (max-width: 480px) {
  #lc-panel { width: 100vw; height: 100dvh; max-height: 100dvh; bottom: 0; inset-inline-end: 0; border-radius: 0; }
}
