/* ============================================================
   ClearTable Assistant - floating chat widget
   Loads after styles.css, so it reuses the site tokens
   (--accent, --green-dark, --sage, --cream). Fallback literals
   are included in case styles.css is ever absent.
   Design: the site's deep greens on cream. Calm and quiet.
   ============================================================ */

.ct-chat{
  --ct-green:var(--accent,#4A7C5C);
  --ct-deep:var(--green-dark,#2F5E43);
  --ct-sage:var(--sage,#E6EFE3);
  --ct-cream:var(--cream,#FFFEF9);
  --ct-line:#dfe6dc;
  --ct-ink:#243329;
  --ct-muted:#5b6660;
  font-family:'Inter',system-ui,-apple-system,sans-serif;
}
.ct-chat svg{display:block;flex:0 0 auto}

/* ---- floating button ------------------------------------- */
.ct-fab{
  position:fixed;
  right:max(20px,env(safe-area-inset-right));
  bottom:max(20px,env(safe-area-inset-bottom));
  z-index:2147483000;
  display:flex;align-items:center;gap:9px;
  height:56px;padding:0 20px 0 18px;
  border:0;border-radius:30px;cursor:pointer;
  background:var(--ct-green);color:#fff;
  font-family:inherit;font-size:15px;font-weight:600;
  box-shadow:0 10px 30px rgba(47,94,67,.30),0 0 0 3px rgba(230,239,227,.55);
  transition:transform .16s ease,box-shadow .16s ease,background .16s ease;
}
.ct-fab:hover{background:var(--ct-deep);transform:translateY(-2px);box-shadow:0 14px 36px rgba(47,94,67,.38),0 0 0 3px rgba(230,239,227,.8)}
.ct-fab:focus-visible{outline:3px solid var(--ct-deep);outline-offset:2px}
.ct-fab .ct-fab-label{white-space:nowrap}
.ct-chat.ct-open .ct-fab{transform:scale(.9);opacity:0;pointer-events:none}
@media(max-width:600px){
  .ct-fab{height:52px;padding:0 16px;gap:0}
  .ct-fab .ct-fab-label{display:none}
}

/* ---- panel ----------------------------------------------- */
.ct-panel{
  position:fixed;
  right:max(20px,env(safe-area-inset-right));
  bottom:max(20px,env(safe-area-inset-bottom));
  z-index:2147483001;
  width:min(378px,calc(100vw - 40px));
  height:min(600px,calc(100vh - 40px));
  max-height:calc(100vh - 40px);
  display:none;flex-direction:column;overflow:hidden;
  background:var(--ct-cream);
  border:1px solid var(--ct-line);
  border-radius:20px;
  box-shadow:0 24px 60px rgba(47,94,67,.30);
  opacity:0;transform:translateY(14px) scale(.98);
  transition:opacity .18s ease,transform .18s ease;
}
.ct-chat.ct-open .ct-panel{display:flex}
.ct-chat.ct-shown .ct-panel{opacity:1;transform:none}
@media(max-width:600px){
  .ct-panel{
    right:8px;left:8px;bottom:8px;top:8px;
    width:auto;height:auto;max-height:none;border-radius:16px;
  }
}

/* header */
.ct-head{
  flex:0 0 auto;display:flex;align-items:center;gap:11px;
  padding:15px 14px 15px 17px;
  background:var(--ct-deep);color:#fff;
}
.ct-head .ct-avatar{
  width:34px;height:34px;flex:0 0 auto;border-radius:50%;
  background:linear-gradient(150deg,#4A7C5C,#3E6B4E);
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 0 0 2px rgba(230,239,227,.55);
  color:#fff;
}
.ct-head .ct-title{flex:1;min-width:0}
.ct-head .ct-title b{display:block;font-family:'Libre Baskerville',Georgia,serif;font-weight:700;font-size:15.5px;line-height:1.2}
.ct-head .ct-title span{display:block;font-size:11.5px;color:#cfe4d5;margin-top:1px}
.ct-close{
  flex:0 0 auto;width:34px;height:34px;border:0;border-radius:9px;cursor:pointer;
  background:rgba(255,255,255,.10);color:#fff;
  display:flex;align-items:center;justify-content:center;transition:background .15s}
.ct-close:hover{background:rgba(255,255,255,.22)}
.ct-close:focus-visible{outline:2px solid var(--ct-sage);outline-offset:2px}

/* notice bar */
.ct-notice{
  flex:0 0 auto;display:flex;gap:8px;align-items:flex-start;
  padding:10px 15px;background:var(--ct-sage);color:#3c5244;
  font-size:11.5px;line-height:1.45;border-bottom:1px solid var(--ct-line)}
.ct-notice svg{color:var(--ct-deep);margin-top:1px}

/* messages */
.ct-msgs{
  flex:1 1 auto;overflow-y:auto;padding:16px 15px 8px;
  display:flex;flex-direction:column;gap:12px;scroll-behavior:smooth}
.ct-msg{max-width:86%;font-size:14px;line-height:1.55;padding:11px 14px;border-radius:15px;word-wrap:break-word;overflow-wrap:anywhere}
.ct-msg a{color:inherit;font-weight:600;text-decoration:underline;overflow-wrap:anywhere}
.ct-msg.ct-bot{align-self:flex-start;background:#fff;color:var(--ct-ink);border:1px solid var(--ct-line);border-bottom-left-radius:5px}
.ct-msg.ct-bot a{color:var(--ct-green)}
.ct-msg.ct-user{align-self:flex-end;background:var(--ct-green);color:#fff;border-bottom-right-radius:5px}
.ct-msg.ct-crisis{border-left:3px solid var(--ct-deep);background:#fff}

/* quick-reply chips + inline link buttons */
.ct-chips{display:flex;flex-wrap:wrap;gap:8px;align-self:flex-start;max-width:100%}
.ct-chip{
  border:1px solid var(--ct-line);background:#fff;color:var(--ct-green);
  font-family:inherit;font-size:12.5px;font-weight:600;cursor:pointer;
  padding:8px 13px;border-radius:20px;transition:background .15s,border-color .15s}
.ct-chip:hover{background:var(--ct-sage);border-color:var(--ct-green)}
.ct-chip:focus-visible{outline:2px solid var(--ct-deep);outline-offset:2px}
.ct-links{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.ct-linkbtn{
  display:inline-flex;align-items:center;gap:6px;
  background:var(--ct-green);color:#fff !important;
  font-size:12.5px;font-weight:600;text-decoration:none !important;
  padding:8px 13px;border-radius:8px;transition:background .15s}
.ct-linkbtn:hover{background:var(--ct-deep)}

/* typing indicator */
.ct-typing{align-self:flex-start;display:none;gap:4px;padding:13px 15px;background:#fff;border:1px solid var(--ct-line);border-radius:15px;border-bottom-left-radius:5px}
.ct-typing.ct-on{display:flex}
.ct-typing span{width:7px;height:7px;border-radius:50%;background:var(--ct-green);opacity:.4;animation:ct-bounce 1.2s infinite ease-in-out}
.ct-typing span:nth-child(2){animation-delay:.15s}
.ct-typing span:nth-child(3){animation-delay:.3s}
@keyframes ct-bounce{0%,60%,100%{transform:translateY(0);opacity:.35}30%{transform:translateY(-5px);opacity:.9}}

/* composer */
.ct-form{flex:0 0 auto;border-top:1px solid var(--ct-line);background:#fff;padding:10px 10px 8px}
.ct-inrow{display:flex;align-items:flex-end;gap:8px}
.ct-input{
  flex:1;resize:none;max-height:110px;min-height:22px;
  font-family:inherit;font-size:14px;line-height:1.45;color:var(--ct-ink);
  border:0;outline:none;background:transparent;padding:8px 6px}
.ct-send{
  flex:0 0 auto;width:40px;height:40px;border:0;border-radius:11px;cursor:pointer;
  background:var(--ct-green);color:#fff;
  display:flex;align-items:center;justify-content:center;transition:background .15s,opacity .15s}
.ct-send:hover{background:var(--ct-deep)}
.ct-send:disabled{opacity:.45;cursor:default}
.ct-send:focus-visible{outline:2px solid var(--ct-deep);outline-offset:2px}
.ct-foot{text-align:center;color:var(--ct-muted);font-size:10.5px;padding:6px 4px 2px;letter-spacing:.02em}

/* reduced motion */
@media (prefers-reduced-motion: reduce){
  .ct-fab,.ct-panel,.ct-send,.ct-chip,.ct-linkbtn{transition:none}
  .ct-typing span{animation:none}
  .ct-msgs{scroll-behavior:auto}
}
