/* ───────────────────────────────────────────────────────────────────────────
   Support Chat — user widget. Self-contained + token-independent so it renders
   identically across all gateway pages (globe.php, entry pages, etc.).
   Namespace: .scw  ·  Agent console reuses these vars + a few .sca- additions.
   ─────────────────────────────────────────────────────────────────────────── */
.scw, .scw *, .scw-fab, .scw-fab *{box-sizing:border-box}
.scw{
  --scw-cyan:#44f1ff; --scw-accent:#2ad1a8;
  --scw-bg:#0b0f18; --scw-panel:#0d1320;
  --scw-stroke:rgba(156,180,255,.14); --scw-stroke2:rgba(156,180,255,.08);
  --scw-text:rgba(240,245,255,.95); --scw-muted:rgba(255,255,255,.55);
  --scw-user:#15455e; --scw-agent:#161c28;
  --scw-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
  --scw-sans:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  position:fixed;inset:0;z-index:2147483600;pointer-events:none;
  font-family:var(--scw-sans);
}

/* ── Floating launcher (bottom-right) ─────────────────────────────────────── */
.scw-fab{
  position:fixed;right:20px;bottom:22px;z-index:2147483600;pointer-events:auto;
  width:58px;height:58px;border-radius:50%;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  border:1px solid rgba(68,241,255,.35);
  background:radial-gradient(120% 120% at 30% 20%,#123042,#0b1018);
  color:var(--scw-cyan);
  box-shadow:0 10px 30px rgba(0,0,0,.45),0 0 0 4px rgba(68,241,255,.05);
  transition:transform .16s ease,box-shadow .16s ease,opacity .2s ease;
  -webkit-tap-highlight-color:transparent;
}
.scw-fab:hover{transform:translateY(-2px);box-shadow:0 14px 34px rgba(0,0,0,.55),0 0 0 5px rgba(68,241,255,.08)}
.scw-fab:active{transform:translateY(0) scale(.97)}
.scw[data-open="true"] ~ .scw-fab{opacity:0;pointer-events:none;transform:scale(.8)}
.scw-fab-badge{
  position:absolute;top:-4px;right:-4px;min-width:20px;height:20px;padding:0 5px;
  display:flex;align-items:center;justify-content:center;
  font-family:var(--scw-mono);font-size:11px;font-weight:800;line-height:1;
  color:#04121a;background:#44f1ff;border-radius:999px;border:2px solid #0b1018;
}

/* ── Welcome teaser (pops up beside the launcher) ─────────────────────────── */
.scw-teaser{
  position:fixed;right:20px;bottom:92px;z-index:2147483500;pointer-events:auto;
  max-width:300px;display:flex;align-items:flex-start;
  background:linear-gradient(168deg,rgba(13,19,32,.99),rgba(8,11,18,.995));
  border:1px solid var(--scw-stroke);border-radius:16px;border-bottom-right-radius:6px;
  box-shadow:0 16px 40px rgba(0,0,0,.5);
  transform:translateY(10px) scale(.96);opacity:0;
  transition:transform .26s cubic-bezier(.22,.8,.2,1),opacity .26s ease;
}
.scw-teaser.is-shown{transform:translateY(0) scale(1);opacity:1}
.scw[data-open="true"] ~ .scw-teaser{opacity:0;pointer-events:none}
.scw-teaser-body{
  display:flex;align-items:flex-start;gap:10px;cursor:pointer;text-align:left;
  background:none;border:none;color:var(--scw-text);font-family:var(--scw-sans);
  padding:13px 30px 13px 13px;
}
.scw-teaser-avatar{
  flex:0 0 auto;width:30px;height:30px;border-radius:50%;font-size:15px;
  display:flex;align-items:center;justify-content:center;
  background:radial-gradient(120% 120% at 30% 20%,#123042,#0b1018);
  border:1px solid rgba(68,241,255,.3);
}
.scw-teaser-text{font-size:13px;line-height:1.5;color:var(--scw-text)}
.scw-teaser-x{
  position:absolute;top:6px;right:6px;width:22px;height:22px;border-radius:50%;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  border:1px solid var(--scw-stroke);background:rgba(8,12,22,.85);color:var(--scw-muted);
  transition:color .14s,border-color .14s;
}
.scw-teaser-x:hover{color:var(--scw-text);border-color:rgba(68,241,255,.4)}
@media (max-width:480px){
  .scw-teaser{right:16px;bottom:84px;max-width:calc(100vw - 80px)}
}

/* ── Panel ────────────────────────────────────────────────────────────────── */
.scw-panel{
  position:fixed;right:20px;bottom:22px;z-index:2147483601;pointer-events:none;
  width:380px;max-width:calc(100vw - 32px);
  height:min(620px,calc(100vh - 110px));
  display:flex;flex-direction:column;overflow:hidden;
  background:linear-gradient(168deg,rgba(13,19,32,.99),rgba(8,11,18,.995));
  border:1px solid var(--scw-stroke);border-radius:16px;
  box-shadow:0 24px 60px rgba(0,0,0,.6);
  transform:translateY(16px) scale(.98);opacity:0;
  transition:transform .22s cubic-bezier(.22,.8,.2,1),opacity .22s ease;
}
/* Non-modal: the container never captures — only the panel does when open, so
   the page behind the chat stays fully interactive. */
.scw[data-open="true"] .scw-panel{transform:translateY(0) scale(1);opacity:1;pointer-events:auto}

/* ── Responsive ───────────────────────────────────────────────────────────────
   Tablets / small laptops: a touch narrower so it never crowds the screen. */
@media (max-width:768px){
  .scw-panel{width:360px;height:min(600px,calc(100vh - 96px))}
}
/* Phones: full-screen sheet, safe-area aware, with a grab handle to close. */
@media (max-width:560px){
  .scw-panel{
    right:0;left:0;bottom:0;top:0;width:auto;max-width:none;height:100dvh;
    border-radius:0;border:none;transform:translateY(100%);  /* slide up from the bottom */
  }
  .scw[data-open="true"] .scw-panel{transform:translateY(0)}
  .scw-fab{
    right:calc(16px + env(safe-area-inset-right,0px));
    bottom:calc(16px + env(safe-area-inset-bottom,0px));
    width:56px;height:56px;
  }
  /* Header gets a bigger close target + clears the notch. */
  .scw-head{padding-top:calc(14px + env(safe-area-inset-top,0px))}
  .scw-close{width:40px;height:40px}
  .scw-close svg{width:20px;height:20px}
  /* Input clears the home indicator. */
  .scw-input{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px))}
  .scw-foot{display:none}            /* save vertical space on small screens */
}
/* While the full-screen sheet is open on a phone, freeze the page behind it. */
html.scw-lock{overflow:hidden;touch-action:none}

/* Header */
.scw-head{
  flex:0 0 auto;display:flex;align-items:center;gap:11px;
  padding:14px 14px 13px;border-bottom:1px solid var(--scw-stroke2);
  background:linear-gradient(180deg,rgba(18,48,66,.55),rgba(13,19,32,0));
}
.scw-head-dot{width:9px;height:9px;border-radius:50%;background:var(--scw-accent);
  box-shadow:0 0 0 3px rgba(42,209,168,.18);flex:0 0 auto}
.scw-head-titles{display:flex;flex-direction:column;line-height:1.25;flex:1 1 auto;min-width:0}
.scw-head-title{font-size:14px;font-weight:700;color:var(--scw-text)}
.scw-head-sub{font-size:11px;color:var(--scw-muted)}
.scw-close{
  flex:0 0 auto;width:30px;height:30px;border-radius:8px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  border:1px solid var(--scw-stroke);background:rgba(8,12,22,.6);color:var(--scw-muted);
  transition:color .14s,border-color .14s,background .14s;
}
.scw-close:hover{color:var(--scw-text);border-color:rgba(68,241,255,.4);background:rgba(68,241,255,.08)}

/* Body / messages */
.scw-body{
  flex:1 1 auto;overflow-y:auto;padding:14px 13px;display:flex;flex-direction:column;gap:9px;
  scrollbar-width:thin;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
}
.scw-body::-webkit-scrollbar{width:7px}
.scw-body::-webkit-scrollbar-thumb{background:rgba(156,180,255,.18);border-radius:4px}
.scw-empty{margin:auto 4px;text-align:center;color:var(--scw-muted)}
.scw-empty-head{font-size:15px;font-weight:700;color:var(--scw-text);margin:0 0 6px}
.scw-empty-sub{font-size:12.5px;line-height:1.5;margin:0}

.scw-msg{max-width:82%;display:flex;flex-direction:column;gap:3px}
.scw-msg.is-user{align-self:flex-end;align-items:flex-end}
.scw-msg.is-agent{align-self:flex-start;align-items:flex-start}
.scw-bubble{
  padding:9px 12px;border-radius:14px;font-size:13.5px;line-height:1.45;
  color:var(--scw-text);word-wrap:break-word;overflow-wrap:anywhere;white-space:pre-wrap;
  border:1px solid var(--scw-stroke);
}
/* Group-chat unread + @-mention badges on the header Groups button. */
.scw-gch-badge{position:absolute;top:-3px;right:-3px;min-width:15px;height:15px;padding:0 4px;display:flex;align-items:center;justify-content:center;
  border-radius:999px;background:#ff5d73;color:#fff;font-size:9px;font-weight:800;border:2px solid var(--scw-bg,#0b0f18);box-shadow:0 0 7px rgba(255,93,115,.6)}
.scw-gch-mbadge{position:absolute;top:-3px;left:-3px;min-width:15px;height:15px;padding:0 4px;display:flex;align-items:center;justify-content:center;
  border-radius:999px;background:#ffb14d;color:#04121a;font-size:9px;font-weight:800;border:2px solid var(--scw-bg,#0b0f18);box-shadow:0 0 7px rgba(255,177,77,.6)}
.scw-gch-mbadge::before{content:'@';margin-right:1px}

/* Colour code: YOU (the customer) = green · Support/admin = blue. */
.scw-msg.is-user .scw-bubble{background:linear-gradient(160deg,#0e6b46,#0a4a30);border-color:rgba(46,209,126,.32);border-bottom-right-radius:5px}
.scw-msg.is-agent .scw-bubble{background:linear-gradient(160deg,#16506e,#103a52);border-color:rgba(68,241,255,.22);border-bottom-left-radius:5px}
/* Optimistic send states */
.scw-msg.is-pending .scw-bubble{opacity:.66}
.scw-msg.is-failed .scw-bubble{background:linear-gradient(160deg,#5a1620,#3f0f17);border-color:rgba(255,93,115,.45);cursor:pointer}
.scw-tick{opacity:.65;margin-left:5px}
.scw-retry{color:#ff8a9a;cursor:pointer}
.scw-meta{font-family:var(--scw-mono);font-size:9.5px;letter-spacing:.04em;color:var(--scw-muted);padding:0 3px}
.scw-day{align-self:center;font-family:var(--scw-mono);font-size:9.5px;letter-spacing:.08em;
  text-transform:uppercase;color:var(--scw-muted);margin:4px 0}

/* Input */
.scw-input{
  flex:0 0 auto;display:flex;align-items:flex-end;gap:8px;
  padding:10px 11px;border-top:1px solid var(--scw-stroke2);background:rgba(8,11,18,.5);
}
.scw-text{
  flex:1 1 auto;min-width:0;resize:none;max-height:120px;
  background:rgba(8,12,22,.7);border:1px solid var(--scw-stroke);border-radius:11px;
  color:var(--scw-text);font-family:var(--scw-sans);font-size:13.5px;line-height:1.4;
  padding:10px 12px;outline:none;transition:border-color .14s;
}
.scw-text:focus{border-color:rgba(68,241,255,.45)}
.scw-text::placeholder{color:var(--scw-muted)}
.scw-send{
  flex:0 0 auto;width:40px;height:40px;border-radius:11px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  border:1px solid rgba(68,241,255,.35);background:rgba(68,241,255,.12);color:var(--scw-cyan);
  transition:background .14s,opacity .14s,transform .1s;
}
.scw-send:hover:not(:disabled){background:rgba(68,241,255,.2)}
.scw-send:active:not(:disabled){transform:scale(.94)}
.scw-send:disabled{opacity:.4;cursor:default}
.scw-foot{
  flex:0 0 auto;padding:7px 12px 9px;text-align:center;
  font-size:10px;color:var(--scw-muted);border-top:1px solid var(--scw-stroke2);
}
.scw-error{
  align-self:center;font-size:11.5px;color:#ff9a9a;background:rgba(255,90,90,.08);
  border:1px solid rgba(255,90,90,.25);border-radius:8px;padding:6px 10px;margin:2px 0;
}

@media (prefers-reduced-motion:reduce){
  .scw-panel,.scw-fab{transition:none}
}

/* ── Pre-chat registration (anonymous visitors) ─────────────────────────────── */
.scw-reg{flex:1;overflow-y:auto;padding:16px 16px 18px;display:flex;flex-direction:column;gap:10px}
.scw-reg-head{margin:2px 0 0;font-size:15px;font-weight:800;color:var(--scw-text)}
.scw-reg-note{margin:0 0 6px;font-size:12.5px;line-height:1.55;color:var(--scw-muted)}
.scw-reg-note strong{color:var(--scw-cyan)}
.scw-reg-form{display:flex;flex-direction:column;gap:9px}
.scw-reg-input{
  width:100%;box-sizing:border-box;padding:11px 12px;border-radius:10px;
  border:1px solid var(--scw-stroke);background:rgba(8,12,22,.7);color:var(--scw-text);
  font-family:var(--scw-sans);font-size:14px;outline:none;transition:border-color .14s;
}
.scw-reg-input:focus{border-color:rgba(68,241,255,.5)}
.scw-reg-input::placeholder{color:rgba(255,255,255,.4)}
.scw-reg-error{font-size:12.5px;color:#ff8095;background:rgba(255,90,120,.08);
  border:1px solid rgba(255,90,120,.2);border-radius:8px;padding:8px 10px}
.scw-reg-submit{
  margin-top:2px;padding:12px 14px;border:none;border-radius:10px;cursor:pointer;
  font-family:var(--scw-sans);font-size:14px;font-weight:800;color:#04121a;
  background:linear-gradient(180deg,#54f4ff,#2ad1a8);transition:filter .14s,opacity .14s;
}
.scw-reg-submit:hover{filter:brightness(1.05)}
.scw-reg-submit:disabled{opacity:.6;cursor:default}

/* Assigned-Gateway-ID confirmation banner shown at the top of a new chat. */
.scw-idbanner{
  margin:0 0 10px;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:1.5;
  color:var(--scw-text);background:rgba(42,209,168,.1);border:1px solid rgba(42,209,168,.3);
}
.scw-idbanner strong{font-family:var(--scw-mono);color:var(--scw-cyan);letter-spacing:.02em}
