/* Ayla web chat. Colors, font and rounding are adopted from the host site at runtime
   (JS sets --ayla-* inline); the var() fallbacks below cover sites where that fails. */
.ayla-chat{
  --ayla-accent:var(--dc-brand,var(--wp--preset--color--brand,#0b5fa5));
  --ayla-on-accent:var(--dc-on-accent,var(--wp--preset--color--on-accent,#fff));
  --ayla-surface:#fff;
  --ayla-text:var(--dc-ink,var(--wp--preset--color--ink,#1c2635));
  --ayla-font:var(--wp--preset--font-family--almarai,inherit);
  --ayla-radius:14px;
  --ayla-muted:color-mix(in srgb,var(--ayla-text) 7%,var(--ayla-surface));
  --ayla-border:color-mix(in srgb,var(--ayla-text) 14%,var(--ayla-surface));
  --ayla-whatsapp:#25d366;
  /* The logo is dark navy on a transparent background, so it always sits on this cream disc whatever the site's accent color is. */
  --ayla-logo-bg:#f8f3e8;
  position:fixed;right:96px;bottom:20px;z-index:99990;
  font-family:var(--ayla-font);color:var(--ayla-text);
  font-size:14.5px;line-height:1.55;
}

/* ---- Launcher ---- */
.ayla-chat__toggle{
  position:relative;width:62px;height:62px;padding:0;border:0;border-radius:50%;
  background:var(--ayla-accent);cursor:pointer;overflow:visible;
  box-shadow:0 6px 16px color-mix(in srgb,var(--ayla-accent) 45%,transparent),0 2px 6px rgba(10,20,40,.18);
  transition:transform .18s ease,box-shadow .18s ease;
}
.ayla-chat__toggle:is(:hover,:focus-visible){transform:translateY(-3px) scale(1.04);box-shadow:0 12px 26px color-mix(in srgb,var(--ayla-accent) 55%,transparent)}
.ayla-chat__toggle img{display:block;width:100%;height:100%;border-radius:50%;object-fit:cover;background:var(--ayla-logo-bg);border:2px solid var(--ayla-surface)}
.ayla-chat__pulse{position:absolute;inset:0;border-radius:50%;pointer-events:none;animation:ayla-pulse 2.6s infinite}
.ayla-chat--open .ayla-chat__pulse{animation:none}
@keyframes ayla-pulse{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--ayla-accent) 45%,transparent)}70%{box-shadow:0 0 0 14px transparent}100%{box-shadow:0 0 0 0 transparent}}

/* ---- Panel ---- */
.ayla-chat__panel{
  position:absolute;right:0;bottom:76px;width:min(392px,calc(100vw - 32px));
  max-height:calc(100vh - 110px);max-height:calc(100dvh - 110px);
  display:flex;flex-direction:column;overflow:hidden;
  background:var(--ayla-surface);border:1px solid var(--ayla-border);
  border-radius:calc(var(--ayla-radius) + 6px);
  box-shadow:0 24px 60px rgba(10,20,40,.22),0 6px 18px rgba(10,20,40,.12);
  animation:ayla-open .22s ease;
}
/* display:flex above would otherwise override the hidden attribute and keep the panel on screen. */
.ayla-chat__panel[hidden]{display:none}
.ayla-chat--large .ayla-chat__panel{width:min(540px,calc(100vw - 32px))}
.ayla-chat--large .ayla-chat__messages{max-height:min(62vh,640px)}
@keyframes ayla-open{from{opacity:0;transform:translateY(14px) scale(.97)}to{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){.ayla-chat__panel{animation:none}.ayla-chat__pulse{animation:none}}

/* ---- Header ---- */
.ayla-chat__head{
  display:flex;align-items:center;gap:12px;padding:14px 16px;
  background:linear-gradient(135deg,var(--ayla-accent),color-mix(in srgb,var(--ayla-accent) 78%,#001630));
  color:var(--ayla-on-accent);
}
.ayla-chat__avatar{position:relative;flex:0 0 auto;width:42px;height:42px}
.ayla-chat__avatar img{width:100%;height:100%;border-radius:50%;object-fit:cover;background:var(--ayla-logo-bg);border:2px solid color-mix(in srgb,var(--ayla-on-accent) 85%,transparent)}
.ayla-chat__dot{position:absolute;inset-inline-end:-1px;bottom:-1px;width:11px;height:11px;border-radius:50%;background:#2ecc71;border:2px solid var(--ayla-surface)}
.ayla-chat__id{flex:1 1 auto;min-width:0}
.ayla-chat__title{margin:0;font-size:15.5px;font-weight:800;line-height:1.3;color:inherit}
.ayla-chat__status{display:block;font-size:12px;opacity:.85}
.ayla-chat__icon{
  flex:0 0 auto;display:grid;place-items:center;width:32px;height:32px;padding:0;border:0;border-radius:8px;
  background:color-mix(in srgb,var(--ayla-on-accent) 14%,transparent);color:inherit;
  cursor:pointer;line-height:1;transition:background-color .15s ease;
}
.ayla-chat__icon svg{display:block;width:16px;height:16px;pointer-events:none}
/* display:grid above would otherwise override the hidden attribute. */
.ayla-chat__icon[hidden]{display:none}
.ayla-chat__icon:is(:hover,:focus-visible){background:color-mix(in srgb,var(--ayla-on-accent) 26%,transparent)}
.ayla-chat__icon:focus-visible,.ayla-chat__toggle:focus-visible{outline:2px solid var(--ayla-on-accent);outline-offset:2px}

/* ---- Messages ---- */
.ayla-chat__messages{
  flex:1 1 auto;max-height:340px;min-height:120px;overflow:auto;padding:16px;
  display:flex;flex-direction:column;align-items:flex-start;
  background:color-mix(in srgb,var(--ayla-accent) 4%,var(--ayla-surface));
  scrollbar-width:thin;
}
.ayla-chat__message{
  max-width:86%;padding:10px 14px;margin:0 0 10px;
  border-radius:var(--ayla-radius);background:var(--ayla-surface);
  border:1px solid var(--ayla-border);box-shadow:0 1px 2px rgba(10,20,40,.06);
  border-start-start-radius:4px;align-self:flex-start;
  overflow-wrap:break-word;
}
.ayla-chat__message--in{
  align-self:flex-end;background:var(--ayla-accent);color:var(--ayla-on-accent);border:0;
  border-radius:var(--ayla-radius);border-start-end-radius:4px;border-start-start-radius:var(--ayla-radius);
  box-shadow:0 2px 6px color-mix(in srgb,var(--ayla-accent) 35%,transparent);
}
.ayla-chat__message--prompt{border-inline-start:3px solid var(--ayla-accent)}
.ayla-chat__message--error{background:#fdecec;border-color:#f3c1c1;color:#9b1c1c}
.ayla-chat__line+.ayla-chat__line,.ayla-chat__list+.ayla-chat__line,.ayla-chat__line+.ayla-chat__list,.ayla-chat__choice+.ayla-chat__line{margin-top:6px}
.ayla-chat__list{margin:6px 0 2px;padding:0;list-style:none}
.ayla-chat__list li{position:relative;margin:0 0 5px;padding-inline-start:16px}
.ayla-chat__list li::before{content:"";position:absolute;inset-inline-start:0;top:.72em;width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.65}
.ayla-chat__link{color:var(--ayla-accent);font-weight:700;text-decoration:underline;text-underline-offset:2px;overflow-wrap:anywhere;word-break:break-word}
.ayla-chat__message--in .ayla-chat__link{color:inherit}

/* ---- Quick choices ---- */
.ayla-chat__chooser{align-self:stretch;display:flex;flex-direction:column;align-items:flex-start}
.ayla-chat__choice{
  display:inline-block;margin:6px 6px 0 0;padding:8px 16px;
  border:1.5px solid var(--ayla-accent);border-radius:999px;
  background:var(--ayla-surface);color:var(--ayla-accent);
  font:inherit;font-weight:700;font-size:13.5px;cursor:pointer;text-decoration:none;
  transition:background-color .15s ease,color .15s ease,transform .15s ease;
}
[dir=rtl] .ayla-chat__choice{margin:6px 0 0 6px}
.ayla-chat__choice:is(:hover,:focus-visible){background:var(--ayla-accent);color:var(--ayla-on-accent);transform:translateY(-1px)}
.ayla-chat__choice--whatsapp{border-color:var(--ayla-whatsapp);color:#128c4a}
.ayla-chat__choice--whatsapp:is(:hover,:focus-visible){background:var(--ayla-whatsapp);border-color:var(--ayla-whatsapp);color:#fff}

/* ---- Typing ---- */
.ayla-chat__message--typing{display:inline-flex;gap:5px;align-items:center;min-height:20px}
.ayla-chat__message--typing span{width:7px;height:7px;border-radius:50%;background:var(--ayla-accent);opacity:.35;animation:ayla-dot 1s infinite ease-in-out}
.ayla-chat__message--typing span:nth-child(2){animation-delay:.15s}
.ayla-chat__message--typing span:nth-child(3){animation-delay:.3s}
@keyframes ayla-dot{0%,80%,100%{opacity:.35;transform:none}40%{opacity:1;transform:translateY(-3px)}}
@media (prefers-reduced-motion:reduce){.ayla-chat__message--typing span{animation:none;opacity:.7}}

/* ---- Composer ---- */
.ayla-chat__form{padding:12px 14px 8px;border-top:1px solid var(--ayla-border);background:var(--ayla-surface)}
.ayla-chat__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.ayla-chat__row{display:flex;align-items:center;gap:8px}
.ayla-chat__row input{
  flex:1 1 auto;min-width:0;padding:11px 16px;
  border:1.5px solid var(--ayla-border);border-radius:999px;
  background:color-mix(in srgb,var(--ayla-text) 3%,var(--ayla-surface));
  color:var(--ayla-text);font:inherit;
}
.ayla-chat__row input:focus{border-color:var(--ayla-accent);outline:3px solid color-mix(in srgb,var(--ayla-accent) 18%,transparent)}
.ayla-chat__send{
  flex:0 0 auto;display:grid;place-items:center;width:42px;height:42px;padding:0;
  border:0;border-radius:50%;background:var(--ayla-accent);color:var(--ayla-on-accent);
  cursor:pointer;transition:transform .15s ease,filter .15s ease;
}
.ayla-chat__send:is(:hover,:focus-visible){transform:scale(1.07);filter:brightness(1.08)}
.ayla-chat__send:disabled{opacity:.55;cursor:wait;transform:none}
[dir=rtl] .ayla-chat__send svg{transform:scaleX(-1)}

/* ---- Brand ---- */
.ayla-chat__brand{display:block;padding:0 14px 10px;font-size:11px;text-align:center;color:color-mix(in srgb,var(--ayla-text) 55%,var(--ayla-surface))}
.ayla-chat__brand a{color:inherit;text-decoration:none}
.ayla-chat__brand a:hover{text-decoration:underline}

/* ---- Small screens ---- */
@media (max-width:1260px){
  .ayla-chat{right:16px;bottom:calc(82px + env(safe-area-inset-bottom,0px))}
  /* The launcher sits higher here, so the panel has less room above it. */
  .ayla-chat__panel{max-height:calc(100vh - 190px);max-height:calc(100dvh - 190px)}
}
@media (max-width:480px){
  /* Anchored by both edges instead of a width, so a scrollbar or a notch can never push it off screen. */
  .ayla-chat__panel,.ayla-chat--large .ayla-chat__panel{
    position:fixed;left:12px;right:12px;width:auto;
    bottom:calc(158px + env(safe-area-inset-bottom,0px));
    max-height:calc(100vh - 190px);max-height:calc(100dvh - 190px);
  }
  .ayla-chat__messages,.ayla-chat--large .ayla-chat__messages{max-height:52vh}
  /* The panel already uses the full width here, so there is nothing to expand. */
  .ayla-chat__icon[data-size-toggle]{display:none}
}

