/* ============================================================
   Support Chat Widget — Styles
   ============================================================ */

:root {
  --sc-accent:        #6366f1;
  --sc-accent-dark:   #4f46e5;
  --sc-accent-light:  #a5b4fc;
  --sc-bg:            #ffffff;
  --sc-bg-2:          #f8f9ff;
  --sc-surface:       rgba(255,255,255,0.85);
  --sc-border:        rgba(99,102,241,0.15);
  --sc-text:          #1e1b4b;
  --sc-text-muted:    #6b7280;
  --sc-shadow:        0 20px 60px rgba(99,102,241,0.25), 0 4px 16px rgba(0,0,0,0.08);
  --sc-radius:        20px;
  --sc-radius-sm:     12px;
  --sc-radius-xs:     8px;
  --sc-agent-bg:      linear-gradient(135deg,#6366f1,#8b5cf6);
  --sc-visitor-bg:    #f0f0ff;
  --sc-transition:    cubic-bezier(0.34,1.56,0.64,1);
  --sc-font:          'Segoe UI', system-ui, -apple-system, sans-serif;
  --sc-z:             999999;
}

/* ── Root ─────────────────────────────────────────────── */
#sc-root {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--sc-z);
  font-family: var(--sc-font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--sc-text);
}

/* ── Launcher button ──────────────────────────────────── */
#sc-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  box-shadow: 0 8px 30px rgba(99,102,241,0.55), 0 2px 8px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.35s var(--sc-transition),
              box-shadow 0.3s ease;
  outline: none;
}

#sc-launcher:hover {
  transform: scale(1.1) rotate(-5deg);
  box-shadow: 0 12px 40px rgba(99,102,241,0.65), 0 4px 12px rgba(0,0,0,0.2);
}

#sc-launcher:active {
  transform: scale(0.95);
}

#sc-launcher svg {
  width: 26px;
  height: 26px;
  color: #fff;
  position: absolute;
  transition: opacity 0.25s ease, transform 0.3s var(--sc-transition);
}

.sc-icon-chat { opacity: 1; transform: scale(1) rotate(0deg); }
.sc-icon-close { opacity: 0; transform: scale(0.5) rotate(90deg); }

#sc-root.is-open .sc-icon-chat  { opacity: 0; transform: scale(0.5) rotate(-90deg); }
#sc-root.is-open .sc-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

/* Notification badge */
.sc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f43f5e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
  animation: sc-bounce-in 0.4s var(--sc-transition);
}

@keyframes sc-bounce-in {
  0%   { transform: scale(0); }
  100% { transform: scale(1); }
}

/* Pulse ring */
#sc-launcher::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,0.5);
  animation: sc-pulse 2.5s ease-out infinite;
}

@keyframes sc-pulse {
  0%   { opacity: 0.8; transform: scale(1); }
  70%  { opacity: 0;   transform: scale(1.4); }
  100% { opacity: 0;   transform: scale(1.4); }
}

#sc-root.is-open #sc-launcher::before { animation: none; opacity: 0; }

/* ── Window ───────────────────────────────────────────── */
#sc-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 370px;
  max-height: 560px;
  border-radius: var(--sc-radius);
  background: var(--sc-bg);
  box-shadow: var(--sc-shadow);
  border: 1px solid var(--sc-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;

  /* closed */
  transform: scale(0.8) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s var(--sc-transition),
              opacity   0.35s ease;
}

#sc-root.is-open #sc-window {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ── Header ───────────────────────────────────────────── */
.sc-header {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.sc-header::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.sc-header-avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.sc-header-avatar svg { width: 44px; height: 44px; }

.sc-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sc-header-title {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sc-header-status {
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sc-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
  animation: sc-blink 2s ease-in-out infinite;
}

@keyframes sc-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Screen helpers ───────────────────────────────────── */
/* [hidden] must override flex/block — important for jQuery .prop('hidden') */
[hidden] { display: none !important; }

.sc-screen { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Pre-chat form ────────────────────────────────────── */
#sc-prechat {
  padding: 24px 20px;
  background: var(--sc-bg-2);
}

.sc-prechat-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sc-greeting {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--sc-text);
  line-height: 1.55;
}

#sc-prechat input {
  border: 1.5px solid rgba(99,102,241,0.2);
  border-radius: var(--sc-radius-xs);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--sc-font);
  color: var(--sc-text);
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#sc-prechat input:focus {
  border-color: var(--sc-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

#sc-start-btn {
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--sc-radius-xs);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: transform 0.2s var(--sc-transition), box-shadow 0.2s ease;
}

#sc-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.4);
}

/* ── Messages ─────────────────────────────────────────── */
#sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--sc-bg-2);
}

#sc-messages::-webkit-scrollbar { width: 4px; }
#sc-messages::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,0.25);
  border-radius: 4px;
}

/* Bubble */
.sc-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  animation: sc-pop-in 0.3s var(--sc-transition);
  word-break: break-word;
}

@keyframes sc-pop-in {
  0%   { opacity: 0; transform: scale(0.85) translateY(6px); }
  100% { opacity: 1; transform: scale(1)    translateY(0); }
}

.sc-bubble--agent {
  align-self: flex-start;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  border-bottom-left-radius: 4px;
}

.sc-bubble--visitor {
  align-self: flex-end;
  background: var(--sc-visitor-bg);
  color: var(--sc-text);
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(99,102,241,0.1);
}

.sc-bubble-meta {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 3px;
  display: block;
  text-align: right;
}

.sc-bubble--agent .sc-bubble-meta { text-align: left; }

/* ── Typing indicator ─────────────────────────────────── */
.sc-typing {
  align-self: flex-start;
  background: linear-gradient(135deg,#6366f1,#7c3aed);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 16px;
  margin: 0 16px 8px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.sc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.8);
  animation: sc-typing-dot 1.2s ease-in-out infinite;
}
.sc-typing span:nth-child(2) { animation-delay: 0.2s; }
.sc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sc-typing-dot {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.5; }
  30%            { transform: translateY(-5px); opacity: 1;   }
}

/* ── Input area ───────────────────────────────────────── */
.sc-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid rgba(99,102,241,0.1);
  flex-shrink: 0;
}

#sc-input {
  flex: 1;
  border: 1.5px solid rgba(99,102,241,0.2);
  border-radius: var(--sc-radius-xs);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--sc-font);
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  color: var(--sc-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#sc-input:focus {
  border-color: var(--sc-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

#sc-send {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s var(--sc-transition), box-shadow 0.2s ease;
}

#sc-send:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(99,102,241,0.5);
}

#sc-send svg { width: 18px; height: 18px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  #sc-root { bottom: 16px; right: 16px; }
  #sc-window { width: calc(100vw - 32px); max-height: 75vh; }
}
