/* ============================================================================
   JDS assistant — chat widget
   Drop-in. Self-contained. Themed entirely through the --chat-* variables
   below, so the same file works on either site design: override any of these
   in the host stylesheet (or in a <style> block) to re-skin it.
   ========================================================================= */

:root{
  /* ---------- Colour ---------- */
  --chat-accent:#f4657f;             /* Launcher fill, send button, focus ring */
  --chat-accent-text:#111214;        /* Text on the accent colour - dark, since the pink is light */
  --chat-accent-ink:#be3a60;         /* Darkened pink for links inside messages */

  --chat-surface:#ffffff;            /* Panel background */
  --chat-surface-2:#f3f2ef;          /* Message list background */
  --chat-ink:#111214;                /* Main text colour */
  --chat-ink-soft:#5b5f66;           /* Secondary text colour */
  --chat-line:#dcd9d2;               /* Borders and dividers */
  --chat-header-bg:#111214;          /* Panel header background */
  --chat-header-text:#f3f2ef;        /* Panel header text */
  --chat-bot-bg:#ffffff;             /* Assistant bubble background */
  --chat-bot-text:#111214;           /* Assistant bubble text */
  --chat-user-bg:#111214;            /* Visitor bubble background */
  --chat-user-text:#f3f2ef;          /* Visitor bubble text */

  /* ---------- Type ---------- */
  --chat-font:inherit;               /* Font family for the whole widget */
  --chat-font-size:15px;             /* Message text size */
  --chat-label-size:11px;            /* Small caps labels and meta text */
  --chat-line-height:1.55;           /* Message line spacing */

  /* ---------- Size & position ---------- */
  --chat-panel-width:370px;          /* Panel width on desktop */
  --chat-panel-height:min(560px,72vh); /* Panel height on desktop */
  --chat-offset:20px;                /* Distance from the screen corner */
  --chat-launcher-size:56px;         /* Diameter of the launcher button */
  --chat-radius:14px;                /* Panel corner rounding */
  --chat-bubble-radius:12px;         /* Message bubble rounding */
  --chat-gap:10px;                   /* Space between messages */
  --chat-pad:16px;                   /* Padding inside panel sections */

  /* ---------- Motion ---------- */
  --chat-transition:.22s;            /* Speed of open/close and hovers */
  --chat-ease:cubic-bezier(.22,1,.36,1); /* Easing curve */

  --chat-z:9000;                     /* Stacking order above page content */
  --chat-shadow:0 24px 60px -18px rgba(17,18,20,.45); /* Panel shadow */
}

/* ---------- Launcher ---------- */
.jds-chat-launcher{
  position:fixed;
  right:var(--chat-offset);bottom:var(--chat-offset);
  z-index:var(--chat-z);
  display:flex;align-items:center;justify-content:center;
  width:var(--chat-launcher-size);height:var(--chat-launcher-size);
  padding:0;
  background:var(--chat-accent);color:var(--chat-accent-text);
  border:none;border-radius:50%;
  box-shadow:var(--chat-shadow);
  cursor:pointer;
  transition:transform var(--chat-transition) var(--chat-ease),
             background var(--chat-transition) ease;
}
.jds-chat-launcher:hover{transform:translateY(-2px) scale(1.04);}
.jds-chat-launcher svg{width:24px;height:24px;}
.jds-chat-launcher .jds-chat-close-ico{display:none;}
.jds-chat-launcher[aria-expanded="true"] .jds-chat-open-ico{display:none;}
.jds-chat-launcher[aria-expanded="true"] .jds-chat-close-ico{display:block;}

/* small unread/prompt dot */
.jds-chat-launcher::after{
  content:"";position:absolute;top:2px;right:2px;
  width:12px;height:12px;border-radius:50%;
  background:#22c55e;border:2px solid var(--chat-surface);
  opacity:0;transform:scale(.6);
  transition:opacity var(--chat-transition),transform var(--chat-transition);
}
.jds-chat-launcher.has-hint::after{opacity:1;transform:none;}

/* ---------- Panel ---------- */
.jds-chat-panel{
  position:fixed;
  right:var(--chat-offset);
  bottom:calc(var(--chat-offset) + var(--chat-launcher-size) + 12px);
  z-index:var(--chat-z);
  display:flex;flex-direction:column;
  width:var(--chat-panel-width);height:var(--chat-panel-height);
  background:var(--chat-surface);
  color:var(--chat-ink);
  font-family:var(--chat-font);
  font-size:var(--chat-font-size);
  line-height:var(--chat-line-height);
  border:1px solid var(--chat-line);
  border-radius:var(--chat-radius);
  box-shadow:var(--chat-shadow);
  overflow:hidden;
  opacity:0;transform:translateY(12px) scale(.98);
  pointer-events:none;
  transition:opacity var(--chat-transition) var(--chat-ease),
             transform var(--chat-transition) var(--chat-ease);
}
.jds-chat-panel.is-open{opacity:1;transform:none;pointer-events:auto;}

@media (max-width:520px){
  .jds-chat-panel{
    right:0;left:0;bottom:0;
    width:100%;height:88vh;
    border-radius:var(--chat-radius) var(--chat-radius) 0 0;
    border-bottom:none;
  }
}

/* ---------- Header ---------- */
.jds-chat-head{
  display:flex;align-items:center;gap:10px;
  padding:var(--chat-pad);
  background:var(--chat-header-bg);color:var(--chat-header-text);
}
.jds-chat-head__dot{
  width:8px;height:8px;border-radius:50%;background:#22c55e;flex:0 0 8px;
}
.jds-chat-head__title{font-weight:600;line-height:1.2;}
.jds-chat-head__sub{
  display:block;
  font-size:var(--chat-label-size);
  text-transform:uppercase;letter-spacing:.14em;
  opacity:.62;margin-top:3px;
}
.jds-chat-head__close{
  margin-left:auto;
  width:32px;height:32px;padding:0;
  display:flex;align-items:center;justify-content:center;
  background:none;border:none;border-radius:6px;
  color:inherit;cursor:pointer;opacity:.7;
}
.jds-chat-head__close:hover{opacity:1;background:rgba(255,255,255,.12);}
.jds-chat-head__close svg{width:16px;height:16px;}

/* ---------- Message list ---------- */
.jds-chat-log{
  flex:1;overflow-y:auto;
  display:flex;flex-direction:column;gap:var(--chat-gap);
  padding:var(--chat-pad);
  background:var(--chat-surface-2);
  overscroll-behavior:contain;
}
.jds-chat-msg{
  max-width:88%;
  padding:10px 13px;
  border-radius:var(--chat-bubble-radius);
  white-space:pre-wrap;word-wrap:break-word;
}
.jds-chat-msg--bot{
  align-self:flex-start;
  background:var(--chat-bot-bg);color:var(--chat-bot-text);
  border:1px solid var(--chat-line);
  border-bottom-left-radius:4px;
}
.jds-chat-msg--user{
  align-self:flex-end;
  background:var(--chat-user-bg);color:var(--chat-user-text);
  border-bottom-right-radius:4px;
}
.jds-chat-msg a{color:var(--chat-accent-ink);font-weight:600;}
.jds-chat-msg--user a{color:inherit;text-decoration:underline;}

/* typing indicator */
.jds-chat-typing{display:flex;gap:4px;align-items:center;padding:4px 2px;}
.jds-chat-typing span{
  width:6px;height:6px;border-radius:50%;background:var(--chat-ink-soft);
  animation:jds-chat-bounce 1.2s infinite ease-in-out;
}
.jds-chat-typing span:nth-child(2){animation-delay:.15s;}
.jds-chat-typing span:nth-child(3){animation-delay:.3s;}
@keyframes jds-chat-bounce{
  0%,60%,100%{transform:translateY(0);opacity:.45;}
  30%{transform:translateY(-4px);opacity:1;}
}

/* ---------- Quick replies ---------- */
.jds-chat-chips{
  display:flex;flex-wrap:wrap;gap:6px;
  padding:0 var(--chat-pad) var(--chat-pad);
  background:var(--chat-surface-2);
}
.jds-chat-chip{
  font:inherit;font-size:13px;
  padding:7px 12px;
  background:var(--chat-surface);color:var(--chat-ink);
  border:1px solid var(--chat-line);border-radius:999px;
  cursor:pointer;
  transition:border-color var(--chat-transition) ease,color var(--chat-transition) ease;
}
.jds-chat-chip:hover{border-color:var(--chat-accent);color:var(--chat-accent-ink);}

/* ---------- Composer ---------- */
.jds-chat-form{
  display:flex;gap:8px;align-items:flex-end;
  padding:var(--chat-pad);
  border-top:1px solid var(--chat-line);
  background:var(--chat-surface);
}
.jds-chat-input{
  flex:1;
  font:inherit;font-size:var(--chat-font-size);
  color:var(--chat-ink);
  padding:10px 12px;
  max-height:110px;min-height:44px;
  background:var(--chat-surface-2);
  border:1px solid var(--chat-line);border-radius:10px;
  resize:none;
}
.jds-chat-input:focus{
  outline:none;border-color:var(--chat-accent);
  box-shadow:0 0 0 2px rgba(244,101,127,.3);
}
.jds-chat-send{
  flex:0 0 44px;width:44px;height:44px;padding:0;
  display:flex;align-items:center;justify-content:center;
  background:var(--chat-accent);color:var(--chat-accent-text);
  border:none;border-radius:10px;cursor:pointer;
  transition:opacity var(--chat-transition) ease;
}
.jds-chat-send:disabled{opacity:.45;cursor:not-allowed;}
.jds-chat-send svg{width:18px;height:18px;}

.jds-chat-foot{
  padding:0 var(--chat-pad) var(--chat-pad);
  background:var(--chat-surface);
  font-size:var(--chat-label-size);
  line-height:1.5;
  color:var(--chat-ink-soft);
}
.jds-chat-foot a{color:var(--chat-accent-ink);font-weight:600;}

/* ---------- Accessibility helpers ---------- */
.jds-chat-sr{
  position:absolute;width:1px;height:1px;
  padding:0;margin:-1px;overflow:hidden;
  clip:rect(0 0 0 0);white-space:nowrap;border:0;
}
.jds-chat-launcher:focus-visible,
.jds-chat-send:focus-visible,
.jds-chat-chip:focus-visible,
.jds-chat-head__close:focus-visible{
  outline:2px solid var(--chat-accent);outline-offset:2px;
}

@media (prefers-reduced-motion:reduce){
  .jds-chat-panel,.jds-chat-launcher{transition:none;}
  .jds-chat-launcher:hover{transform:none;}
  .jds-chat-typing span{animation:none;}
}
