/* ============================================================
   StagePass / Gita Myanmar — AI Chat Widget  v4.0
   Light theme, list-based quick chat
   ============================================================ */

/* ── Variables ── */
:root {
  --rgm-red:        #DC2626;
  --rgm-red-light:  #EF4444;
  --rgm-red-dark:   #991B1B;
  --rgm-pink:       #FCA5A5;

  --chat-bg:        #FFFFFF;
  --chat-surface:   #F8FAFC;
  --chat-elevated:  #F1F5F9;
  --chat-hover:     #E2E8F0;
  --chat-border:    rgba(0,0,0,0.08);
  --chat-border-red:rgba(220,38,38,0.18);

  --chat-text:      #0F172A;
  --chat-muted:     #64748B;
  --chat-faint:     #94A3B8;

  --chat-gradient:  linear-gradient(135deg, #DC2626 0%, #EF4444 100%);

  --chat-radius:    20px;
  --chat-radius-sm: 12px;
  --chat-radius-xs: 8px;
  --chat-shadow:    0 20px 60px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
}

/* ── FAB Button ── */
#sp-chat-fab {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background-color: #DC2626;
  background-image: linear-gradient(135deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 55%);
  background-size: 200% 200%;
  animation:
    sp-fab-bg-color 6s ease infinite,
    sp-fab-bg-shimmer 3s ease infinite;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.04);
  z-index: 9998;
  opacity: 0;
  transform: scale(0.6) translateY(10px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.25s ease;
  overflow: hidden;
}
#sp-chat-fab::before {
  content: "";
  position: absolute; inset: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.38) 0%, rgba(255,255,255,0) 60%);
  transform: translateX(-100%) rotate(25deg);
  animation: sp-fab-flash 2.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes sp-fab-bg-color {
  0%, 14%   { background-color: #DC2626; }
  18%, 34%  { background-color: #F59E0B; }
  38%, 54%  { background-color: #10B981; }
  58%, 74%  { background-color: #EC4899; }
  78%, 94%  { background-color: #3B82F6; }
  100%      { background-color: #DC2626; }
}
@keyframes sp-fab-bg-shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes sp-fab-flash {
  0% { transform: translateX(-100%) rotate(25deg); opacity: 0; }
  10% { opacity: 0.6; }
  40% { transform: translateX(100%) rotate(25deg); opacity: 0; }
  100% { transform: translateX(100%) rotate(25deg); opacity: 0; }
}
#sp-chat-fab.sp-ready {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}
#sp-chat-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 32px rgba(220,38,38,0.45), 0 0 0 6px rgba(220,38,38,0.08);
}
#sp-chat-fab svg { width: 26px; height: 26px; fill: #fff; transition: transform 0.25s ease, opacity 0.2s ease; }
#sp-chat-fab .sp-fab-icon-chat  { display: block; }
#sp-chat-fab .sp-fab-icon-close { display: none;  }
#sp-chat-fab.open .sp-fab-icon-chat  { display: none;  }
#sp-chat-fab.open .sp-fab-icon-close { display: block; }

#sp-chat-badge {
  position: absolute; top: 0; right: 0;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--chat-gradient); border-radius: 999px;
  border: 2px solid #fff;
  font-size: 0.65rem; font-weight: 800; color: #fff;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(220,38,38,0.35);
}

/* ── Chat Window ── */
#sp-chat-window {
  position: fixed;
  bottom: 96px; right: 24px;
  width: 380px;
  height: min(620px, calc(100dvh - 120px));
  max-height: calc(100dvh - 120px);
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex; flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform: scale(0.92) translateY(14px);
  transform-origin: bottom right;
  opacity: 0; pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.22s ease;
}
#sp-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1; pointer-events: all;
}

/* ── Header ── */
.sp-chat-header {
  background: var(--chat-surface);
  border-bottom: 1px solid var(--chat-border);
  padding: 0.8rem 1rem;
  display: flex; align-items: center; gap: 0.7rem;
  flex-shrink: 0;
}
.sp-chat-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--chat-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 900; color: #fff; letter-spacing: 0.04em; flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(220,38,38,0.25);
}
.sp-chat-header-info { flex: 1; min-width: 0; }
.sp-chat-header-name  { font-weight: 800; font-size: 0.92rem; color: var(--chat-text); }
.sp-chat-header-status {
  font-size: 0.72rem; color: var(--chat-muted);
  display: flex; align-items: center; gap: 0.35rem; margin-top: 0.1rem;
}
.sp-chat-header-status::before {
  content: ""; width: 6px; height: 6px;
  background: #10B981; border-radius: 50%; flex-shrink: 0;
}
.sp-header-btn {
  background: #fff; border: 1px solid var(--chat-border);
  border-radius: 10px;
  width: 32px; height: 32px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--chat-muted); transition: all 0.2s ease; flex-shrink: 0;
}
.sp-header-btn:hover {
  background: var(--chat-elevated); border-color: var(--chat-border-red); color: var(--rgm-red);
}
.sp-header-btn svg { width: 17px; height: 17px; fill: currentColor; }

/* ── View System ── */
.sp-view { display: none; }
.sp-view.active {
  display: flex; flex: 1; flex-direction: column;
  overflow: hidden; min-height: 0;
}

/* ─────────────────── VIEW: HOME / QUICK CHAT LIST ─────────────────── */
#sp-view-home.active { overflow: hidden; }
.sp-home-content {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.15) transparent;
}
.sp-home-content::-webkit-scrollbar       { width: 4px; }
.sp-home-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

.sp-home-intro {
  padding: 1.25rem 1.1rem 0.75rem;
  flex-shrink: 0;
}
.sp-home-intro h3 {
  font-size: 1.1rem; font-weight: 800; color: var(--chat-text); margin-bottom: 0.25rem;
}
.sp-home-intro p {
  font-size: 0.8rem; color: var(--chat-muted); line-height: 1.5;
}

.sp-quick-list {
  flex: 1; overflow-y: auto; padding: 0 0.85rem 0.75rem;
}
.sp-quick-section-title {
  font-size: 0.7rem; font-weight: 800; color: var(--chat-muted); text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.5rem 0.35rem 0.4rem;
}
.sp-quick-item {
  width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--chat-border); border-radius: var(--chat-radius-xs);
  padding: 0.75rem 0.85rem; margin-bottom: 0.45rem;
  display: flex; align-items: center; gap: 0.7rem;
  cursor: pointer; transition: all 0.18s ease;
}
.sp-quick-item:hover {
  border-color: var(--chat-border-red);
  background: #FFF5F5;
  transform: translateX(3px);
}
.sp-quick-item svg {
  width: 18px; height: 18px; flex-shrink: 0; fill: var(--rgm-red-light);
}
.sp-quick-item span {
  font-size: 0.84rem; color: var(--chat-text); font-weight: 600;
}

/* Widget bottom bar */
.sp-widget-bottom { border-top: 1px solid var(--chat-border); background: var(--chat-surface); flex-shrink: 0; }

.sp-home-input-area {
  padding: 0.55rem 0.85rem 0.7rem;
  display: flex; gap: 0.5rem; align-items: center;
  background: var(--chat-surface); flex-shrink: 0;
}
.sp-home-input {
  flex: 1;
  background: #fff;
  border: 1px solid var(--chat-border); border-radius: 999px;
  padding: 0.55rem 1rem; color: var(--chat-text);
  font-size: 0.85rem; font-family: inherit;
  outline: none; transition: all 0.2s ease;
}
.sp-home-input:focus { border-color: var(--chat-border-red); box-shadow: 0 0 0 3px rgba(220,38,38,0.06); }
.sp-home-input::placeholder { color: var(--chat-faint); }
.sp-home-send {
  width: 38px; height: 38px; background: var(--chat-gradient);
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 3px 12px rgba(220,38,38,0.25);
}
.sp-home-send:hover    { transform: scale(1.05); }
.sp-home-send:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.sp-home-send svg { width: 17px; height: 17px; fill: #fff; }

.sp-home-footer { padding: 0.55rem 0.85rem 0.2rem; flex-shrink: 0; }
.sp-human-btn {
  width: 100%;
  background: #fff; border: 1px solid var(--chat-border-red);
  border-radius: var(--chat-radius-xs); padding: 0.65rem 1rem;
  color: var(--rgm-red); font-size: 0.82rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  transition: all 0.2s ease;
}
.sp-human-btn:hover { background: #FFF5F5; }
.sp-human-btn svg { width: 17px; height: 17px; fill: currentColor; }

/* ─────────────────── VIEW: CHAT ─────────────────── */
.sp-chat-messages {
  flex: 1; overflow-y: auto; padding: 0.875rem;
  display: flex; flex-direction: column; gap: 0.75rem;
  scroll-behavior: smooth; min-height: 0;
  background: var(--chat-bg);
}
.sp-chat-messages::-webkit-scrollbar       { width: 4px; }
.sp-chat-messages::-webkit-scrollbar-track { background: transparent; }
.sp-chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

/* Message Bubbles */
.sp-msg {
  display: flex; flex-direction: column; gap: 0.3rem;
  animation: sp-msg-in 0.25s ease both;
  width: 100%;
}
.sp-msg.bot  { align-items: flex-start; }
.sp-msg.user { align-items: flex-end; }
.sp-msg-header { display: flex; align-items: center; gap: 0.4rem; }
.sp-msg.user .sp-msg-header { flex-direction: row-reverse; }

.sp-msg-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--chat-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.5rem; font-weight: 800; color: #fff; letter-spacing: 0.03em;
  flex-shrink: 0;
}
.sp-msg-sender { font-size: 0.68rem; font-weight: 700; color: var(--chat-muted); }
.sp-msg.bot  .sp-msg-sender { color: var(--rgm-red); }
.sp-msg.user .sp-msg-sender { color: rgba(255,255,255,0.75); }

.sp-msg-bubble {
  display: inline-block; max-width: 100%; padding: 0.65rem 0.9rem; border-radius: var(--chat-radius-sm);
  font-size: 0.86rem; line-height: 1.55;
  word-wrap: break-word; word-break: break-word;
  box-sizing: border-box;
}
.sp-msg.bot  .sp-msg-bubble {
  background: var(--chat-elevated);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  border-top-left-radius: 4px;
}
.sp-msg.user .sp-msg-bubble {
  background: var(--chat-gradient);
  color: #fff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(220,38,38,0.2);
}
.sp-msg-time { font-size: 0.64rem; color: var(--chat-faint); padding: 0 0.2rem; }
.sp-msg.user .sp-msg-time { text-align: right; }
.sp-msg.sp-grouped { margin-top: -0.35rem; }
.sp-msg.sp-grouped .sp-msg-header { display: none; }
.sp-msg.sp-grouped .sp-msg-bubble { border-radius: var(--chat-radius-sm); }
.sp-msg.bot .sp-msg-bubble strong { color: var(--rgm-red); font-weight: 700; }
.sp-msg.bot .sp-msg-bubble em     { color: var(--rgm-red-light); }

/* AI action links */
.sp-ai-link {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.55rem; border-radius: 6px; text-decoration: none;
  background: rgba(220,38,38,0.08); border: 1px solid rgba(220,38,38,0.15);
  color: var(--rgm-red); font-size: 0.82em; font-weight: 700;
  transition: all .15s ease; cursor: pointer;
}
.sp-ai-link:hover { background: rgba(220,38,38,0.15); }

/* Typing */
.sp-typing-dots {
  background: var(--chat-elevated); border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius-sm); border-top-left-radius: 4px;
  padding: 0.65rem 1rem; display: inline-flex; gap: 4px; align-items: center;
}
.sp-typing-dot { width: 7px; height: 7px; background: var(--chat-faint); border-radius: 50%; animation: sp-dot-bounce 1.2s ease-in-out infinite; }
.sp-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.sp-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Streaming cursor */
.sp-msg-bubble.sp-streaming::after {
  content: "\25AE";
  display: inline-block; color: var(--rgm-red);
  opacity: 1; animation: sp-cursor-blink 0.7s ease-in-out infinite; margin-left: 1px;
}
@keyframes sp-cursor-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Chat input area */
.sp-chat-input-area {
  padding: 0.75rem 0.85rem; border-top: 1px solid var(--chat-border);
  display: flex; gap: 0.5rem; align-items: flex-end;
  background: var(--chat-surface); flex-shrink: 0;
}
.sp-chat-input {
  flex: 1; background: #fff;
  border: 1px solid var(--chat-border); border-radius: 999px;
  padding: 0.6rem 1rem; color: var(--chat-text); font-size: 0.86rem; font-family: inherit;
  resize: none; outline: none; line-height: 1.4; max-height: 100px; min-height: 40px;
  transition: all 0.2s ease; scrollbar-width: none;
}
.sp-chat-input::-webkit-scrollbar { display: none; }
.sp-chat-input:focus       { border-color: var(--chat-border-red); box-shadow: 0 0 0 3px rgba(220,38,38,0.06); }
.sp-chat-input::placeholder { color: var(--chat-faint); }
.sp-chat-send {
  width: 40px; height: 40px; background: var(--chat-gradient);
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.2s ease;
  box-shadow: 0 3px 12px rgba(220,38,38,0.25);
}
.sp-chat-send:hover    { transform: scale(1.05); }
.sp-chat-send:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.sp-chat-send svg { width: 18px; height: 18px; fill: #fff; }

/* ─────────────────── VIEW: HISTORY ─────────────────── */
.sp-history-header {
  padding: 0.7rem 0.85rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--chat-border); flex-shrink: 0;
  background: var(--chat-surface);
}
.sp-history-header span { font-size: 0.76rem; font-weight: 800; color: var(--chat-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sp-hist-clear-btn {
  background: none; border: none; color: var(--rgm-red); font-size: 0.72rem;
  cursor: pointer; padding: 0.2rem 0.5rem; border-radius: 6px; transition: background 0.2s; font-weight: 700;
}
.sp-hist-clear-btn:hover { background: rgba(220,38,38,0.08); }

.sp-history-list {
  flex: 1; overflow-y: auto; padding: 0.5rem;
  scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.15) transparent; min-height: 0;
  background: var(--chat-bg);
}
.sp-history-list::-webkit-scrollbar       { width: 4px; }
.sp-history-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

.sp-hist-item {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.75rem; border-radius: var(--chat-radius-xs); cursor: pointer;
  transition: all 0.2s ease; border: 1px solid var(--chat-border); margin-bottom: 0.3rem;
  background: #fff;
}
.sp-hist-item:hover  { border-color: var(--chat-border-red); background: #FFF5F5; }
.sp-hist-item.active { border-color: var(--chat-border-red); background: rgba(220,38,38,0.06); }
.sp-hist-icon {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(220,38,38,0.08); border: 1px solid rgba(220,38,38,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; flex-shrink: 0;
}
.sp-hist-info { flex: 1; min-width: 0; }
.sp-hist-preview { font-size: 0.82rem; color: var(--chat-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.15rem; }
.sp-hist-meta   { font-size: 0.68rem; color: var(--chat-faint); }
.sp-hist-empty  { text-align: center; padding: 2.5rem 1rem; color: var(--chat-muted); font-size: 0.82rem; line-height: 1.8; }
.sp-hist-empty-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }

.sp-history-footer { padding: 0.75rem 0.85rem; border-top: 1px solid var(--chat-border); flex-shrink: 0; background: var(--chat-surface); }
.sp-new-chat-btn {
  width: 100%; background: var(--chat-gradient);
  border: none; border-radius: var(--chat-radius-xs);
  padding: 0.7rem; color: #fff; font-size: 0.82rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  transition: all 0.2s ease;
  box-shadow: 0 3px 12px rgba(220,38,38,0.25);
}
.sp-new-chat-btn:hover { opacity: 0.92; }
.sp-new-chat-btn svg { width: 18px; height: 18px; fill: #fff; }

/* ─────────────────── HUMAN SUPPORT VIEW ─────────────────── */
.sp-support-view {
  position: absolute; inset: 0;
  background: var(--chat-bg);
  display: flex; flex-direction: column;
  z-index: 10;
  animation: sp-msg-in 0.2s ease both;
}
.sp-support-view-header {
  background: var(--chat-surface);
  border-bottom: 1px solid var(--chat-border);
  padding: 0.7rem 0.85rem;
  display: flex; align-items: center; gap: 0.6rem;
  flex-shrink: 0;
}
.sp-support-back {
  width: 32px; height: 32px; border-radius: 10px;
  background: #fff; border: 1px solid var(--chat-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: all 0.15s ease; color: var(--chat-muted);
}
.sp-support-back:hover { background: #FFF5F5; border-color: var(--chat-border-red); color: var(--rgm-red); }
.sp-support-back svg { width: 18px; height: 18px; fill: currentColor; }
.sp-support-view-agent { display: flex; align-items: center; gap: 0.6rem; }
.sp-support-view-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #10B981, #059669);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sp-support-view-avatar svg { width: 20px; height: 20px; fill: #fff; }
.sp-support-view-name { font-size: 0.85rem; font-weight: 800; color: var(--chat-text); }
.sp-support-view-status { font-size: 0.72rem; color: var(--chat-muted); display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.sp-sv-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sp-sv-dot.waiting { background: #F59E0B; animation: sp-sv-pulse 1.4s ease-in-out infinite; }
.sp-sv-dot.online  { background: #10B981; }
.sp-sv-dot.offline { background: var(--chat-faint); }
@keyframes sp-sv-pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.sp-support-view-msgs {
  flex: 1; overflow-y: auto; padding: 0.75rem 0.85rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  scroll-behavior: smooth; background: var(--chat-bg);
}
.sp-sv-history-label {
  text-align: center; font-size: 0.68rem; color: var(--chat-faint);
  padding: 0.25rem 0; letter-spacing: 0.04em;
}

.sp-sv-waiting-bar {
  padding: 0.625rem 0.85rem;
  border-top: 1px solid var(--chat-border);
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.78rem; color: var(--chat-muted);
  flex-shrink: 0; background: var(--chat-surface);
}
.sp-sv-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(220,38,38,0.15);
  border-top-color: var(--rgm-red);
  animation: sp-spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes sp-spin { to { transform: rotate(360deg); } }

.sp-sv-typing {
  display: none; flex-direction: row; align-items: center; gap: 5px;
  padding: 4px 0.85rem 2px;
  font-size: 0.72rem; color: var(--chat-muted); font-style: italic;
  flex-shrink: 0; background: var(--chat-bg);
}
.sp-sv-typing-dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--chat-faint);
  animation: sp-dot-bounce 1.2s ease-in-out infinite;
}
.sp-sv-typing-dot:nth-child(2) { animation-delay: .2s; }
.sp-sv-typing-dot:nth-child(3) { animation-delay: .4s; }

.sp-support-view-input {
  border-top: 1px solid var(--chat-border);
  padding: 0.4rem 0.85rem 0.6rem;
  display: flex; flex-direction: column; gap: 0; align-items: stretch;
  flex-shrink: 0; background: var(--chat-surface);
}
.sp-support-view-input-row { display: flex; align-items: flex-end; gap: 0.5rem; }
.sp-support-view-input textarea {
  flex: 1; background: #fff;
  border: 1px solid var(--chat-border); border-radius: 10px;
  padding: 0.55rem 0.75rem; color: var(--chat-text);
  font-size: 16px; outline: none; resize: none;
  max-height: 80px; line-height: 1.45; font-family: inherit;
  transition: all 0.2s ease;
}
.sp-support-view-input textarea:focus { border-color: var(--chat-border-red); box-shadow: 0 0 0 3px rgba(220,38,38,0.06); }
.sp-support-view-input textarea::placeholder { color: var(--chat-faint); }
.sp-support-view-input button {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--chat-gradient); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all 0.15s ease;
  box-shadow: 0 3px 10px rgba(220,38,38,0.25);
}
.sp-support-view-input button:hover   { opacity: 0.9; transform: scale(1.04); }
.sp-support-view-input button:active  { transform: scale(0.95); }
.sp-support-view-input button svg { width: 18px; height: 18px; fill: #fff; }

/* Legacy overlay */
.sp-support-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; animation: sp-msg-in 0.2s ease both;
}
.sp-support-card {
  background: var(--chat-bg); border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius); padding: 1.5rem; margin: 1rem;
  text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  width: 100%;
}
.sp-support-icon  { font-size: 2.25rem; margin-bottom: 0.5rem; }
.sp-support-card h3 { color: var(--chat-text); font-size: 1.05rem; margin: 0 0 0.4rem; }
.sp-support-card p  { color: var(--chat-muted); font-size: 0.8rem; margin: 0 0 1.1rem; line-height: 1.6; }
.sp-support-contacts { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.875rem; }
.sp-support-link {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.7rem 1rem; border-radius: var(--chat-radius-xs);
  font-size: 0.83rem; font-weight: 700; text-decoration: none; transition: background 0.2s;
}
.sp-support-link.email    { background: rgba(220,38,38,0.08); color: var(--rgm-red); border: 1px solid rgba(220,38,38,0.12); }
.sp-support-link.email:hover    { background: rgba(220,38,38,0.14); }
.sp-support-link.telegram { background: rgba(6,182,212,0.06); color: #0891B2; border: 1px solid rgba(6,182,212,0.12); }
.sp-support-link.telegram:hover { background: rgba(6,182,212,0.12); }
.sp-support-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.sp-support-link.email    svg { fill: var(--rgm-red); }
.sp-support-link.telegram svg { fill: #0891B2; }
.sp-support-hours { font-size: 0.73rem; color: var(--chat-faint); margin-bottom: 0.875rem; }
.sp-support-close {
  background: var(--chat-elevated); border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius-xs); padding: 0.6rem 1.5rem;
  color: var(--chat-muted); font-size: 0.83rem; cursor: pointer; transition: all 0.2s;
}
.sp-support-close:hover { background: var(--chat-hover); color: var(--chat-text); }

/* ── Mobile bar adjustments ── */
body.has-mobile-bar #sp-chat-fab    { bottom: calc(68px + env(safe-area-inset-bottom) + 12px); }
body.has-mobile-bar #sp-chat-window { bottom: calc(68px + env(safe-area-inset-bottom) + 80px); }
body.has-mobile-bar #sp-chat-window { max-height: calc(100dvh - 68px - env(safe-area-inset-bottom) - 96px); }

/* ── Animations ── */
@keyframes sp-msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sp-dot-bounce { 0%,80%,100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-5px); opacity: 1; } }

/* ── Close button gap on mobile ── */
@media (max-width: 480px) {
  .sp-btn-close-gap { margin-left: 2px; }
}

/* ── Maximize / Minimize icon toggle ── */
.sp-header-btn .sp-icon-maximize,
.sp-header-btn .sp-icon-minimize { display: block; }

/* ── Maximize backdrop ── */
#sp-chat-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  animation: sp-backdrop-in 0.28s ease both;
}
@keyframes sp-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Maximized — right-side panel ── */
#sp-chat-window.sp-maximized {
  width: 50vw !important; height: 100dvh !important;
  max-height: 100dvh !important; right: 0 !important; bottom: 0 !important;
  border-radius: 0 !important; transform: none !important;
  transition: width 0.3s ease, height 0.3s ease, border-radius 0.3s ease;
  z-index: 10000;
}
body.sp-chat-maximized #sp-chat-fab { display: none; }

/* ── Maximized — Mobile: full screen ── */
@media (max-width: 480px) {
  #sp-chat-window.sp-maximized {
    width: 100vw !important; height: 100dvh !important;
    max-height: 100dvh !important; right: 0 !important; bottom: 0 !important;
    border-radius: 0 !important;
  }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #sp-chat-window {
    width: calc(100vw - 16px);
    height: min(calc(100dvh - 110px), 540px);
    max-height: calc(100dvh - 110px);
    right: 8px; bottom: calc(76px + env(safe-area-inset-bottom));
    border-radius: var(--chat-radius) var(--chat-radius) var(--chat-radius-sm) var(--chat-radius-sm);
  }
  body.has-mobile-bar #sp-chat-window {
    bottom: calc(68px + env(safe-area-inset-bottom) + 76px);
    max-height: calc(100dvh - 68px - env(safe-area-inset-bottom) - 92px);
  }
  #sp-chat-fab { right: 16px; bottom: 20px; width: 56px; height: 56px; }
  body.has-mobile-bar #sp-chat-fab { bottom: calc(68px + env(safe-area-inset-bottom) + 12px); }
}


/* ── Version Toggle Picker ── */
#sp-version-picker {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 280px;
  background: linear-gradient(160deg, #150707 0%, #0F0505 100%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35), 0 0 0 1px rgba(220,38,38,0.08);
  padding: 1rem;
  z-index: 9999;
  display: none;
  transform: scale(0.92) translateY(14px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.22s ease;
}
#sp-version-picker.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.sp-version-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
}
.sp-version-picker__close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}
.sp-version-picker__close:hover {
  background: rgba(255,255,255,0.16);
  color: #fff;
}

.sp-version-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.sp-version-option:last-child { margin-bottom: 0; }
.sp-version-option:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.14);
}
.sp-version-option:active { transform: scale(0.98); }
.sp-version-option.active {
  background: rgba(220,38,38,0.12);
  border-color: rgba(220,38,38,0.45);
  box-shadow: 0 0 20px rgba(220,38,38,0.12);
}

.sp-version-option__icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.sp-version-option.active .sp-version-option__icon {
  background: linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
}
.sp-version-option__icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.sp-version-option__text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sp-version-option__title {
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.sp-version-option__desc {
  color: rgba(255,255,255,0.55);
  font-size: 0.75rem;
}

/* FAB mode icons */
#sp-chat-fab .sp-fab-icon-version {
  position: relative;
  width: 26px; height: 26px;
  display: block;
  z-index: 1;
}
#sp-chat-fab .sp-fab-icon-close { z-index: 1; }
#sp-chat-fab .sp-fab-icon-version .sp-fab-cycle {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  transform: scale(0.6) rotate(-12deg);
  animation: sp-fab-icon-cycle 6s ease-in-out infinite;
}
#sp-chat-fab .sp-fab-icon-version .sp-fab-cycle:nth-child(1) { animation-delay: 0s; }
#sp-chat-fab .sp-fab-icon-version .sp-fab-cycle:nth-child(2) { animation-delay: 1.2s; }
#sp-chat-fab .sp-fab-icon-version .sp-fab-cycle:nth-child(3) { animation-delay: 2.4s; }
#sp-chat-fab .sp-fab-icon-version .sp-fab-cycle:nth-child(4) { animation-delay: 3.6s; }
#sp-chat-fab .sp-fab-icon-version .sp-fab-cycle:nth-child(5) { animation-delay: 4.8s; }
@keyframes sp-fab-icon-cycle {
  0%   { opacity: 0; transform: scale(0.6) rotate(-12deg); }
  4%   { opacity: 1; transform: scale(1.08) rotate(2deg); }
  16%  { opacity: 1; transform: scale(1) rotate(0deg); }
  20%  { opacity: 0; transform: scale(0.85) rotate(8deg); }
  100% { opacity: 0; transform: scale(0.6) rotate(-12deg); }
}

#sp-chat-fab.open .sp-fab-icon-version { display: none; }
#sp-chat-fab.open .sp-fab-icon-close  { display: block; }

#sp-chat-fab.picker-open .sp-fab-icon-version { display: none; }
#sp-chat-fab.picker-open .sp-fab-icon-close { display: block; }

@media (max-width: 640px) {
  #sp-version-picker {
    right: 16px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: calc(100vw - 32px);
    max-width: 320px;
  }
  body.has-mobile-bar #sp-version-picker {
    bottom: calc(68px + env(safe-area-inset-bottom) + 76px);
  }
}

/* Embedded chat mode (chat-rgm domain) */
#sp-chat-window.sp-chat-embedded {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
  border: none;
  transform: none;
  opacity: 1;
  pointer-events: all;
  background: var(--chat-bg);
}
#sp-chat-window.sp-chat-embedded.open {
  transform: none;
}
#sp-chat-window.sp-chat-embedded .sp-chat-header {
  border-radius: 0;
}
#sp-chat-window.sp-chat-embedded .sp-btn-close-gap,
#sp-chat-window.sp-chat-embedded #sp-btn-maximize {
  display: none !important;
}
