/* StudioChat — Frontend v1.0.0 */
:root {
  --sc-primary:  #1a1a2e;
  --sc-accent:   #4363b7;
  --sc-accent2:  #0f3460;
  --sc-light:    #ffffff;
  --sc-bg:       #f8f9ff;
  --sc-bub-a:    #ffffff;
  --sc-bub-v:    #4363b7;
  --sc-size:     64px;
  --sc-x:        80px;
  --sc-y:        24px;
  --sc-radius:   0;
  --sc-font:     inherit;
  --sc-shadow:   0 24px 64px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.12);
  --sc-ease:     cubic-bezier(0.34,1.56,0.64,1);
}

/* ── Launcher ─────────────────────────────────────────────── */
#sc-launcher {
  position: fixed;
  bottom: var(--sc-y);
  right:  var(--sc-x);
  width:  var(--sc-size);
  height: var(--sc-size);
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 99998;
  background: transparent;
  outline: none;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s var(--sc-ease);
}
#sc-launcher.sc-left { right:auto; left:var(--sc-x); }
#sc-launcher:hover  { transform: scale(1.08); }
#sc-launcher:active { transform: scale(0.94); }

#sc-launcher .sc-avatar-wrap {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  overflow: hidden;   /* clips the image into a circle — works in all browsers */
  background: #fff;
  z-index: 1;
  flex-shrink: 0;
}
#sc-launcher .sc-avatar {
  width: 100%; height: 100%;
  border-radius: 0;   /* parent handles clipping */
  object-fit: cover;
  display: block;
  border: none;
}
#sc-launcher .sc-avatar-icon {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  background: linear-gradient(135deg, var(--sc-accent2), var(--sc-accent));
  box-shadow: 0 8px 28px rgba(67,99,183,0.4);
  border: none;
  z-index: 1;
}

/* Pulse rings — perfectly centered on avatar */
.sc-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width:  var(--sc-size);
  height: var(--sc-size);
  transform: translate(-50%, -50%) scale(1);
  border-radius: 50%;
  border: 2px solid var(--sc-accent);
  opacity: 0;
  animation: sc-pulse 2.6s ease-out infinite;
  pointer-events: none;
  z-index: 0;
}
.sc-pulse:nth-child(2) { animation-delay: 1.3s; }
@keyframes sc-pulse {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: .65; }
  70%  { transform: translate(-50%, -50%) scale(1.55); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1.55); opacity: 0; }
}

/* Notification dot */
.sc-dot {
  position: absolute; top:1px; right:1px;
  width:15px; height:15px;
  background: #4363b7; border-radius:50%;
  border: 2.5px solid #fff;
  animation: sc-pop .4s var(--sc-ease) .8s both;
}
@keyframes sc-pop { from{transform:scale(0)} to{transform:scale(1)} }

/* ── Greeting bubble ──────────────────────────────────────── */
#sc-greeting {
  position: fixed;
  bottom: calc(var(--sc-y) + var(--sc-size) + 14px);
  right: var(--sc-x);
  max-width: 240px;
  background: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 14px 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.14);
  font-family: var(--sc-font);
  font-size: 14px;
  color: #1e1b4b;
  line-height: 1.45;
  z-index: 99997;
  cursor: pointer;
  transform: translateY(12px) scale(.94);
  transform-origin: bottom right;
  opacity: 0;
  transition: opacity .3s ease, transform .35s var(--sc-ease);
  pointer-events: none;
}
#sc-greeting.sc-left { right:auto;left:var(--sc-x); border-radius:18px 18px 18px 4px; transform-origin:bottom left; }
#sc-greeting.sc-visible { opacity:1; transform:translateY(0) scale(1); pointer-events:all; }
#sc-greeting .sc-greet-avatar {
  width:28px;height:28px;border-radius:50%;object-fit:cover;
  margin-right:8px;flex-shrink:0;vertical-align:middle;
  border:2px solid var(--sc-accent);
}
#sc-greeting .sc-greet-close {
  position:absolute;top:-7px;right:-7px;
  width:20px;height:20px;border-radius:50%;
  background:#6b7280;border:none;color:#fff;
  font-size:11px;cursor:pointer;display:flex;align-items:center;justify-content:center;
  padding:0;line-height:1;
}

/* ── Chat Window ──────────────────────────────────────────── */
#sc-window {
  position: fixed;
  bottom: calc(var(--sc-y) + var(--sc-size) + 16px);
  right:  var(--sc-x);
  width: 380px;
  max-height: 600px;
  border-radius: var(--sc-radius);
  background: #fff;
  box-shadow: var(--sc-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  font-family: var(--sc-font);
  overflow: hidden;
  transform: scale(.88) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform .35s var(--sc-ease), opacity .25s ease;
}
#sc-window.sc-left { right:auto;left:var(--sc-x); transform-origin:bottom left; }
#sc-window.sc-open { transform:scale(1) translateY(0); opacity:1; pointer-events:all; }

/* Header */
.sc-header {
  background: #000;
  padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; position: relative;
}
.sc-header-avatar {
  width:64px;height:64px;
  flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:28px;
  overflow:hidden;
}
.sc-header-avatar img { width:100%;height:100%;object-fit:contain;border-radius:0; }
.sc-header-info { flex:1;min-width:0; }
.sc-header-title {
  color:#fff;font-size:15px;font-weight:700;
  letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.sc-header-sub {
  color:rgba(255,255,255,.75);font-size:12px;margin-top:2px;
  display:flex;align-items:center;gap:5px;
}
.sc-status-dot {
  width:7px;height:7px;border-radius:50%;background:#86efac;flex-shrink:0;
  box-shadow:0 0 0 2px rgba(134,239,172,.3);
}
.sc-header-actions { display:flex;gap:6px;flex-shrink:0; }
.sc-hbtn {
  width:32px;height:32px;border-radius:8px;border:none;cursor:pointer;
  background:transparent;color:#fff;
  display:flex;align-items:center;justify-content:center;
  transition:opacity .2s;
}
.sc-hbtn:hover { opacity:.75; }
/* Voice ON — subtle active indicator, no underline */
.sc-hbtn.voice-on { opacity:1; }
/* Voice OFF — dimmed */
.sc-voice-btn:not(.voice-on) { opacity:.45; }

/* Messages */
.sc-messages {
  flex:1;overflow-y:auto;padding:16px 14px;
  background:var(--sc-bg);display:flex;flex-direction:column;gap:10px;
  scroll-behavior:smooth;
}
.sc-messages::-webkit-scrollbar{width:3px}
.sc-messages::-webkit-scrollbar-thumb{background:#d1d5db;border-radius:3px}

.sc-msg { display:flex;align-items:flex-end;gap:8px;animation:sc-in .3s ease; }
.sc-msg.sc-user { flex-direction:row-reverse; }
@keyframes sc-in { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

.sc-msg-av {
  width:28px;height:28px;border-radius:50%;flex-shrink:0;overflow:hidden;
  background:linear-gradient(135deg,var(--sc-accent2),var(--sc-accent));
  display:flex;align-items:center;justify-content:center;
}
.sc-msg-av img { width:100%;height:100%;object-fit:cover; }


.sc-bubble {
  max-width:78%;padding:10px 14px;border-radius:18px;
  font-size:14px;line-height:1.5;word-break:break-word;
}
.sc-msg:not(.sc-user) .sc-bubble {
  background:var(--sc-bub-a);color:#1e1b4b;
  border-bottom-left-radius:4px;
  box-shadow:0 1px 4px rgba(0,0,0,.07);
}
.sc-msg.sc-user .sc-bubble {
  background:var(--sc-bub-v);color:#fff;
  border-bottom-right-radius:4px;
}
.sc-bubble.sc-live-badge::before {
  content:'LIVE AGENT';display:block;
  font-size:9px;font-weight:800;letter-spacing:.08em;
  color:var(--sc-accent);margin-bottom:3px;opacity:.8;
}

/* Typing dots */
.sc-typing { display:flex;gap:4px;padding:12px 14px;background:var(--sc-bub-a);
  border-radius:18px;border-bottom-left-radius:4px;
  box-shadow:0 1px 4px rgba(0,0,0,.07);width:fit-content; }
.sc-typing span { width:7px;height:7px;background:#c7d0e8;border-radius:50%;
  animation:sc-bounce 1.3s ease-in-out infinite; }
.sc-typing span:nth-child(2){animation-delay:.15s}
.sc-typing span:nth-child(3){animation-delay:.3s}
@keyframes sc-bounce{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(-6px)}}

/* Starters */
.sc-starters { display:flex;flex-wrap:wrap;gap:7px;padding:4px 0 2px; }
.sc-starter {
  padding:7px 13px;border-radius:20px;border:1.5px solid var(--sc-accent);
  background:rgba(67,99,183,.07);color:var(--sc-accent);
  font-size:12px;font-weight:500;cursor:pointer;
  transition:background .2s,transform .15s;white-space:nowrap;
}
.sc-starter:hover { background:var(--sc-accent);color:#fff;transform:translateY(-1px); }

/* Banner */
.sc-banner {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
  animation: sc-in .4s ease;
  flex-shrink: 0;
  transition: transform .2s, box-shadow .2s;
  line-height: 0; /* removes gap below img */
}
.sc-banner:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.sc-banner a     { display: block; line-height: 0; }
.sc-banner img   { width: 100%; height: auto; min-height: 100px; display: block; border-radius: 12px; object-fit: cover; }
.sc-banner-x {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.45); color: #fff;
  border: none; border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer; font-size: 12px; line-height: 22px;
  text-align: center; padding: 0;
  transition: background .15s;
}
.sc-banner-x:hover { background: rgba(0,0,0,.7); }

/* Speaking bar */
.sc-speak-bar{display:none;align-items:center;justify-content:center;gap:4px;padding:6px 0 2px}
.sc-speak-bar.on{display:flex}
.sc-speak-bar span{display:inline-block;width:3px;background:var(--sc-accent);
  border-radius:3px;animation:sc-speak .7s ease-in-out infinite alternate}
.sc-speak-bar span:nth-child(1){height:8px;animation-delay:0s}
.sc-speak-bar span:nth-child(2){height:16px;animation-delay:.1s}
.sc-speak-bar span:nth-child(3){height:22px;animation-delay:.2s}
.sc-speak-bar span:nth-child(4){height:16px;animation-delay:.3s}
.sc-speak-bar span:nth-child(5){height:8px;animation-delay:.4s}
@keyframes sc-speak{from{transform:scaleY(.4)}to{transform:scaleY(1)}}

/* Live mode indicator */
.sc-live-indicator {
  background:linear-gradient(90deg,#065f46,#059669);
  color:#fff;font-size:12px;font-weight:600;
  padding:7px 14px;text-align:center;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;gap:6px;
}
.sc-live-dot{width:7px;height:7px;background:#86efac;border-radius:50%;
  animation:sc-pulse-sm 1.4s ease infinite}
@keyframes sc-pulse-sm{0%,100%{opacity:1}50%{opacity:.4}}

/* Input area */
.sc-input-area { padding:12px 14px;background:#fff;border-top:1px solid #eef0f8;flex-shrink:0; }
.sc-input-row {
  display:flex;align-items:center;gap:8px;
  background:var(--sc-bg);border:1.5px solid #e8eafb;
  border-radius:26px;padding:6px 8px 6px 16px;
  transition:border-color .2s;
}
.sc-input-row:focus-within{border-color:var(--sc-accent)}
#sc-input{
  flex:1;border:none;background:transparent;outline:none;
  font-size:14px;color:#1e1b4b;font-family:var(--sc-font);
  resize:none;max-height:80px;line-height:1.5;
}
#sc-input::placeholder{color:#94a3b8}
.sc-ibtn{
  width:34px;height:34px;border-radius:50%;border:none;
  cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;
  transition:transform .15s,opacity .15s;
}
.sc-ibtn:hover{transform:scale(1.1)}
.sc-ibtn:active{transform:scale(.95)}
.sc-mic{background:transparent;color:#94a3b8}
.sc-mic.recording{background:#eff6ff;color:#4363b7;animation:sc-mic-pulse 1s ease infinite}
@keyframes sc-mic-pulse{0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,.3)}50%{box-shadow:0 0 0 6px rgba(239,68,68,0)}}
.sc-send{background:linear-gradient(135deg,var(--sc-accent2),var(--sc-accent));color:#fff}
.sc-send:disabled{opacity:.4;cursor:not-allowed;transform:none}

.sc-input-footer{text-align:center;font-size:10.5px;color:#94a3b8;margin-top:8px}
.sc-input-footer a{color:var(--sc-accent);text-decoration:none}

/* Live chat request button */
.sc-live-btn-wrap{padding:0 14px 10px;display:flex;gap:8px;align-items:center}
.sc-live-btn{
  width:100%;padding:10px 0;border-radius:24px;
  border:1.5px solid var(--sc-accent);
  background:transparent;color:var(--sc-accent);
  font-size:13px;font-weight:600;cursor:pointer;
  display:flex;align-items:center;justify-content:center;gap:7px;
  transition:background .2s,color .2s;
}
.sc-live-btn:hover{background:var(--sc-accent);color:#fff}

/* ── Responsive ───────────────────────────────────────────── */
@media(max-width:480px){
  #sc-window{
    width:calc(100vw - 16px);left:8px;right:8px;
    bottom:90px;max-height:72vh;transform-origin:bottom center;
  }
  #sc-window.sc-left{left:8px;right:8px}
  #sc-launcher{bottom:18px;right:14px}
  #sc-launcher.sc-left{right:auto;left:14px}
  #sc-greeting{right:8px;left:8px;max-width:none}
}

/* ── Font Awesome icon sizing inside widget buttons ────── */
.sc-hbtn i, .sc-ibtn i { font-size:15px; pointer-events:none; }
.sc-hbtn i  { color:#fff; }
.sc-ibtn.sc-send i { color:#fff; font-size:14px; }
.sc-ibtn.sc-mic  i { font-size:16px; }
.sc-msg-av i { font-size:13px; color:#fff; }
.sc-live-btn i { font-size:14px; }
