/* Scoped styles for Genesis AI Chatbot */
#genesis-chatbot-root {
  --chat-primary-gradient: linear-gradient(135deg, #6b27ea, #a020ee 55%, #d90bf6); /* site purple/violet/magenta gradient */
  --chat-primary-bg: #8a3ff0; /* violet accent */
  --chat-header-bg: #150f2b; /* dark purple-navy */
  --chat-bg: #ffffff;
  --chat-text-dark: #333333;
  --chat-text-light: #ffffff;
  --chat-text-muted: #666666;
  --chat-border: #e0e0e0;
  --chat-user-msg-bg: #f2ebff; /* subtle violet tint */
  --chat-ai-msg-bg: #ffffff;
  --chat-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  --chat-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.25);
  --chat-font-family: 'Roboto', 'Montserrat', sans-serif;
  
  position: fixed;
  z-index: 999999;
  bottom: -15px;
  right: 0;
  font-family: var(--chat-font-family);
  pointer-events: none; /* Let clicks pass through the root wrapper */
  width: 100vw;
  height: 100vh;
}

#genesis-chatbot-root * {
  box-sizing: border-box;
}

/* =========================================
   LAUNCHER
========================================= */
#genesis-chatbot-launcher {
  position: absolute;
  bottom: 50px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-header-bg);
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
  outline: none;
  z-index: 10000;
  pointer-events: auto;
}

#genesis-chatbot-launcher:hover,
#genesis-chatbot-launcher:focus {
  transform: scale(1.05);
  box-shadow: var(--chat-shadow-hover);
}

#genesis-chatbot-launcher:active {
  transform: scale(0.95);
}

#genesis-chatbot-launcher svg {
  width: 32px;
  height: 32px;
  fill: var(--chat-text-light);
}

/* Tooltip */
.genesis-chatbot-tooltip {
  position: absolute;
  right: 76px;
  bottom: 16px;
  background: var(--chat-bg);
  color: var(--chat-text-dark);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--chat-shadow);
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

#genesis-chatbot-launcher:hover .genesis-chatbot-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* =========================================
   CHAT WINDOW
========================================= */
#genesis-chatbot-window {
  position: absolute;
  bottom: 100px;
  right: 80px;
  width: 400px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  border-radius: 12px;
  box-shadow: var(--chat-shadow-hover);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform-origin: bottom right;
  z-index: 10000;
  border: 1px solid var(--chat-border);
}

#genesis-chatbot-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.genesis-chatbot-header {
  background: var(--chat-header-bg);
  color: var(--chat-text-light);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.genesis-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.genesis-chatbot-header-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.genesis-chatbot-header-icon svg {
  width: 20px;
  height: 20px;
  fill: var(--chat-text-light);
}

.genesis-chatbot-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--chat-text-light);
}

.genesis-chatbot-header-text p {
  margin: 0;
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}

.genesis-chatbot-header-text p::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #29cc61; /* Green status dot */
  border-radius: 50%;
}

.genesis-chatbot-header-actions {
  display: flex;
  gap: 8px;
}

.genesis-chatbot-header-btn {
  background: transparent;
  border: none;
  color: var(--chat-text-light);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.genesis-chatbot-header-btn:hover,
.genesis-chatbot-header-btn:focus {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.genesis-chatbot-header-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Chat Area */
.genesis-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Message Styles */
.chat-msg {
  max-width: 85%;
  line-height: 1.5;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

.chat-msg.user {
  align-self: flex-end;
}

.chat-msg.ai {
  align-self: flex-start;
}

.chat-msg-content {
  padding: 12px 16px;
  border-radius: 12px;
  position: relative;
}

.chat-msg.user .chat-msg-content {
  background: var(--chat-user-msg-bg);
  color: var(--chat-text-dark);
  border-bottom-right-radius: 4px;
}

.chat-msg.ai .chat-msg-content {
  background: var(--chat-ai-msg-bg);
  color: var(--chat-text-dark);
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 4px;
}

.chat-msg.ai .chat-msg-content p {
  margin: 0 0 8px 0;
}
.chat-msg.ai .chat-msg-content p:last-child {
  margin: 0;
}
.chat-msg.ai .chat-msg-content ul {
  margin: 0 0 8px 0;
  padding-left: 20px;
}
.chat-msg.ai .chat-msg-content a {
  color: var(--chat-primary-bg);
  text-decoration: none;
  font-weight: 500;
}
.chat-msg.ai .chat-msg-content a:hover {
  text-decoration: underline;
}

/* Suggestion Chips */
.genesis-chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.suggestion-chip {
  background: #ffffff;
  border: 1px solid var(--chat-primary-bg);
  color: var(--chat-primary-bg);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggestion-chip:hover,
.suggestion-chip:focus {
  background: var(--chat-primary-bg);
  color: var(--chat-text-light);
  outline: none;
}

.suggestion-chip.primary {
  background: var(--chat-primary-gradient);
  border-color: transparent;
  color: var(--chat-text-light);
  font-weight: 600;
}

.suggestion-chip.primary:hover,
.suggestion-chip.primary:focus {
  opacity: 0.9;
  background: var(--chat-primary-gradient);
}

/* Structured Cards (Products/Contact) */
.chat-card {
  background: #ffffff;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chat-card h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: var(--chat-primary-bg);
}

.chat-card p {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: var(--chat-text-muted);
}

.chat-card .card-cta {
  display: inline-block;
  background: var(--chat-primary-gradient);
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s;
}

.chat-card .card-cta:hover {
  opacity: 0.9;
}

/* Loading Dots */
.chat-loading {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--chat-ai-msg-bg);
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  max-width: 85%;
}
.chat-loading-text {
    font-size: 12px;
    color: var(--chat-text-muted);
    margin-right: 8px;
}

.dot {
  width: 6px;
  height: 6px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
.genesis-chatbot-input-area {
  padding: 16px;
  border-top: 1px solid var(--chat-border);
  display: flex;
  gap: 8px;
  background: var(--chat-bg);
  flex-shrink: 0;
}

.genesis-chatbot-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  font-size: 14px;
  font-family: var(--chat-font-family);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.genesis-chatbot-input:focus {
  outline: none;
  border-color: var(--chat-primary-bg);
  box-shadow: 0 0 0 2px rgba(138, 63, 240, 0.14);
}

.genesis-chatbot-send-btn {
  background: var(--chat-primary-gradient);
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

.genesis-chatbot-send-btn:hover:not(:disabled),
.genesis-chatbot-send-btn:focus:not(:disabled) {
  transform: scale(1.05);
  outline: none;
}

.genesis-chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #ccc;
}

.genesis-chatbot-send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  margin-left: 2px;
}

/* =========================================
   VOICE UI
========================================= */
.genesis-chatbot-mic-btn {
  background: transparent;
  border: 1px solid var(--chat-border);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--chat-primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.genesis-chatbot-mic-btn:hover {
  background: var(--chat-ai-msg-bg);
  border-color: var(--chat-primary-bg);
}

.genesis-chatbot-mic-btn.listening {
  background: #ff3b30;
  color: white;
  border-color: #ff3b30;
  animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.genesis-chatbot-mic-btn svg {
  width: 24px;
  height: 24px;
}

.genesis-chatbot-voice-status {
  padding: 8px 16px;
  background: var(--chat-ai-msg-bg);
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--chat-primary-bg);
  font-weight: 500;
}

.voice-wave {
  display: flex;
  align-items: center;
  gap: 3px;
}

.voice-wave span {
  display: block;
  width: 3px;
  height: 12px;
  background: var(--chat-primary-bg);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

.voice-wave span:nth-child(2) { animation-delay: 0.2s; }
.voice-wave span:nth-child(3) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1.2); }
}

.genesis-chatbot-stop-btn {
  background: transparent;
  border: 1px solid var(--chat-primary-bg);
  color: var(--chat-primary-bg);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto;
}

.genesis-chatbot-stop-btn:hover {
  background: var(--chat-primary-bg);
  color: white;
}

/* =========================================
   RESPONSIVE (MOBILE)
========================================= */
@media (max-width: 600px) {
  #genesis-chatbot-launcher {
    bottom: 85px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  
  #genesis-chatbot-launcher svg {
    width: 28px;
    height: 28px;
  }
  
  .genesis-chatbot-tooltip {
    display: none;
  }

  #genesis-chatbot-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    transform-origin: bottom center;
  }
  
  .genesis-chatbot-messages {
    padding-bottom: 24px; /* safe area */
  }
}

/* =========================================
   HUMAN HANDOFF FORMS
========================================= */
.genesis-handoff-form {
  background: var(--chat-ai-msg-bg);
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.genesis-handoff-form h4 {
  margin: 0;
  color: var(--chat-primary-bg);
  font-size: 15px;
}

.genesis-handoff-form input,
.genesis-handoff-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--chat-font-family);
}

.genesis-handoff-form input:focus,
.genesis-handoff-form textarea:focus {
  outline: none;
  border-color: var(--chat-primary-bg);
}

.genesis-handoff-form textarea {
  resize: vertical;
  min-height: 60px;
}

.genesis-handoff-btn {
  background: var(--chat-primary-gradient);
  color: white;
  border: none;
  padding: 8px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.genesis-handoff-btn:hover {
  opacity: 0.9;
}

.genesis-handoff-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.genesis-handoff-status {
  font-size: 12px;
  margin-top: 4px;
}

.genesis-handoff-status.success {
  color: #28a745;
}

.genesis-handoff-status.error {
  color: #dc3545;
}

/* =========================================
   LIVE EXPERT CALL PANEL (WebRTC)
========================================= */
.expert-call-panel .expert-call-status {
  font-size: 13px;
  margin-bottom: 10px;
}

.expert-call-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.expert-call-controls .genesis-handoff-btn {
  flex: 1;
  min-width: 100px;
}

.expert-call-mute-btn.active {
  background: #dc3545;
}

.genesis-handoff-voice-record-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ff3b30;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 24px;
  cursor: pointer;
  font-weight: bold;
}
.genesis-handoff-voice-record-btn.recording {
  animation: pulse-mic 1.5s infinite;
}
.genesis-handoff-voice-play {
  display: flex;
  align-items: center;
  gap: 8px;
}
.genesis-handoff-voice-play audio {
  width: 100%;
  height: 32px;
}

.genesis-handoff-form select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--chat-font-family);
  background: white;
}

.genesis-handoff-form select:focus {
  outline: none;
  border-color: var(--chat-primary-bg);
}

