/* WP AI Agent Floating Widget CSS - All 4 Placement Corner Support */
#wp-ai-agent-root {
  display: block !important;
  position: static !important;
  visibility: visible !important;
  opacity: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 2147483647 !important;
}

.wp-ai-widget-wrapper {
  position: fixed !important;
  z-index: 2147483647 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: normal !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.wp-ai-widget-wrapper * {
  box-sizing: border-box !important;
}

/* Placements */
.wp-ai-pos-bottom-right { bottom: 24px !important; right: 24px !important; top: auto !important; left: auto !important; }
.wp-ai-pos-bottom-right .wp-ai-window { bottom: 74px !important; right: 0 !important; top: auto !important; left: auto !important; transform-origin: bottom right !important; }

.wp-ai-pos-bottom-left { bottom: 24px !important; left: 24px !important; top: auto !important; right: auto !important; }
.wp-ai-pos-bottom-left .wp-ai-window { bottom: 74px !important; left: 0 !important; top: auto !important; right: auto !important; transform-origin: bottom left !important; }

.wp-ai-pos-top-right { top: 24px !important; right: 24px !important; bottom: auto !important; left: auto !important; }
.wp-ai-pos-top-right .wp-ai-window { top: 74px !important; right: 0 !important; bottom: auto !important; left: auto !important; transform-origin: top right !important; }

.wp-ai-pos-top-left { top: 24px !important; left: 24px !important; bottom: auto !important; right: auto !important; }
.wp-ai-pos-top-left .wp-ai-window { top: 74px !important; left: 0 !important; bottom: auto !important; right: auto !important; transform-origin: top left !important; }

/* Floating Badge */
.wp-ai-badge {
  width: 60px !important;
  height: 60px !important;
  border-radius: 50% !important;
  border: none !important;
  cursor: pointer !important;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
  padding: 0 !important;
  outline: none !important;
}

.wp-ai-badge:hover {
  transform: scale(1.08) !important;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45) !important;
}

.wp-ai-badge-avatar {
  width: 100% !important;
  height: 100% !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block !important;
}

.wp-ai-badge-pulse {
  position: absolute !important;
  top: 2px !important;
  right: 2px !important;
  width: 14px !important;
  height: 14px !important;
  background-color: #22c55e !important;
  border: 2px solid #ffffff !important;
  border-radius: 50% !important;
}

.wp-ai-icon-chat {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #ffffff;
  border-radius: 50%;
  padding: 3px;
  color: #2563eb;
  width: 22px;
  height: 22px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Chat Window Popup */
.wp-ai-window {
  width: 380px !important;
  height: 580px !important;
  max-width: calc(100vw - 32px) !important;
  max-height: calc(100vh - 100px) !important;
  background: #ffffff !important;
  border-radius: 18px !important;
  box-shadow: 0 16px 40px rgba(0,0,0,0.2) !important;
  border: 1px solid #e2e8f0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  position: absolute !important;
  transition: opacity 0.25s ease, transform 0.25s ease !important;
}

.wp-ai-window.wp-ai-hidden, .wp-ai-hidden {
  display: none !important;
}

/* Header */
.wp-ai-header {
  padding: 14px 18px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wp-ai-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wp-ai-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
}

.wp-ai-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.wp-ai-status-indicator {
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  gap: 4px;
}

.wp-ai-status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}

.wp-ai-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
  opacity: 0.8;
  line-height: 1;
}

.wp-ai-close-btn:hover { opacity: 1; }

/* Pre-Chat Gate Screen */
.wp-ai-prechat-container {
  flex: 1;
  background: #f8fafc;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.wp-ai-prechat-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  width: 100%;
}

.wp-ai-prechat-icon {
  font-size: 32px;
  text-align: center;
  margin-bottom: 8px;
}

.wp-ai-prechat-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  text-align: center;
  margin: 0 0 6px 0;
}

.wp-ai-prechat-desc {
  font-size: 12px;
  color: #64748b;
  text-align: center;
  margin: 0 0 16px 0;
  line-height: 1.4;
}

.wp-ai-prechat-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wp-ai-field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wp-ai-field-label {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
}

/* Active Chat Box */
.wp-ai-active-chat-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wp-ai-customer-badge {
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #475569;
}

.wp-ai-badge-edit-btn {
  background: none;
  border: none;
  color: #4f46e5;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* Messages Area */
.wp-ai-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wp-ai-msg { display: flex; max-width: 85%; }
.wp-ai-agent-msg { align-self: flex-start; }
.wp-ai-user-msg { align-self: flex-end; }

.wp-ai-msg-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.wp-ai-agent-msg .wp-ai-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
}

.wp-ai-user-msg .wp-ai-msg-bubble {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.wp-ai-sent-img { max-width: 100%; border-radius: 8px; margin-top: 8px; }

/* Quick Suggestions */
.wp-ai-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.wp-ai-sug-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 11px;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wp-ai-sug-btn:hover { background: #2563eb; color: #ffffff; border-color: #2563eb; }

/* Image Attachment Preview Box */
.wp-ai-image-preview {
  padding: 8px 16px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #e2e8f0;
  position: relative;
}

#wp-ai-preview-img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.wp-ai-preview-tag { font-size: 12px; color: #475569; font-weight: 500; }
.wp-ai-remove-img { position: absolute; right: 12px; background: none; border: none; font-size: 18px; cursor: pointer; color: #ef4444; }

/* Input Bar */
.wp-ai-footer { padding: 10px 12px; background: #ffffff; border-top: 1px solid #e2e8f0; }

.wp-ai-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 4px 8px;
}

.wp-ai-input-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
}

.wp-ai-tool-btn {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.wp-ai-tool-btn:hover { color: #2563eb; }
.wp-ai-mic-active { color: #ef4444 !important; animation: wp-ai-pulse 1.2s infinite; }

@keyframes wp-ai-pulse { 0% { transform: scale(1); } 50% { transform: scale(1.15); } 100% { transform: scale(1); } }

.wp-ai-send-btn {
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.wp-ai-send-btn:hover { opacity: 0.9; }

/* WhatsApp Bar */
.wp-ai-whatsapp-bar {
  background: #f0fdf4;
  border-bottom: 1px solid #bbf7d0;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #166534;
}

.wp-ai-wa-link { display: inline-flex; align-items: center; text-decoration: none; color: #166534; font-weight: 500; cursor: pointer; }
.wp-ai-wa-link:hover { opacity: 0.8; }

.wp-ai-lead-toggle-btn {
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wp-ai-lead-toggle-btn:hover { background: #15803d; }

/* WhatsApp Enquiry Modal Popup */
.wp-ai-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.wp-ai-modal-card {
  background: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 330px;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
  border: 1px solid #cbd5e1;
  animation: wp-ai-scale-up 0.2s ease;
}

@keyframes wp-ai-scale-up {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.wp-ai-modal-header {
  background: #f8fafc;
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wp-ai-modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #64748b;
  cursor: pointer;
  line-height: 1;
}

.wp-ai-modal-close-btn:hover { color: #0f172a; }

.wp-ai-modal-body { padding: 14px; }

.wp-ai-modal-wa-banner { margin-bottom: 8px; }
.wp-ai-modal-wa-btn {
  display: block;
  text-align: center;
  background: #22c55e;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s ease;
}
.wp-ai-modal-wa-btn:hover { background: #16a34a; }

.wp-ai-lead-form-fields { display: flex; flex-direction: column; gap: 6px; }

.wp-ai-lead-select {
  width: 30% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  cursor: pointer;
}

.wp-ai-lead-input {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  color: #1e293b;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.wp-ai-lead-input:focus, .wp-ai-lead-select:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.wp-ai-lead-submit-btn {
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.wp-ai-lead-submit-btn:hover { background: #15803d; }

.wp-ai-modal-cancel-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.wp-ai-modal-cancel-btn:hover { background: #e2e8f0; color: #0f172a; }

.wp-ai-chat-link { color: #2563eb !important; text-decoration: underline !important; font-weight: 600 !important; }

/* Typing animation */
.wp-ai-typing-dots span { animation: wp-ai-blink 1.4s infinite fill-mode: both; font-size: 18px; font-weight: bold; }
.wp-ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.wp-ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes wp-ai-blink { 0% { opacity: .2; } 20% { opacity: 1; } 100% { opacity: .2; } }
