/* ==========================================================================
   My Advertiser Communications - AI Agent Widget Styles
   Ultra-modern Glassmorphism & High-Performance UI
   ========================================================================== */

:root {
  --adv-primary: #0284c7;
  --adv-primary-dark: #0369a1;
  --adv-primary-light: #e0f2fe;
  --adv-accent-pink: #ec4899;
  --adv-accent-rose: #e11d48;
  --adv-accent-purple: #8b5cf6;
  --adv-dark: #0f172a;
  --adv-dark-deep: #020617;
  --adv-surface: #ffffff;
  --adv-surface-subtle: #f8fafc;
  --adv-border: #e2e8f0;
  --adv-text-main: #0f172a;
  --adv-text-muted: #64748b;
  --adv-shadow-lg: 0 20px 45px -10px rgba(15, 23, 42, 0.25), 0 10px 20px -5px rgba(2, 132, 199, 0.15);
  --adv-radius-lg: 24px;
  --adv-radius-md: 16px;
  --adv-radius-sm: 10px;
}

/* ==================== TRIGGER BUTTON & FLOATING BADGE ==================== */
#adv-ai-trigger-container {
  position: fixed;
  bottom: 96px; /* Sits right above the Call button (bottom-6 / 24px) */
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  user-select: none;
}

#adv-ai-trigger-badge {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transform-origin: right center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

#adv-ai-trigger-badge:hover {
  transform: translateY(-2px) scale(1.03);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.3);
}

#adv-ai-trigger-badge .adv-badge-dot {
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 10px #22c55e;
  animation: advPulse 2s infinite;
}

#adv-ai-trigger-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7 0%, #7c3aed 50%, #ec4899 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.85);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  outline: none;
}

#adv-ai-trigger-btn:hover {
  transform: scale(1.08) rotate(4deg);
  box-shadow: 0 16px 36px rgba(124, 58, 237, 0.55), 0 0 0 4px rgba(255, 255, 255, 0.95);
}

#adv-ai-trigger-btn i {
  font-size: 24px;
  transition: transform 0.3s ease;
}

#adv-ai-trigger-btn .adv-ping-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  opacity: 0.8;
  animation: advPing 2.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}

/* ==================== MAIN CHAT WINDOW ==================== */
#adv-ai-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: var(--adv-radius-lg);
  box-shadow: var(--adv-shadow-lg);
  border: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 0;
  transform: translateY(30px) scale(0.94);
  pointer-events: none;
  transition: all 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

#adv-ai-widget.adv-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ==================== BACKDROP OVERLAY ==================== */
#adv-ai-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#adv-ai-backdrop.adv-active {
  opacity: 1;
  pointer-events: auto;
}

/* ==================== HEADER ==================== */
.adv-chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 60%, #0f172a 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.adv-chat-header::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -20px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.adv-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 2;
  min-width: 0;
  flex: 1;
}

.adv-agent-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284c7, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 19px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
  flex-shrink: 0;
}

.adv-avatar-status {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0f172a;
}

.adv-header-meta {
  min-width: 0;
  overflow: hidden;
}

.adv-header-meta h3 {
  font-size: 14.5px;
  font-weight: 800;
  margin: 0;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adv-header-meta h3 span.adv-badge-ai {
  font-size: 10px;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 1px 6px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.adv-header-meta p {
  font-size: 11px;
  color: #94a3b8;
  margin: 2px 0 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adv-header-meta p .adv-status-pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 6px #22c55e;
  flex-shrink: 0;
}

.adv-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  margin-left: 8px;
}

.adv-icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
}

.adv-icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

.adv-icon-btn.active {
  background: #0284c7;
  color: #ffffff;
}

#adv-close-btn {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  font-size: 14px;
}

#adv-close-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #dc2626;
}

/* ==================== CHAT MESSAGES BODY ==================== */
.adv-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.adv-chat-body::-webkit-scrollbar {
  width: 5px;
}

.adv-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.adv-chat-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.adv-chat-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==================== MESSAGE BUBBLES ==================== */
.adv-message-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: advFadeUp 0.25s ease-out;
}

.adv-message-row.adv-agent {
  align-self: flex-start;
}

.adv-message-row.adv-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.adv-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0284c7, #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

.adv-msg-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.adv-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #1e293b;
  position: relative;
  word-break: break-word;
}

.adv-agent .adv-msg-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-top-left-radius: 4px;
  box-shadow: 0 3px 12px -2px rgba(15, 23, 42, 0.05);
}

.adv-user .adv-msg-bubble {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.25);
}

.adv-msg-bubble p {
  margin: 0 0 8px 0;
}

.adv-msg-bubble p:last-child {
  margin-bottom: 0;
}

.adv-msg-bubble strong {
  font-weight: 700;
  color: #0f172a;
}

.adv-user .adv-msg-bubble strong {
  color: #ffffff;
}

.adv-msg-bubble ul, .adv-msg-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.adv-msg-bubble li {
  margin-bottom: 4px;
}

.adv-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: #94a3b8;
  padding: 0 4px;
}

.adv-user .adv-msg-meta {
  justify-content: flex-end;
}

.adv-msg-actions {
  display: inline-flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.adv-message-row:hover .adv-msg-actions {
  opacity: 1;
}

.adv-msg-action-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
  border-radius: 4px;
}

.adv-msg-action-btn:hover {
  color: #0284c7;
  background: #e2e8f0;
}

/* ==================== QUICK PROMPT CHIPS ==================== */
.adv-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.adv-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.adv-chip:hover {
  background: #f0f9ff;
  border-color: #38bdf8;
  color: #0284c7;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.15);
}

.adv-chip i {
  color: #0284c7;
  font-size: 11px;
}

/* ==================== INTERACTIVE CHAT CARDS ==================== */
.adv-card {
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid #e2e8f0;
  border-radius: var(--adv-radius-md);
  padding: 14px;
  margin-top: 10px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.adv-card-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.adv-card-plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}

.adv-card-plan-box {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--adv-radius-sm);
  padding: 10px;
  text-align: center;
  transition: border-color 0.2s;
}

.adv-card-plan-box.adv-sky {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.adv-card-plan-box.adv-pink {
  border-color: #fbcfe8;
  background: #fdf2f8;
}

.adv-plan-name {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
}

.adv-plan-rate {
  font-size: 16px;
  font-weight: 900;
  margin: 3px 0;
  font-family: 'JetBrains Mono', monospace;
}

.adv-sky .adv-plan-rate { color: #0284c7; }
.adv-pink .adv-plan-rate { color: #db2777; }

.adv-plan-sub {
  font-size: 9.5px;
  color: #64748b;
}

.adv-card-cta-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.adv-cta-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--adv-radius-sm);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.adv-cta-btn.adv-btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
}

.adv-cta-btn.adv-btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.adv-cta-btn.adv-btn-whatsapp {
  background: #25d366;
  color: #ffffff;
}

.adv-cta-btn.adv-btn-whatsapp:hover {
  background: #20bd5a;
  transform: translateY(-1px);
}

/* ==================== LEAD CAPTURE IN-CHAT FORM ==================== */
.adv-inchat-form {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--adv-radius-md);
  padding: 14px;
  margin-top: 8px;
}

.adv-inchat-form h4 {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.adv-inchat-form p {
  font-size: 11px;
  color: #64748b;
  margin: 0 0 10px 0;
}

.adv-form-group {
  margin-bottom: 8px;
}

.adv-form-group input,
.adv-form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.adv-form-group input:focus,
.adv-form-group select:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.adv-form-submit-btn {
  width: 100%;
  padding: 9px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0284c7, #7c3aed);
  color: #ffffff;
  border: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.adv-form-submit-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.adv-form-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==================== TYPING INDICATOR ==================== */
.adv-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  border-top-left-radius: 4px;
  width: fit-content;
}

.adv-typing-dot {
  width: 6px;
  height: 6px;
  background: #0284c7;
  border-radius: 50%;
  animation: advTypingBounce 1.4s infinite ease-in-out both;
}

.adv-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.adv-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* ==================== FOOTER & INPUT BAR ==================== */
.adv-chat-footer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.adv-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border: 1.5px solid transparent;
  border-radius: 9999px;
  padding: 4px 6px 4px 14px;
  transition: all 0.2s ease;
}

.adv-input-row:focus-within {
  background: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

#adv-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: #0f172a;
  font-family: inherit;
  padding: 6px 0;
}

#adv-chat-input::placeholder {
  color: #94a3b8;
}

.adv-mic-btn {
  background: transparent;
  border: none;
  color: #64748b;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.adv-mic-btn:hover {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.1);
}

.adv-mic-btn.adv-recording {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  animation: advPulseRed 1.2s infinite;
}

#adv-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 13px;
  flex-shrink: 0;
}

#adv-send-btn:hover {
  transform: scale(1.06);
  filter: brightness(1.1);
}

#adv-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.adv-footer-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: #94a3b8;
  padding: 0 4px;
}

.adv-footer-brand a {
  color: #64748b;
  text-decoration: none;
  font-weight: 600;
}

.adv-footer-brand a:hover {
  color: #0284c7;
}

/* ==================== ANIMATIONS ==================== */
@keyframes advPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}

@keyframes advPulseRed {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes advPing {
  0% { transform: scale(0.95); opacity: 0.8; }
  80%, 100% { transform: scale(1.35); opacity: 0; }
}

@keyframes advTypingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes advFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 640px) {
  #adv-ai-trigger-container {
    bottom: 84px;
    right: 16px;
  }
  
  #adv-ai-trigger-badge {
    display: none;
  }

  /* Compact floating card modal on mobile - leaves comfortable margins so it NEVER covers full screen */
  #adv-ai-widget {
    bottom: 12px;
    right: 8px;
    left: 8px;
    width: auto;
    max-width: 430px;
    margin: 0 auto;
    height: 80vh;
    height: 80dvh;
    max-height: 580px;
    border-radius: 20px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.08);
  }

  .adv-chat-header {
    padding: 12px 14px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
  }

  .adv-agent-avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-radius: 10px;
  }

  .adv-header-meta h3 {
    font-size: 13.5px;
  }

  .adv-header-meta h3 span.adv-badge-ai {
    font-size: 9px;
    padding: 1px 4px;
  }

  .adv-header-actions {
    gap: 5px;
    margin-left: 6px;
  }

  .adv-icon-btn {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  /* Prominent high-contrast Close button on mobile */
  #adv-close-btn {
    width: 34px;
    height: 34px;
    background: #ef4444;
    color: #ffffff;
    border: 1.5px solid #dc2626;
    border-radius: 10px;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  }

  #adv-close-btn:active {
    transform: scale(0.95);
  }

  .adv-chat-body {
    padding: 14px 12px;
    gap: 12px;
  }

  .adv-message-row {
    max-width: 92%;
  }

  .adv-chat-footer {
    padding: 10px 12px;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
  }
}
