/* «مساعد أنوبيس» — the chat bubble (src/chat.js). Always bottom RIGHT, in
   both languages; the countdown popup keeps the bottom left. */

.achat { position: fixed; right: 20px; bottom: 20px; z-index: 70; font-family: var(--body); }
.achat-open {
  position: relative; display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%;
  border: 0; cursor: pointer; color: #1c1407;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  box-shadow: 0 14px 34px rgba(234,184,95,.35), 0 0 0 6px rgba(234,184,95,.12);
  transition: transform .3s var(--ease), box-shadow .3s;
  animation: achat-pop .6s var(--ease) .8s both;
}
.achat-open:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 18px 40px rgba(234,184,95,.45), 0 0 0 8px rgba(234,184,95,.14); }
.achat-open img { width: 38px; height: 38px; border-radius: 12px; transition: opacity .2s, transform .3s var(--ease); }
.achat-open .x { position: absolute; width: 26px; height: 26px; opacity: 0; transform: rotate(-90deg); transition: opacity .2s, transform .3s var(--ease); }
.achat.open .achat-open img { opacity: 0; transform: scale(.6); }
.achat.open .achat-open .x { opacity: 1; transform: none; }
.achat-open .dot { position: absolute; top: 4px; right: 4px; width: 13px; height: 13px; border-radius: 50%; background: var(--live); border: 2px solid var(--bg); }
.achat.open .achat-open .dot { display: none; }
@keyframes achat-pop { from { opacity: 0; transform: scale(.4) translateY(20px); } }

.achat-nudge {
  position: absolute; right: 4px; bottom: 76px; white-space: nowrap; cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid rgba(234,184,95,.3);
  padding: 9px 14px; border-radius: 16px 16px 4px 16px; font-size: .92rem; font-weight: 500;
  box-shadow: 0 12px 30px rgba(0,0,0,.4); animation: achat-rise .45s var(--ease) both;
}
.achat-nudge[hidden] { display: none; }

.achat-panel {
  position: absolute; right: 0; bottom: 78px;
  width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 24px; border: 1px solid rgba(255,255,255,.14);
  background: linear-gradient(160deg, rgba(234,184,95,.10), transparent 40%), rgba(12,24,48,.92);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  transform-origin: bottom right; animation: achat-rise .35s var(--ease) both;
}
.achat-panel[hidden] { display: none; }
@keyframes achat-rise { from { opacity: 0; transform: translateY(14px) scale(.96); } }

.achat-panel header { display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line); }
.achat-panel header img { border-radius: 11px; box-shadow: 0 0 0 1px rgba(234,184,95,.35); }
.achat-panel header div { flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.achat-panel header b { font-family: var(--display); font-weight: 700; }
.achat-panel header span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8rem; }
.achat-panel header span i { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px rgba(95,211,162,.18); }
.achat-x { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; background: rgba(255,255,255,.06); color: var(--muted); }
.achat-x:hover { color: var(--text); background: rgba(255,255,255,.12); }
.achat-x svg { width: 18px; height: 18px; }

.achat-log { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.14) transparent; }
.achat-msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: .94rem; line-height: 1.7; overflow-wrap: anywhere; }
.achat-msg.in { animation: achat-rise .3s var(--ease) both; }
.achat-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-start-start-radius: 6px; }
.achat-msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #1c1407; font-weight: 500; border-start-end-radius: 6px; }
.achat-msg p + p, .achat-msg p + ul, .achat-msg ul + div, .achat-msg p + div { margin-top: 8px; }
.achat-msg ul { padding-inline-start: 18px; color: var(--muted); }
.achat-msg li { margin: 3px 0; }
.achat-msg a:not(.achat-links a) { color: var(--gold-2); text-decoration: underline; text-underline-offset: 3px; }
.achat-links { display: flex; flex-wrap: wrap; gap: 6px; }
.achat-links a { padding: 5px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600; background: var(--gold-soft); color: var(--gold-2); border: 1px solid rgba(234,184,95,.3); transition: background-color .2s; }
.achat-links a:hover { background: rgba(234,184,95,.25); }
.achat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.achat-chips button {
  font: inherit; font-size: .84rem; cursor: pointer; padding: 6px 12px; border-radius: 999px;
  color: var(--text); background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.16); transition: all .2s;
}
.achat-chips button:hover { border-color: rgba(234,184,95,.5); color: var(--gold-2); }
.achat-msg.typing { display: flex; gap: 5px; padding: 14px 16px; }
.achat-msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: achat-dot 1s ease-in-out infinite; }
.achat-msg.typing span:nth-child(2) { animation-delay: .15s; }
.achat-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes achat-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.achat-form { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.achat-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text); background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 10px 16px; outline: none;
}
.achat-form input:focus { border-color: rgba(234,184,95,.55); }
.achat-form button { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; cursor: pointer; color: #1c1407; background: linear-gradient(135deg, var(--gold-2), var(--gold)); }
.achat-form button svg { width: 20px; height: 20px; }
[dir="rtl"] .achat-form button svg { transform: scaleX(-1); }

/* The countdown popup sits bottom-end: bottom right on the English site, where
   it would cover the bubble, so it moves to the bottom left there. */
[dir="ltr"] .cdpop { inset-inline-end: auto; inset-inline-start: 24px; --dir: -1; }

@media (max-width: 560px) {
  /* The phone countdown spans the width; stop it short of the bubble. */
  html[dir] .cdpop { left: 12px; right: 82px; }
}
@media (max-width: 520px) {
  .achat { right: 14px; bottom: 14px; }
  .achat-open { width: 56px; height: 56px; }
  .achat-panel { position: fixed; right: 10px; left: 10px; bottom: 82px; width: auto; height: min(600px, calc(100dvh - 100px)); }
}
@media (prefers-reduced-motion: reduce) {
  .achat *, .achat-open { animation: none !important; }
}
