/**
 * Great America Security — WhatsApp Chat Widget (Standalone)
 * Dependency-free drop-in for custom (non-WordPress) websites.
 * Namespace: #gas-chat-widget / .gas-* — no global styles leaked.
 */

/* ============ Widget container ============ */
#gas-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  direction: ltr;
  -webkit-tap-highlight-color: transparent;
}
#gas-chat-widget * { box-sizing: border-box; }

/* ============ Floating launcher ============ */
#gas-chat-widget .gas-chat-launcher {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: #25D366;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45), 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}
#gas-chat-widget .gas-chat-launcher:hover { transform: scale(1.06); }
#gas-chat-widget .gas-chat-launcher svg { width: 32px; height: 32px; fill: #fff; }
#gas-chat-widget .gas-chat-launcher .icon-close { display: none; width: 24px; height: 24px; stroke: #fff; }
#gas-chat-widget .gas-chat-launcher.is-open .icon-chat { display: none; }
#gas-chat-widget .gas-chat-launcher.is-open .icon-close { display: block; }
#gas-chat-widget .gas-chat-launcher.is-open { background: #121849; }

/* Pulsing attention badge */
#gas-chat-widget .gas-radar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #cc0000;
  border: 3px solid #fff;
  animation: gas-pulse 2s infinite;
}
@keyframes gas-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(204, 0, 0, 0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(204, 0, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(204, 0, 0, 0); }
}

/* ============ Proactive teaser bubble ============ */
#gas-chat-widget .gas-proactive-teaser {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 260px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(18, 24, 73, 0.22);
  padding: 14px 36px 14px 14px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: gas-slide-up 0.4s ease;
}
@keyframes gas-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
#gas-chat-widget .gas-proactive-close {
  position: absolute;
  top: 6px;
  right: 10px;
  border: none;
  background: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
#gas-chat-widget .gas-proactive-avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #121849;
  display: flex;
  align-items: center;
  justify-content: center;
}
#gas-chat-widget .gas-proactive-avatar img { width: 100%; height: 100%; object-fit: cover; }
#gas-chat-widget .gas-proactive-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #121849;
  margin-bottom: 3px;
}
#gas-chat-widget .gas-proactive-text { font-size: 12.5px; line-height: 1.45; color: #475569; }

/* ============ Chat window ============ */
#gas-chat-widget .gas-chat-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: #f0f2f5;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(18, 24, 73, 0.32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#gas-chat-widget .gas-chat-window.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Header */
#gas-chat-widget .gas-chat-header {
  background: linear-gradient(135deg, #121849 0%, #1e2566 100%);
  color: #fff;
  padding: 14px 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  border-bottom: 3px solid #cc0000;
}
#gas-chat-widget .gas-header-profile { display: flex; align-items: center; gap: 11px; min-width: 0; }
#gas-chat-widget .gas-header-avatar {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  border: 2px solid #cc0000;
}
#gas-chat-widget .gas-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
#gas-chat-widget .gas-status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #25D366;
  border: 2px solid #fff;
}
#gas-chat-widget .gas-header-info { min-width: 0; }
#gas-chat-widget .gas-header-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#gas-chat-widget .gas-header-subtitle {
  font-size: 11.5px;
  color: #c7cee6;
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 2px;
}
#gas-chat-widget .gas-header-subtitle .online-text { color: #4ade80; font-weight: 600; }
#gas-chat-widget .gas-header-actions { display: flex; gap: 4px; }
#gas-chat-widget .gas-btn-icon {
  background: transparent;
  border: none;
  color: #c7cee6;
  cursor: pointer;
  border-radius: 8px;
  padding: 7px;
  display: flex;
  transition: background 0.15s, color 0.15s;
}
#gas-chat-widget .gas-btn-icon:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* Message stream */
#gas-chat-widget .gas-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px;
  background-color: #f0f2f5;
  background-image: radial-gradient(rgba(18, 24, 73, 0.05) 1px, transparent 1px);
  background-size: 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
#gas-chat-widget .gas-msg-row { display: flex; flex-direction: column; max-width: 88%; }
#gas-chat-widget .gas-msg-row.bot { align-self: flex-start; }
#gas-chat-widget .gas-msg-row.user { align-self: flex-end; align-items: flex-end; }
#gas-chat-widget .gas-msg-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
#gas-chat-widget .gas-msg-row.bot .gas-msg-bubble {
  background: #fff;
  color: #1e293b;
  border-top-left-radius: 4px;
}
#gas-chat-widget .gas-msg-row.user .gas-msg-bubble {
  background: #121849;
  color: #fff;
  border-top-right-radius: 4px;
}
#gas-chat-widget .gas-msg-bubble ul { margin: 8px 0 2px; padding-left: 4px; list-style: none; }
#gas-chat-widget .gas-msg-bubble ul li { margin: 3px 0; }
#gas-chat-widget .gas-msg-bubble ul li::before {
  content: "✓ ";
  color: #cc0000;
  font-weight: 700;
}
#gas-chat-widget .gas-msg-meta {
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 3px;
  display: flex;
  gap: 4px;
  align-items: center;
}
#gas-chat-widget .gas-checkmarks { color: #53bdeb; }

/* Typing indicator */
#gas-chat-widget .gas-typing-indicator {
  background: #fff;
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 13px 16px;
  display: inline-flex;
  gap: 5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
#gas-chat-widget .gas-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: gas-typing 1.2s infinite;
}
#gas-chat-widget .gas-typing-dot:nth-child(2) { animation-delay: 0.15s; }
#gas-chat-widget .gas-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes gas-typing {
  0%, 60%, 100% { transform: none; opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Service chips */
#gas-chat-widget .gas-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
#gas-chat-widget .gas-chip-btn {
  border: 1.5px solid #121849;
  background: #fff;
  color: #121849;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
#gas-chat-widget .gas-chip-btn:hover {
  background: #121849;
  color: #fff;
  border-color: #121849;
}

/* Summary card + WhatsApp CTA */
#gas-chat-widget .gas-final-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(18, 24, 73, 0.12);
  border-top: 3px solid #cc0000;
}
#gas-chat-widget .gas-summary-box { margin: 10px 0; }
#gas-chat-widget .gas-summary-item {
  display: flex;
  gap: 8px;
  font-size: 12.5px;
  padding: 6px 0;
  border-bottom: 1px dashed #e2e8f0;
}
#gas-chat-widget .gas-summary-item:last-child { border-bottom: none; }
#gas-chat-widget .gas-summary-label { color: #64748b; font-weight: 600; flex: 0 0 auto; }
#gas-chat-widget .gas-summary-val { color: #121849; font-weight: 600; }
#gas-chat-widget .gas-wa-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #25D366;
  color: #fff !important;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 700;
  padding: 13px 16px;
  border-radius: 12px;
  margin-top: 6px;
  transition: background 0.15s ease, transform 0.15s ease;
}
#gas-chat-widget .gas-wa-submit-btn:hover { background: #1eb856; transform: translateY(-1px); }
#gas-chat-widget .gas-wa-submit-btn svg { width: 22px; height: 22px; fill: #fff; flex: 0 0 auto; }

/* Input footer */
#gas-chat-widget .gas-chat-footer {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
}
#gas-chat-widget .gas-input-form { display: flex; gap: 8px; align-items: center; }
#gas-chat-widget .gas-input-field {
  flex: 1 1 auto;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 16px; /* prevents iOS auto-zoom */
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
#gas-chat-widget .gas-input-field:focus { border-color: #121849; }
#gas-chat-widget .gas-input-field:disabled { background: #f1f5f9; color: #94a3b8; }
#gas-chat-widget .gas-send-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #121849;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
#gas-chat-widget .gas-send-btn:hover { background: #cc0000; }
#gas-chat-widget .gas-send-btn:disabled { background: #cbd5e1; cursor: default; }
#gas-chat-widget .gas-send-btn svg { width: 18px; height: 18px; }
#gas-chat-widget .gas-security-footnote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 7px;
}
#gas-chat-widget .gas-security-footnote svg { width: 11px; height: 11px; }

/* ============ Mobile bottom-sheet ============ */
@media (max-width: 640px) {
  #gas-chat-widget { bottom: 0; right: 0; left: 0; display: flex; justify-content: flex-end; }
  #gas-chat-widget .gas-chat-launcher { margin: 0 16px 16px 0; }
  #gas-chat-widget .gas-proactive-teaser { right: 16px; bottom: 88px; width: min(280px, calc(100vw - 64px)); }
  #gas-chat-widget .gas-chat-window {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 65vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  #gas-chat-widget * { animation: none !important; transition: none !important; }
}
