/* ═══════════════════════════════════════════════════════
   Support Chat Widget
   ═══════════════════════════════════════════════════════ */

#scw-root {
  position: fixed;
  bottom: 40px;
  right: 32px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
}

/* ── Toggle button ──────────────────────────── */
#scw-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  box-shadow: var(--sh-lg);
  transition: all var(--transition, .2s);
  border: none;
  cursor: pointer;
  position: relative;
}
#scw-toggle:hover {
  background: var(--accent-2);
  transform: translateY(-2px);
}
#scw-toggle svg {
  width: 22px;
  height: 22px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#scw-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f59e0b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── Chat window ────────────────────────────── */
#scw-window {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 380px;
  height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: scwSlideUp .25s ease;
}
#scw-window.scw-open { display: flex; }

@keyframes scwSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ─────────────────────────────────── */
#scw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #1e293b;
  color: #fff;
  flex-shrink: 0;
}
#scw-header-title {
  font-weight: 600;
  font-size: 15px;
}
#scw-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
#scw-end {
  background: none;
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
#scw-end:hover { background: rgba(255,255,255,.15); }
#scw-end:disabled { opacity: .4; cursor: default; }
#scw-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  opacity: .7;
  transition: opacity .15s;
}
#scw-close:hover { opacity: 1; }

/* ── Messages ───────────────────────────────── */
#scw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}

.scw-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.scw-msg-user {
  align-self: flex-end;
  background: #e11d48;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.scw-msg-bot {
  align-self: flex-start;
  background: #e2e8f0;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.scw-msg-admin {
  align-self: flex-start;
  background: #dbeafe;
  color: #1e3a5f;
  border-bottom-left-radius: 4px;
}
.scw-msg-system {
  align-self: center;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
  padding: 4px 0;
}
.scw-msg-time {
  font-size: 11px;
  opacity: .5;
  margin-top: 4px;
  display: block;
}

/* ── Typing indicator ───────────────────────── */
#scw-typing {
  display: none;
  padding: 8px 16px;
  color: #94a3b8;
  font-size: 13px;
  font-style: italic;
}
#scw-typing.scw-visible { display: block; }

/* ── Input area ─────────────────────────────── */
#scw-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}
#scw-input {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 80px;
  outline: none;
  transition: border-color .15s;
}
#scw-input:focus { border-color: #e11d48; }
#scw-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #e11d48;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
#scw-send:hover { background: #be123c; }
#scw-send:disabled { background: #cbd5e1; cursor: default; }

/* ── Mobile ─────────────────────────────────── */
@media (max-width: 480px) {
  #scw-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
    bottom: 68px;
    right: -8px;
    border-radius: 12px;
  }
}
