/**
 * RedditPosters WhatsApp Concierge & Lead Engine CSS
 * High-performance conversational widget with visualViewport mobile docking
 */

:root {
  --rp-navy: #0F172A;
  --rp-navy-dark: #090D16;
  --rp-orange: #FF4500;
  --rp-orange-hover: #E03D00;
  --rp-emerald: #10B981;
  --rp-wa-green: #25D366;
  --rp-wa-dark: #128C7E;
  --rp-wa-bubble: #DCF8C6;
  --rp-wa-user-text: #064E3B;
  --rp-bg-chat: #F8FAFC;
  --rp-border: #E2E8F0;
  --rp-text-main: #0F172A;
  --rp-text-muted: #64748B;
  --rp-shadow-float: 0 12px 28px -4px rgba(37, 211, 102, 0.38);
  --rp-shadow-window: 0 25px 60px -15px rgba(15, 23, 42, 0.25), 0 0 1px rgba(15, 23, 42, 0.15);
}

/* Base Widget Container */
#rp-wa-widget {
  font-family: inherit;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

/* Floating Launcher Button */
.rp-chat-launcher {
  pointer-events: auto;
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--rp-shadow-float);
  border: 2.5px solid rgba(255, 255, 255, 0.95);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.rp-chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 16px 36px -4px rgba(37, 211, 102, 0.5);
}

.rp-chat-launcher:active {
  transform: scale(0.95);
}

.rp-chat-launcher svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
  transition: transform 0.25s ease;
}

.rp-chat-launcher.is-open svg.icon-chat {
  display: none;
}
.rp-chat-launcher:not(.is-open) svg.icon-close {
  display: none;
}
.rp-chat-launcher.is-open svg.icon-close {
  display: block;
}

/* Pulsing Online Radar Badge */
.rp-radar-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 14px;
  height: 14px;
  background-color: #10B981;
  border: 2.5px solid #FFFFFF;
  border-radius: 50%;
}

.rp-radar-badge::after {
  content: '';
  position: absolute;
  top: -2.5px;
  left: -2.5px;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #10B981;
  animation: rp-radar-pulse 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
  box-sizing: content-box;
}

@keyframes rp-radar-pulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* Proactive Hint Teaser Bubble */
.rp-proactive-teaser {
  pointer-events: auto;
  margin-bottom: 12px;
  background: #FFFFFF;
  border: 1px solid var(--rp-border);
  border-radius: 16px;
  padding: 12px 14px;
  max-width: 290px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: rp-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rp-proactive-teaser:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -5px rgba(15, 23, 42, 0.16);
}

.rp-proactive-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0F172A;
  color: #FF4500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 69, 0, 0.4);
}

.rp-proactive-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.45;
  color: var(--rp-text-main);
  text-align: left;
}

.rp-proactive-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #10B981;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.rp-proactive-close {
  background: none;
  border: none;
  color: var(--rp-text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 15px;
  line-height: 1;
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Chat Main Window */
.rp-chat-window {
  pointer-events: auto;
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #FFFFFF;
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: var(--rp-shadow-window);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
  z-index: 100000;
}

.rp-chat-window.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Window Header */
.rp-chat-header {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #FFFFFF;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid rgba(255, 69, 0, 0.5);
  flex-shrink: 0;
}

.rp-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rp-header-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid #FF4500;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FF4500;
  flex-shrink: 0;
}

.rp-header-avatar svg {
  width: 20px;
  height: 20px;
}

.rp-header-avatar .status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background-color: #25D366;
  border: 2px solid #0F172A;
  border-radius: 50%;
}

.rp-header-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.rp-header-title {
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.25;
}

.rp-header-subtitle {
  font-size: 11px;
  color: #94A3B8;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.rp-header-subtitle .online-text {
  color: #34D399;
  font-weight: 600;
}

.rp-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.rp-btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #94A3B8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.rp-btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

/* Chat Messages Stream */
.rp-chat-body {
  flex: 1;
  background-color: var(--rp-bg-chat);
  background-image: radial-gradient(#E2E8F0 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 16px 14px;
  overflow-y: auto;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rp-chat-body::-webkit-scrollbar {
  width: 4px;
}
.rp-chat-body::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

/* Message Rows */
.rp-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: rp-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.rp-msg-row.bot {
  align-self: flex-start;
}

.rp-msg-row.user {
  align-self: flex-end;
}

.rp-msg-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 16px;
  position: relative;
  word-break: break-word;
}

.rp-msg-row.bot .rp-msg-bubble {
  background: #FFFFFF;
  color: var(--rp-text-main);
  border: 1px solid #E2E8F0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.rp-msg-row.user .rp-msg-bubble {
  background: var(--rp-wa-bubble);
  color: var(--rp-wa-user-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.15);
}

.rp-msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #94A3B8;
  margin-top: 3px;
  padding: 0 4px;
}

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

.rp-checkmarks {
  color: #25D366;
  font-weight: bold;
  font-size: 10px;
}

/* Realistic Typing Indicator */
.rp-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.rp-typing-dot {
  width: 6px;
  height: 6px;
  background-color: #94A3B8;
  border-radius: 50%;
  animation: rp-typing-bounce 1.3s infinite ease-in-out;
}

.rp-typing-dot:nth-child(1) { animation-delay: 0s; }
.rp-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.rp-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes rp-typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Interactive Chips Container */
.rp-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.rp-chip-btn {
  background: #FFFFFF;
  color: #0F172A;
  border: 1px solid #CBD5E1;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  text-align: left;
}

.rp-chip-btn:hover {
  background: #FF4500;
  color: #FFFFFF;
  border-color: #FF4500;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(255, 69, 0, 0.25);
}

/* Final Action Summary Card */
.rp-final-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: rp-slide-up 0.3s ease;
}

.rp-summary-box {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.rp-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.rp-summary-label {
  color: #64748B;
  font-weight: 500;
  flex-shrink: 0;
}

.rp-summary-val {
  color: #0F172A;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.rp-wa-submit-btn {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #FFFFFF !important;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none !important;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.32);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.rp-wa-submit-btn:hover {
  background: linear-gradient(135deg, #22C55E 0%, #0F766E 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(37, 211, 102, 0.42);
  color: #FFFFFF !important;
}

.rp-wa-submit-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Chat Input Footer */
.rp-chat-footer {
  background: #FFFFFF;
  border-top: 1px solid var(--rp-border);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.rp-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F8FAFC;
  border: 1px solid var(--rp-border);
  border-radius: 9999px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rp-input-form:focus-within {
  border-color: #FF4500;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.12);
}

.rp-input-field {
  flex: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  font-size: 13.5px;
  color: var(--rp-text-main);
  padding: 7px 0;
  font-family: inherit;
}

.rp-input-field::placeholder {
  color: #94A3B8;
}

.rp-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0F172A;
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.rp-send-btn:hover {
  background: #FF4500;
  transform: scale(1.05);
}

.rp-send-btn svg {
  width: 15px;
  height: 15px;
}

.rp-security-footnote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
  color: #94A3B8;
  text-align: center;
}

.rp-security-footnote svg {
  width: 11px;
  height: 11px;
  color: #10B981;
}

/* Animations */
@keyframes rp-slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile Responsiveness — Bottom-Sheet UX with visualViewport support */
@media (max-width: 640px) {
  #rp-wa-widget {
    bottom: 16px;
    right: 16px;
  }
  .rp-chat-window {
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 65vh !important;
    max-height: 85vh !important;
    border-radius: 20px 20px 0 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25) !important;
    transform: translateY(100%) !important;
    transform-origin: bottom center !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.25s !important;
  }
  .rp-chat-window.is-visible {
    transform: translateY(0) !important;
  }
  .rp-chat-header {
    padding: 12px 14px !important;
  }
  .rp-header-avatar {
    width: 36px !important;
    height: 36px !important;
  }
  .rp-header-title {
    font-size: 13.5px !important;
  }
  .rp-chat-body {
    padding: 12px !important;
    gap: 10px !important;
  }
  .rp-chat-footer {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)) 12px !important;
  }
  .rp-input-field {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom on input focus */
    padding: 6px 0 !important;
  }
}
