/* LeadGo Agent IA — Widget CSS */
/* Isolated namespace to avoid WordPress theme conflicts */

#leadgo-widget-root {
  --lg-primary: #0070f3;
  --lg-primary-dark: #0051cc;
  --lg-accent: #00d4aa;
  --lg-dark: #0a0e1a;
  --lg-dark2: #111827;
  --lg-surface: #1a2035;
  --lg-surface2: #242b40;
  --lg-text: #f1f5f9;
  --lg-text-muted: #94a3b8;
  --lg-border: rgba(255,255,255,0.08);
  --lg-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 4px 20px rgba(0,112,243,0.2);
  --lg-radius: 16px;
  --lg-radius-sm: 10px;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  box-sizing: border-box;
}

#leadgo-widget-root *, #leadgo-widget-root *::before, #leadgo-widget-root *::after {
  box-sizing: inherit;
}

/* === TOGGLE BUTTON === */
#leadgo-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--lg-primary) 0%, #0051cc 100%);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,112,243,0.45), 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#leadgo-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,112,243,0.6), 0 4px 12px rgba(0,0,0,0.4);
}

#leadgo-toggle-btn:active {
  transform: scale(0.96);
}

#leadgo-toggle-btn svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: opacity 0.2s ease;
}

/* Online dot */
#leadgo-toggle-btn::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 13px;
  height: 13px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
  animation: leadgo-pulse 2s infinite;
}

@keyframes leadgo-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50% { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* === CHAT WINDOW === */
#leadgo-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 560px;
  background: var(--lg-dark2);
  border: 1px solid var(--lg-border);
  border-radius: var(--lg-radius);
  box-shadow: var(--lg-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999997;
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

#leadgo-chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#leadgo-chat-header {
  background: linear-gradient(135deg, var(--lg-primary) 0%, #0040aa 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

#leadgo-chat-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.leadgo-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.leadgo-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border: 2px solid var(--lg-primary);
  border-radius: 50%;
}

.leadgo-header-info {
  flex: 1;
  position: relative;
  z-index: 1;
}

.leadgo-header-info .agent-name {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
}

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

.leadgo-header-info .agent-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
}

#leadgo-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  cursor: pointer;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

#leadgo-close-btn:hover { background: rgba(255,255,255,0.25); }

/* Messages area */
#leadgo-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#leadgo-messages::-webkit-scrollbar { width: 4px; }
#leadgo-messages::-webkit-scrollbar-track { background: transparent; }
#leadgo-messages::-webkit-scrollbar-thumb { background: var(--lg-surface2); border-radius: 4px; }

/* Message bubbles */
.leadgo-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: leadgo-msg-in 0.25s ease;
}

@keyframes leadgo-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.leadgo-msg.assistant { align-self: flex-start; }
.leadgo-msg.user { align-self: flex-end; }

.leadgo-msg .bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
}

.leadgo-msg.assistant .bubble {
  background: var(--lg-surface);
  color: var(--lg-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--lg-border);
}

.leadgo-msg.user .bubble {
  background: var(--lg-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.leadgo-msg .msg-time {
  font-size: 10.5px;
  color: var(--lg-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.leadgo-msg.user .msg-time { text-align: right; }

/* CTA button inside message */
.leadgo-cta-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 16px;
  background: linear-gradient(135deg, var(--lg-primary), #0040aa);
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.15s;
}

.leadgo-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,112,243,0.45);
}

/* Typing indicator */
.leadgo-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--lg-surface);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--lg-border);
  align-self: flex-start;
  animation: leadgo-msg-in 0.25s ease;
}

.leadgo-typing span {
  width: 7px;
  height: 7px;
  background: var(--lg-text-muted);
  border-radius: 50%;
  animation: leadgo-bounce 1.2s infinite;
}

.leadgo-typing span:nth-child(2) { animation-delay: 0.2s; }
.leadgo-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes leadgo-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Lead capture form */
#leadgo-capture-form {
  background: var(--lg-surface);
  border: 1px solid rgba(0,212,170,0.2);
  border-radius: 12px;
  padding: 14px;
  margin: 4px 0;
  align-self: flex-start;
  max-width: 90%;
  animation: leadgo-msg-in 0.3s ease;
}

#leadgo-capture-form h4 {
  color: var(--lg-accent);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 10px;
}

#leadgo-capture-form input {
  width: 100%;
  padding: 8px 10px;
  background: var(--lg-dark2);
  border: 1px solid var(--lg-border);
  border-radius: 8px;
  color: var(--lg-text);
  font-size: 13px;
  margin-bottom: 7px;
  outline: none;
  transition: border-color 0.15s;
}

#leadgo-capture-form input:focus { border-color: var(--lg-primary); }
#leadgo-capture-form input::placeholder { color: var(--lg-text-muted); }

#leadgo-capture-form button {
  width: 100%;
  padding: 9px;
  background: var(--lg-accent);
  color: var(--lg-dark);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

#leadgo-capture-form button:hover { opacity: 0.9; }

/* Input area */
#leadgo-input-area {
  padding: 12px;
  border-top: 1px solid var(--lg-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--lg-dark2);
  flex-shrink: 0;
}

#leadgo-user-input {
  flex: 1;
  background: var(--lg-surface);
  border: 1px solid var(--lg-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--lg-text);
  font-size: 13.5px;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s;
  font-family: inherit;
}

#leadgo-user-input:focus { border-color: var(--lg-primary); }
#leadgo-user-input::placeholder { color: var(--lg-text-muted); }

#leadgo-send-btn {
  width: 40px;
  height: 40px;
  background: var(--lg-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

#leadgo-send-btn:hover { background: var(--lg-primary-dark); }
#leadgo-send-btn:active { transform: scale(0.93); }
#leadgo-send-btn svg { width: 17px; height: 17px; fill: #fff; }
#leadgo-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Branding footer */
#leadgo-chat-footer {
  padding: 6px 12px 8px;
  text-align: center;
  border-top: 1px solid var(--lg-border);
  background: var(--lg-dark2);
}

#leadgo-chat-footer span {
  font-size: 10.5px;
  color: var(--lg-text-muted);
}

#leadgo-chat-footer a {
  color: var(--lg-primary);
  text-decoration: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
  #leadgo-chat-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
    right: 8px;
    bottom: 80px;
    border-radius: 12px;
  }
  #leadgo-toggle-btn {
    right: 16px;
    bottom: 16px;
  }
}
