/* SmartChat Pro – Widget Styles */
:root {
  --scp-accent:   #2563eb;
  --scp-accent-d: #1d4ed8;
  --scp-bg:       #fff;
  --scp-surface:  #f8fafc;
  --scp-border:   #e2e8f0;
  --scp-text:     #1e293b;
  --scp-text2:    #64748b;
  --scp-radius:   14px;
  --scp-shadow:   0 8px 40px rgba(0,0,0,.15), 0 2px 8px rgba(0,0,0,.08);
}

.scp-sr-only {position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);}

/* ── Widget wrapper ──────────────────────────────────────────────────────── */
.scp-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Launcher ────────────────────────────────────────────────────────────── */
.scp-launcher {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--scp-accent);
  border: none; cursor: pointer;
  box-shadow: 0 4px 18px rgba(37,99,235,.45);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: transform .2s, box-shadow .2s;
}
.scp-launcher:hover { transform: scale(1.07); box-shadow: 0 6px 24px rgba(37,99,235,.55); }
.scp-ico { width: 24px; height: 24px; fill: #fff; }
.scp-ico-close { display: none; }
.scp-launcher[aria-expanded="true"] .scp-ico-chat  { display: none; }
.scp-launcher[aria-expanded="true"] .scp-ico-close { display: block; }
.scp-badge-dot {
  position: absolute; top: -3px; right: -3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #ef4444; border: 2px solid #fff;
}

/* ── Window ──────────────────────────────────────────────────────────────── */
.scp-window {
  position: absolute;
  bottom: 70px; right: 0;
  width: 370px;
  background: var(--scp-bg);
  border-radius: var(--scp-radius);
  box-shadow: var(--scp-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: scp-pop .18s ease;
}
@keyframes scp-pop {
  from { opacity:0; transform:scale(.95) translateY(6px); }
  to   { opacity:1; transform:scale(1)   translateY(0); }
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.scp-win-header {
  background: var(--scp-accent);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  color: #fff;
}
.scp-win-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.scp-win-avatar svg { width:18px; height:18px; fill:#fff; }
.scp-win-name   { font-weight: 600; font-size: 14px; }
.scp-win-status { font-size: 11px; opacity: .8; display:flex; align-items:center; gap:5px; }
.scp-online-dot { width:7px;height:7px;border-radius:50%;background:#4ade80;display:inline-block; }
.scp-win-close  { margin-left:auto; background:none; border:none; color:#fff; cursor:pointer; opacity:.7; font-size:16px; line-height:1; }
.scp-win-close:hover { opacity:1; }

/* ── Messages ────────────────────────────────────────────────────────────── */
.scp-messages {
  flex:1; overflow-y:auto; padding:14px; min-height:240px; max-height:380px;
  display:flex; flex-direction:column; gap:8px;
  background: var(--scp-surface);
}
.scp-msg { display:flex; flex-direction:column; max-width:84%; }
.scp-msg-user      { align-self:flex-end; align-items:flex-end; }
.scp-msg-assistant { align-self:flex-start; }
.scp-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  word-break: break-word;
  line-height: 1.55;
}
.scp-msg-user      .scp-bubble { background: var(--scp-accent); color:#fff; border-bottom-right-radius:3px; }
.scp-msg-assistant .scp-bubble { background:#fff; color:var(--scp-text); border:1px solid var(--scp-border); border-bottom-left-radius:3px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.scp-msg-time { font-size:10px; color:var(--scp-text2); margin-top:3px; padding:0 3px; }

/* ── Typing indicator ────────────────────────────────────────────────────── */
.scp-typing { padding:6px 14px; }
.scp-typing-bubble {
  display:inline-flex; gap:4px;
  background:#fff; border:1px solid var(--scp-border);
  padding:10px 14px; border-radius:14px; border-bottom-left-radius:3px;
}
.scp-typing-bubble span {
  width:7px;height:7px;border-radius:50%;background:#94a3b8;
  animation:scp-bounce .9s infinite;
}
.scp-typing-bubble span:nth-child(2){animation-delay:.15s;}
.scp-typing-bubble span:nth-child(3){animation-delay:.3s;}
@keyframes scp-bounce{0%,60%,100%{transform:translateY(0);}30%{transform:translateY(-6px);}}

/* ── Input ───────────────────────────────────────────────────────────────── */
.scp-input-row {
  display:flex; align-items:flex-end; gap:8px;
  padding:10px 12px; border-top:1px solid var(--scp-border); background:var(--scp-bg);
}
.scp-input {
  flex:1; border:1px solid var(--scp-border); border-radius:10px;
  padding:9px 12px; resize:none; font-family:inherit; font-size:14px;
  line-height:1.5; outline:none; max-height:130px; overflow-y:auto;
  transition:border-color .15s;
}
.scp-input:focus { border-color:var(--scp-accent); }
.scp-send {
  width:38px;height:38px;flex-shrink:0; background:var(--scp-accent); border:none;
  border-radius:10px; cursor:pointer; display:flex; align-items:center; justify-content:center;
  transition:background .15s;
}
.scp-send:hover { background:var(--scp-accent-d); }
.scp-send svg { width:18px;height:18px;fill:#fff; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.scp-win-footer {
  text-align:center; font-size:10px; color:var(--scp-text2);
  padding:5px; border-top:1px solid #f1f5f9; background:var(--scp-bg);
}
.scp-clear-btn { background:none; border:none; color:var(--scp-text2); cursor:pointer; font-size:10px; text-decoration:underline; }

/* ── Dark theme ──────────────────────────────────────────────────────────── */
.scp-theme-dark { --scp-bg:#1e293b; --scp-surface:#0f172a; --scp-border:#334155; --scp-text:#e2e8f0; --scp-text2:#94a3b8; }
.scp-theme-dark .scp-msg-assistant .scp-bubble { background:#1e293b; border-color:#334155; color:#e2e8f0; }
.scp-theme-dark .scp-typing-bubble { background:#1e293b; border-color:#334155; }
.scp-theme-dark .scp-win-footer { border-color:#334155; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media(max-width:420px){
  .scp-window { width:calc(100vw - 16px); right:0; bottom:70px; }
  .scp-widget { right:8px; bottom:8px; }
}

/* ── Rate-limited message bubble ─────────────────────────────────────────── */
.scp-msg-limited .scp-bubble {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
  color: #991b1b !important;
}
.scp-msg-limited .scp-bubble::before {
  content: '⏱ ';
}

/* ── Links inside bot bubbles ────────────────────────────────────────────── */
.scp-msg-assistant .scp-bubble a,
.scp-msg-assistant .scp-bubble a:visited {
  color: var(--scp-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.scp-msg-assistant .scp-bubble a:hover {
  opacity: 0.8;
}
/* Dark theme */
.scp-theme-dark .scp-msg-assistant .scp-bubble a {
  color: #93c5fd;
}
