/* =============================================================================
   billchat.css — "Chat with @dollarbill" live-chat POPUP for the /users hub
   (THE PRINCE OF PROXY). A faithful clone of fragchat.css (same component/UI),
   scoped under .bc-* / #bc* so it can never collide with fragchat's .fc-* or
   usernames.css. Every colour is drawn from the shared theme.css palette so it
   re-themes for free across wtf / dark. Motion is transform/opacity only and is
   disabled wholesale under reduced-motion.

   AVATAR. @dollarbill has NO staged avatar yet, so the launcher/header/gate use
   a tasteful 👑 CREST monogram (the "Prince of Proxy" mark) drawn in CSS — swap
   .bc-crest for a real <img> once an avatar is staged.
   ========================================================================== */

#bcRoot, .bc-root{
  position:fixed !important; right:20px; bottom:20px; z-index:120;
  font-family:var(--font-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif);
}

/* ---- the 👑 CREST monogram (placeholder avatar) ------------------------- */
.bc-crest{
  display:inline-flex; align-items:center; justify-content:center;
  border-radius:50%;
  background:
    radial-gradient(120% 120% at 50% 18%, #ffe9ad, #e7b23a 46%, #a8781f 78%, #6e4c12);
  color:#3a2708; line-height:1;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.5), inset 0 -3px 6px rgba(0,0,0,.35);
  overflow:hidden; text-align:center;
}
.bc-crest span{ filter:drop-shadow(0 1px 0 rgba(0,0,0,.25)); }

/* ---------------------------------------------------------------------------
   LAUNCHER BUBBLE — the always-there "Chat with @dollarbill" pill.
   ------------------------------------------------------------------------ */
.bc-launcher{
  display:inline-flex; align-items:center; gap:11px;
  padding:9px 18px 9px 9px;
  border-radius:999px;
  background:linear-gradient(140deg, var(--p300), var(--p400) 60%, var(--p500));
  border:1px solid var(--p600);
  color:var(--on-accent);
  box-shadow:0 12px 30px color-mix(in srgb, var(--p400) 45%, transparent),
             0 0 0 1px rgba(255,255,255,.08) inset;
  transform-origin:bottom right;
  animation:bcLaunchIn .4s cubic-bezier(.2,.85,.3,1) both;
  transition:transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.bc-launcher:hover{
  transform:translateY(-2px);
  box-shadow:0 16px 40px color-mix(in srgb, var(--p400) 60%, transparent), 0 0 0 1px rgba(255,255,255,.14) inset;
  filter:brightness(1.04);
}
.bc-launcher:active{ transform:translateY(0); }
.bc-launcher.is-hidden{ display:none; }

.bc-launcher-ic{
  position:relative; flex:0 0 auto;
  width:38px; height:38px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  background:radial-gradient(120% 120% at 50% 20%, var(--raised), var(--void));
  border:2px solid rgba(255,255,255,.55); overflow:visible;
}
.bc-launcher-ic .bc-crest{ width:30px; height:30px; font-size:16px; }
.bc-launcher-online{
  position:absolute; right:-1px; bottom:-1px;
  width:11px; height:11px; border-radius:50%;
  background:var(--gain); border:2px solid var(--p400);
  box-shadow:0 0 8px var(--gain);
  animation:bcBlip 2.2s ease-in-out infinite;
}
.bc-launcher-txt{ display:flex; flex-direction:column; line-height:1.15; text-align:left; }
.bc-launcher-txt b{ font-size:14px; font-weight:800; letter-spacing:.01em; }
.bc-launcher-sub{ font-size:10.5px; opacity:.86; letter-spacing:.02em; }

.bc-launcher::after{
  content:""; position:absolute; inset:0; border-radius:999px;
  border:1.5px solid var(--p500); opacity:0; pointer-events:none;
  animation:bcPing 3.4s ease-out infinite;
}

/* ---------------------------------------------------------------------------
   PANEL — the chat window itself.
   ------------------------------------------------------------------------ */
#bcPanel, .bc-panel{
  position:fixed !important; top:74px; right:20px; left:auto; bottom:auto;
  width:clamp(360px, 33vw, 480px);
  height:min(620px, calc(100vh - 110px));
  display:flex; flex-direction:column; overflow:hidden;
  background:var(--panel);
  border:1px solid var(--hairline-2);
  border-radius:18px;
  box-shadow:0 30px 80px rgba(0,0,0,.6), 0 0 0 1px color-mix(in srgb, var(--p400) 8%, transparent);
  transform-origin:top right;
  z-index:130;
}
.bc-panel{
  transform:translateY(-10px) scale(.96); opacity:0;
  transition:transform .22s cubic-bezier(.2,.85,.3,1), opacity .18s ease;
}
.bc-panel.is-in{ transform:none; opacity:1; }
.bc-panel[hidden]{ display:none !important; }
.bc-head{ cursor:move; user-select:none; -webkit-user-select:none; }
.bc-head .bc-icobtn{ cursor:pointer; }

/* ---- header ------------------------------------------------------------- */
.bc-head{
  display:flex; align-items:center; gap:10px;
  padding:11px 12px;
  background:
    radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--p400) 18%, transparent), transparent 60%),
    var(--raised);
  border-bottom:1px solid var(--hairline-2);
}
.bc-head-pfp{ position:relative; flex:0 0 auto; width:38px; height:38px; }
.bc-head-pfp .bc-crest{
  width:38px; height:38px; font-size:20px;
  border:2px solid var(--p400);
}
.bc-head-online{
  position:absolute; right:-1px; bottom:-1px;
  width:10px; height:10px; border-radius:50%;
  background:var(--gain); border:2px solid var(--raised);
  box-shadow:0 0 7px var(--gain);
  animation:bcBlip 2.2s ease-in-out infinite;
}
.bc-head-meta{ flex:1 1 auto; min-width:0; display:flex; flex-direction:column; gap:1px; }
.bc-head-id{ color:var(--ink-hi); font-weight:800; font-size:15px; letter-spacing:.01em; display:inline-flex; align-items:center; gap:6px; }
.bc-head-badge{
  display:inline-block; padding:1px 7px;
  font-size:8.5px; font-weight:900; letter-spacing:.12em; vertical-align:middle;
  color:#3a2708; background:linear-gradient(180deg,#ffe9ad,#e0b247); border-radius:999px;
}
.bc-head-sub{
  color:var(--gain); font-size:10.5px; letter-spacing:.02em;
  display:inline-flex; align-items:center; gap:6px;
}
.bc-head-btns{ flex:0 0 auto; display:inline-flex; gap:2px; }
.bc-icobtn{
  width:30px; height:30px; border-radius:8px;
  display:inline-flex; align-items:center; justify-content:center;
  color:var(--ink-lo); font-size:20px; line-height:1;
  transition:background .14s ease, color .14s ease;
}
.bc-icobtn:hover{ background:var(--hover); color:var(--ink-hi); }

/* ---- message body ------------------------------------------------------- */
.bc-body{ flex:1 1 auto; min-height:0; display:flex; position:relative; }
.bc-list{
  flex:1 1 auto; min-height:0; overflow-y:auto; overflow-x:hidden;
  padding:14px 12px 6px;
  display:flex; flex-direction:column; gap:9px;
  scrollbar-width:thin;
  background:
    radial-gradient(140% 60% at 90% 0%, color-mix(in srgb, var(--p400) 5%, transparent), transparent 60%),
    var(--void);
}
.bc-list::-webkit-scrollbar{ width:8px; }
.bc-list::-webkit-scrollbar-thumb{ background:var(--hairline-2); border-radius:8px; }

.bc-msg{
  display:flex; align-items:flex-end; gap:8px; max-width:100%;
  animation:bcMsgIn .26s cubic-bezier(.2,.85,.3,1) both;
}
.bc-from-customer{ flex-direction:row-reverse; }
.bc-col{ min-width:0; max-width:80%; display:flex; flex-direction:column; }

.bc-avatar{
  flex:0 0 auto; width:28px; height:28px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  overflow:hidden;
}
.bc-avatar-bill .bc-crest{ width:100%; height:100%; font-size:15px; border:1.5px solid var(--p400); }
.bc-avatar-ai{
  background:var(--raised); border:1px solid var(--hairline-2);
  color:var(--p400);
}

.bc-bubble{
  position:relative;
  padding:8px 12px 6px;
  border-radius:14px;
  font-size:13.5px; line-height:19px;
  color:var(--ink-mid);
  word-wrap:break-word; overflow-wrap:anywhere;
}
.bc-b-name{
  font-size:10px; font-weight:800; letter-spacing:.06em;
  margin-bottom:2px; opacity:.85;
}
.bc-time{
  margin-top:3px; font-size:9.5px; letter-spacing:.02em;
  color:var(--ink-faint); text-align:right;
}

.bc-from-ai .bc-bubble{
  background:var(--raised); border:1px solid var(--hairline);
  border-bottom-left-radius:5px;
}
.bc-from-ai .bc-b-name{ color:var(--p500); }

/* @dollarbill (the human proxy) — accent-tinted, left, emphasized */
.bc-from-bill .bc-bubble{
  background:linear-gradient(180deg, color-mix(in srgb, var(--p400) 16%, transparent), color-mix(in srgb, var(--p400) 9%, transparent));
  border:1px solid color-mix(in srgb, var(--p400) 42%, transparent);
  border-bottom-left-radius:5px;
  color:var(--ink-hi);
  box-shadow:0 2px 10px color-mix(in srgb, var(--p400) 14%, transparent);
}
.bc-from-bill .bc-b-name{ color:var(--p600); }

.bc-from-customer .bc-col{ align-items:flex-end; }
.bc-from-customer .bc-bubble{
  background:linear-gradient(160deg, var(--p400), var(--p300));
  border:1px solid var(--p500);
  color:var(--on-accent);
  border-bottom-right-radius:5px;
  box-shadow:0 4px 14px color-mix(in srgb, var(--p400) 34%, transparent);
}
.bc-from-customer .bc-time{ color:rgba(255,255,255,.7); }

.bc-sys{
  align-self:center; text-align:center; max-width:90%;
  animation:bcMsgIn .26s ease both;
}
.bc-sys-txt{
  display:inline-block; padding:4px 12px;
  font-size:10.5px; letter-spacing:.03em;
  color:var(--ink-faint);
  background:var(--panel); border:1px solid var(--hairline);
  border-radius:999px;
}

/* ---- quick-start chips (what do you want to proxy?) --------------------- */
.bc-chips{ display:flex; flex-wrap:wrap; gap:7px; margin-top:9px; }
.bc-chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:7px 13px; border-radius:999px;
  font-size:12.5px; font-weight:700; letter-spacing:.01em;
  color:var(--ink-hi);
  background:var(--void);
  border:1px solid var(--p500);
  transition:transform .12s ease, box-shadow .16s ease, background .16s ease;
  animation:bcChipIn .3s cubic-bezier(.2,.85,.3,1) both;
}
.bc-chip:hover:not([disabled]){
  background:var(--p400); color:var(--on-accent);
  transform:translateY(-1px);
  box-shadow:0 8px 20px color-mix(in srgb, var(--p400) 50%, transparent);
}
.bc-chip[disabled]{ cursor:default; opacity:.6; }

/* ---- typing indicator --------------------------------------------------- */
.bc-typing{ display:inline-flex; align-items:center; gap:4px; padding:11px 13px; }
.bc-typing-dot{
  width:6px; height:6px; border-radius:50%; background:var(--p500);
  animation:bcType 1.2s ease-in-out infinite;
}
.bc-typing-dot:nth-child(2){ animation-delay:.16s; }
.bc-typing-dot:nth-child(3){ animation-delay:.32s; }

/* ---------------------------------------------------------------------------
   COMPOSER — text input + send.
   ------------------------------------------------------------------------ */
.bc-compose{
  flex:0 0 auto; display:flex; align-items:center; gap:8px;
  padding:10px 11px;
  background:var(--raised);
  border-top:1px solid var(--hairline-2);
}
.bc-input{
  flex:1 1 auto; min-width:0;
  padding:10px 14px; border-radius:999px;
  background:var(--void);
  border:1px solid var(--hairline-2);
  color:var(--ink-hi); font-size:13.5px;
  transition:border-color .14s ease, box-shadow .14s ease;
}
.bc-input::placeholder{ color:var(--ink-faint); }
.bc-input:focus{ border-color:var(--p400); box-shadow:0 0 0 3px color-mix(in srgb, var(--p400) 18%, transparent); }
.bc-input:disabled{ opacity:.6; }
.bc-send{
  flex:0 0 auto; width:40px; height:40px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  color:var(--on-accent);
  background:linear-gradient(140deg, var(--p400), var(--p300));
  border:1px solid var(--p500);
  box-shadow:0 4px 14px color-mix(in srgb, var(--p400) 40%, transparent);
  transition:transform .12s ease, filter .16s ease;
}
.bc-send:hover:not(:disabled){ transform:translateY(-1px) scale(1.04); filter:brightness(1.06); }
.bc-send:active:not(:disabled){ transform:none; }
.bc-send:disabled{ opacity:.45; filter:grayscale(.3); }
.bc-send svg{ margin-left:-1px; }

/* ---------------------------------------------------------------------------
   KEYFRAMES
   ------------------------------------------------------------------------ */
@keyframes bcLaunchIn{ from{ transform:translateY(18px) scale(.8); opacity:0; } to{ transform:none; opacity:1; } }
@keyframes bcMsgIn{ from{ transform:translateY(8px); opacity:0; } to{ transform:none; opacity:1; } }
@keyframes bcChipIn{ from{ transform:translateY(6px) scale(.94); opacity:0; } to{ transform:none; opacity:1; } }
@keyframes bcBlip{ 0%,100%{ opacity:1; } 50%{ opacity:.35; } }
@keyframes bcPing{ 0%{ transform:scale(1); opacity:.5; } 70%,100%{ transform:scale(1.16); opacity:0; } }
@keyframes bcType{ 0%,60%,100%{ transform:translateY(0); opacity:.5; } 30%{ transform:translateY(-4px); opacity:1; } }

/* ---------------------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------------------ */
@media (max-width:480px){
  .bc-root{ right:12px; bottom:12px; }
  .bc-panel{
    width:calc(100vw - 24px);
    height:min(72vh, calc(100vh - 96px));
  }
  .bc-launcher-sub{ display:none; }
}

/* ---------------------------------------------------------------------------
   REDUCED MOTION
   ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce){
  .bc-launcher, .bc-panel, .bc-msg, .bc-sys, .bc-chip,
  .bc-launcher-online, .bc-head-online, .bc-typing-dot, .bc-launcher::after{
    animation:none !important;
    transition:none !important;
  }
  .bc-panel{ transform:none; opacity:1; }
  .bc-launcher-online, .bc-head-online{ opacity:1; }
}
