/* ==========================================================================
   RPAVault AI Career Counselor & Course Assistant Styles
   Works in both Full-Page Mode (#rpavault-counselor-app) and Floating Bubble Mode
   ========================================================================== */

:root {
  --rpav-primary: #0b1f31;
  --rpav-primary-hover: #004182;
  --rpav-accent: #0058b0;
  --rpav-accent-hover: #004182;
  --rpav-accent-light: #e6f1fb;
  --rpav-success: #10b981;
  --rpav-text-main: #1a181b;
  --rpav-text-muted: #607987;
  --rpav-border: #cce8f3;
  --rpav-bg-bubble-user: #0058b0;
  --rpav-bg-bubble-bot: #f6fcff;
  --rpav-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --rpav-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --rpav-shadow-lg: 0 10px 25px -5px rgba(11, 31, 49, 0.15), 0 8px 10px -6px rgba(11, 31, 49, 0.1);
  --rpav-shadow-xl: 0 20px 40px -5px rgba(11, 31, 49, 0.22);
}

/* ==========================================================================
   1. FLOATING LAUNCHER (Bubble Mode)
   ========================================================================== */
#rpav-bubble-launcher {
  position: fixed;
  bottom: 84px; /* Positioned directly above floating WhatsApp button */
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0b1f31, #004182);
  box-shadow: 0 8px 24px rgba(11, 31, 49, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, bottom 0.25s ease;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

#rpav-bubble-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 30px rgba(0, 88, 176, 0.35);
}

#rpav-bubble-launcher svg {
  width: 24px;
  height: 24px;
  fill: #ffffff;
  transition: transform 0.25s ease;
}

#rpav-bubble-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 13px;
  height: 13px;
  background: var(--rpav-success);
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: rpav-pulse 2s infinite;
}

@keyframes rpav-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   2. CHAT MODAL CONTAINER (Bubble Mode)
   ========================================================================== */
#rpav-chat-modal {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 395px;
  height: 610px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 40px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(11, 31, 49, 0.22), 0 0 0 1px rgba(0, 88, 176, 0.12);
  border: 1px solid var(--rpav-border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 8500;
  font-family: var(--rpav-font);
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

#rpav-chat-modal.rpav-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ==========================================================================
   3. FULL PAGE CONTAINER & STANDALONE PAGE MODE
   ========================================================================== */
.chatbot-standalone-page {
  background: #f8fafc;
  background: radial-gradient(circle at top center, #f1f5f9 0%, #f8fafc 100%);
  padding: 24px 20px 36px;
  min-height: calc(100vh - 140px);
  display: flex;
  justify-content: center;
  align-items: center;
}

.chatbot-standalone-container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

.chatbot-intro-banner {
  display: none !important;
}

#rpavault-counselor-app {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  height: 740px;
  max-height: calc(100vh - 150px);
  min-height: 520px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 16px 40px -10px rgba(11, 31, 49, 0.12), 0 0 0 1px var(--rpav-border);
  border: 1px solid var(--rpav-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--rpav-font);
}

/* Hide floating bubble launcher and whatsapp floating button on dedicated chatbot page */
body.is-chatbot-page #rpav-bubble-launcher,
body:has(#rpavault-counselor-app) #rpav-bubble-launcher,
body:has(.chatbot-standalone-page) #rpav-bubble-launcher {
  display: none !important;
}

/* Mobile Friendly: Within Website with Logo & Header, No Footer */
@media (max-width: 768px) {
  body.is-chatbot-page footer,
  body:has(#rpavault-counselor-app) footer,
  body:has(.chatbot-standalone-page) footer {
    display: none !important;
  }

  body.is-chatbot-page .whatsapp-float,
  body:has(#rpavault-counselor-app) .whatsapp-float,
  body:has(.chatbot-standalone-page) .whatsapp-float {
    display: none !important;
  }

  .chatbot-standalone-page {
    padding: 0 !important;
    background: #ffffff !important;
    min-height: 0 !important;
    height: calc(100vh - 65px) !important;
    height: calc(100dvh - 65px) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .chatbot-standalone-container {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .chatbot-intro-banner {
    display: none !important; /* Hide intro banner on mobile so chat takes full viewport */
  }

  #rpavault-counselor-app {
    height: 100% !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    min-height: 0 !important;
  }
}

/* ==========================================================================
   4. CHAT HEADER
   ========================================================================== */
.rpav-header,
#rpav-chat-modal .rpav-header,
#rpavault-counselor-app .rpav-header {
  background: #0b1f31 !important;
  background: linear-gradient(135deg, #0b1f31 0%, #004182 100%) !important;
  color: #ffffff !important;
  padding: 16px 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
  flex-shrink: 0 !important;
}

.rpav-header-left {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.rpav-avatar {
  width: 42px !important;
  height: 42px !important;
  background: rgba(255, 255, 255, 0.12) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
  border: 1.5px solid rgba(255, 255, 255, 0.25) !important;
}

.rpav-avatar svg {
  width: 22px !important;
  height: 22px !important;
  fill: #60a5fa !important;
}

.rpav-online-dot {
  position: absolute !important;
  bottom: 0 !important;
  right: 0 !important;
  width: 11px !important;
  height: 11px !important;
  background: var(--rpav-success) !important;
  border-radius: 50% !important;
  border: 2px solid #0b1f31 !important;
}

.rpav-header-info,
#rpav-chat-modal .rpav-header-info,
#rpavault-counselor-app .rpav-header-info {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
}

.rpav-header-info h3,
#rpav-chat-modal .rpav-header-info h3,
#rpavault-counselor-app .rpav-header-info h3,
.course-detail-page #rpav-chat-modal .rpav-header-info h3,
.course-detail-page #rpavault-counselor-app .rpav-header-info h3 {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  letter-spacing: -0.2px !important;
  color: #ffffff !important;
  font-family: var(--rpav-font) !important;
  line-height: 1.25 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.rpav-header-info p,
#rpav-chat-modal .rpav-header-info p,
#rpavault-counselor-app .rpav-header-info p,
.course-detail-page #rpav-chat-modal .rpav-header-info p,
.course-detail-page #rpavault-counselor-app .rpav-header-info p {
  margin: 3px 0 0 !important;
  padding: 0 !important;
  font-size: 12px !important;
  color: rgba(255, 255, 255, 0.88) !important;
  font-family: var(--rpav-font) !important;
  line-height: 1.25 !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.rpav-header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.rpav-icon-btn,
#rpav-chat-modal .rpav-icon-btn {
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.85) !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.rpav-icon-btn:hover,
#rpav-chat-modal .rpav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.16) !important;
  color: #ffffff !important;
}

/* ==========================================================================
   5. MESSAGE THREAD & SCROLL AREA
   ========================================================================== */
.rpav-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fdfdfd;
  scroll-behavior: smooth;
}

.rpav-msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: rpav-fadein 0.25s ease-out;
}

@keyframes rpav-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.rpav-bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: 18px;
  word-wrap: break-word;
}

.rpav-msg-user .rpav-bubble {
  background: var(--rpav-bg-bubble-user);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.rpav-msg-bot .rpav-bubble {
  background: var(--rpav-bg-bubble-bot);
  color: var(--rpav-text-main);
  border: 1px solid var(--rpav-border);
  border-bottom-left-radius: 4px;
}

.rpav-bubble a,
.rpav-bubble .rpav-link {
  color: #0058b0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
  transition: color 0.15s ease;
  word-break: break-word;
}

.rpav-bubble a:hover,
.rpav-bubble .rpav-link:hover {
  color: #00366f;
  text-decoration-thickness: 2px;
}

.rpav-msg-user .rpav-bubble a,
.rpav-msg-user .rpav-bubble .rpav-link {
  color: #ffffff;
  text-decoration: underline;
}

.rpav-msg-time {
  font-size: 11px;
  color: #94a3b8;
  padding: 0 4px;
}

.rpav-msg-user .rpav-msg-time {
  align-self: flex-end;
}

/* Typing Indicator */
.rpav-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--rpav-bg-bubble-bot);
  border: 1px solid var(--rpav-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.rpav-typing-dot {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: rpav-bounce 1.4s infinite ease-in-out both;
}

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

@keyframes rpav-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ==========================================================================
   6. QUICK CHIPS / STARTER QUESTIONS
   ========================================================================== */
.rpav-chips-wrapper {
  padding: 10px 18px 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.rpav-chips-wrapper::-webkit-scrollbar {
  display: none;
}

.rpav-chip {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--rpav-border);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.rpav-chip:hover {
  background: var(--rpav-accent-light);
  border-color: #bfdbfe;
  color: var(--rpav-accent);
}

.rpav-chip-wa {
  background: #ecfdf5 !important;
  color: #065f46 !important;
  border-color: #a7f3d0 !important;
  font-weight: 600 !important;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rpav-chip-wa:hover {
  background: #d1fae5 !important;
  border-color: #34d399 !important;
  color: #047857 !important;
}

.rpav-chip-wa svg {
  width: 14px;
  height: 14px;
  fill: #10b981;
}

/* WhatsApp Connect in Chat & Success */
.rpav-wa-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #25d366;
  color: #ffffff !important;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
  transition: all 0.2s ease;
  margin-top: 6px;
}

.rpav-wa-action-btn:hover {
  background: #20ba5a;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45);
  transform: translateY(-1px);
}

.rpav-wa-action-btn svg {
  fill: #ffffff;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.rpav-wa-prompt-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.rpav-btn-wa-confirm {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #25d366;
  color: #ffffff;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.rpav-btn-wa-confirm:hover {
  background: #20ba5a;
  transform: translateY(-1px);
}

.rpav-btn-wa-confirm svg {
  fill: #ffffff;
  width: 16px;
  height: 16px;
}

.rpav-btn-wa-cancel {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.rpav-btn-wa-cancel:hover {
  background: #e2e8f0;
  color: #334155;
}

/* ==========================================================================
   7. EMBEDDED LEAD CAPTURE CARD
   ========================================================================== */
.rpav-lead-card {
  background: linear-gradient(135deg, #f8fafc, #eff6ff);
  border: 1.5px solid #bfdbfe;
  border-radius: 16px;
  padding: 16px;
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.rpav-lead-header {
  font-size: 13.5px;
  font-weight: 700;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rpav-lead-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.rpav-lead-card input:focus {
  border-color: var(--rpav-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.rpav-lead-btn {
  background: var(--rpav-accent);
  color: #ffffff;
  border: none;
  padding: 10px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.rpav-lead-btn:hover {
  background: var(--rpav-accent-hover);
}

.rpav-lead-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 14px;
  border-radius: 12px;
  text-align: center;
}

/* ==========================================================================
   8. INPUT FOOTER
   ========================================================================== */
.rpav-footer {
  padding: 14px 18px;
  background: #ffffff;
  border-top: 1px solid var(--rpav-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.rpav-input-box {
  flex: 1;
  border: 1.5px solid var(--rpav-border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  background: #f8fafc;
  color: var(--rpav-text-main);
  transition: all 0.2s ease;
  font-family: inherit;
}

.rpav-input-box:focus {
  background: #ffffff;
  border-color: var(--rpav-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.rpav-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--rpav-primary);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.rpav-send-btn:hover {
  background: var(--rpav-accent);
  transform: scale(1.05);
}

.rpav-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

.rpav-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #ffffff;
}

/* ==========================================================================
   9. MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 640px) {
  #rpav-chat-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 8500 !important;
  }

  .chatbot-standalone-page {
    height: calc(100vh - 52px) !important;
    height: calc(100dvh - 52px) !important;
  }

  .rpav-header {
    padding: 12px 14px !important;
  }

  .rpav-header-left {
    gap: 10px !important;
    min-width: 0 !important;
    flex: 1 !important;
  }

  .rpav-avatar {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0 !important;
  }

  .rpav-avatar svg {
    width: 19px !important;
    height: 19px !important;
  }

  .rpav-online-dot {
    width: 9px !important;
    height: 9px !important;
    border-width: 1.5px !important;
  }

  .rpav-header-info {
    min-width: 0 !important;
    flex: 1 !important;
  }

  .rpav-header-info h3 {
    font-size: 15px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
  }

  .rpav-header-info p {
    font-size: 11px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
    margin-top: 2px !important;
  }

  .rpav-messages {
    padding: 12px 12px 6px !important;
    gap: 10px !important;
    overscroll-behavior-y: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .rpav-msg {
    max-width: 90% !important;
  }

  .rpav-bubble {
    padding: 10px 13px !important;
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  .rpav-chips-wrapper {
    padding: 6px 12px 8px !important;
    gap: 6px !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .rpav-chips-wrapper::-webkit-scrollbar {
    display: none !important;
  }

  .rpav-chip {
    padding: 6px 11px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    min-height: 34px !important;
  }

  .rpav-footer {
    padding: 8px 12px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px)) !important;
    gap: 8px !important;
  }

  .rpav-input-box {
    padding: 10px 14px !important;
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom on input focus */
    min-height: 44px !important;
    border-radius: 22px !important;
  }

  .rpav-send-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
  }

  #rpavault-counselor-app {
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
  }
}

@media (max-width: 360px) {
  .rpav-header {
    padding: 10px 10px !important;
  }

  .rpav-header-left {
    gap: 8px !important;
  }

  .rpav-avatar {
    width: 32px !important;
    height: 32px !important;
  }

  .rpav-avatar svg {
    width: 17px !important;
    height: 17px !important;
  }

  .rpav-header-info h3 {
    font-size: 14px !important;
  }

  .rpav-header-info p {
    font-size: 10px !important;
  }

  .rpav-footer {
    padding: 6px 8px !important;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px)) !important;
    gap: 6px !important;
  }

  .rpav-input-box {
    padding: 8px 12px !important;
  }

  .rpav-send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
  }
}
