/**
 * Red Chilli Travel — AI Chatbot Styles
 * Premium Chilli Red (#C62828) aesthetics, cartoon avatar, exact WhatsApp vertical alignment, and mobile responsiveness
 */

:root {
  --rct-chilli-red: #C62828;
  --rct-chilli-dark: #B71C1C;
  --rct-chilli-light: #FFEBEE;
  --rct-chat-primary: #14283F;
  --rct-chat-accent: #D9A441;
  --rct-chat-bg: #FFFFFF;
  --rct-chat-body-bg: #F8FAFC;
  --rct-chat-border: #E2E8F0;
  --rct-chat-text: #1E293B;
  --rct-chat-text-muted: #64748B;
  --rct-chat-radius: 18px;
  --rct-chat-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.05);
}

/* ==========================================================================
   1. FLOATING ACTIONS VERTICAL STACK (CHATBOT & WHATSAPP IN A PERFECT LINE)
   ========================================================================== */
.rct-floating-actions-stack {
  position: fixed;
  bottom: 25px;
  right: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  z-index: 1060;
  pointer-events: auto;
}

/* Standard dimensions for both round floating buttons */
.rct-floating-actions-stack .rct-floating-chatbot-btn,
.rct-floating-actions-stack .rct-floating-whatsapp,
.rct-floating-chatbot-btn,
.rct-floating-whatsapp {
  width: 58px !important;
  height: 58px !important;
  border-radius: 50% !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Inside the stack, buttons follow vertical flex flow */
.rct-floating-actions-stack .rct-floating-chatbot-btn,
.rct-floating-actions-stack .rct-floating-whatsapp {
  position: relative !important;
  bottom: auto !important;
  right: auto !important;
  left: auto !important;
  top: auto !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
}

/* Standalone Fallback if not yet nested */
.rct-floating-chatbot-btn {
  position: fixed;
  bottom: calc(25px + 58px + 14px);
  right: 25px;
  background: var(--rct-chilli-red);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(198, 40, 40, 0.45);
  z-index: 1060;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
  outline: none;
  padding: 0;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
}

.rct-floating-chatbot-btn:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 14px 32px rgba(198, 40, 40, 0.6);
}

.rct-floating-chatbot-btn:active {
  transform: scale(0.96);
}

/* Cartoon Man Avatar Image */
.rct-chatbot-avatar-img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2.5px solid #FFFFFF;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.rct-floating-chatbot-btn:hover .rct-chatbot-avatar-img {
  transform: scale(1.03);
}

.rct-chatbot-icon-close svg {
  display: block;
  margin: auto;
}

/* Floating WhatsApp Button Styling */
.rct-floating-whatsapp {
  background: #25D366 !important;
  box-shadow: 0 10px 25px rgba(37, 211, 102, 0.45) !important;
  text-decoration: none !important;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease !important;
}

.rct-floating-whatsapp:hover {
  transform: scale(1.08) translateY(-3px) !important;
  box-shadow: 0 14px 32px rgba(37, 211, 102, 0.6) !important;
}

.rct-floating-whatsapp svg {
  width: 32px !important;
  height: 32px !important;
  fill: #FFFFFF !important;
}

/* Tooltip Prompt */
.rct-chatbot-btn-tooltip {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: #14283F;
  color: #FFFFFF;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.825rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.45rem 0.85rem;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.rct-chatbot-btn-tooltip::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent #14283F;
}

.rct-floating-chatbot-btn:hover .rct-chatbot-btn-tooltip,
.rct-floating-chatbot-btn.has-tooltip-open .rct-chatbot-btn-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

/* Pulsing Notification Dot */
.rct-chatbot-pulse-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background: #10B981;
  border: 2.5px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: rctChatPulse 2s infinite;
  z-index: 3;
}

@keyframes rctChatPulse {
  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 8px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* ==========================================================================
   2. LUXURY CHATBOT WINDOW DESIGN
   ========================================================================== */
.rct-chatbot-window {
  position: fixed;
  bottom: 25px;
  right: 98px; /* Positioned to the left of floating buttons to NEVER cover WhatsApp */
  width: 395px;
  max-width: calc(100vw - 30px);
  height: 560px;
  max-height: calc(100vh - 60px);
  background: var(--rct-chat-bg);
  border-radius: var(--rct-chat-radius);
  box-shadow: var(--rct-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1070;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--rct-chat-border);
}

.rct-chatbot-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat Header */
.rct-chat-header {
  background: linear-gradient(135deg, #14283F 0%, #0D1C2E 100%);
  color: #FFFFFF;
  padding: 0.9rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2.5px solid var(--rct-chilli-red);
  user-select: none;
}

.rct-chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rct-chat-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rct-chat-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.rct-chat-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #10B981;
  border: 2px solid #14283F;
  border-radius: 50%;
}

.rct-chat-header-text {
  display: flex;
  flex-direction: column;
}

.rct-chat-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
}

.rct-chat-subtitle {
  font-size: 0.75rem;
  color: #CBD5E1;
  margin-top: 2px;
}

.rct-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.rct-chat-hbtn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #CBD5E1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
  padding: 0;
}

.rct-chat-hbtn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.rct-chat-hbtn-close:hover {
  background: var(--rct-chilli-red);
}

/* Trust Bar inside Chat */
.rct-chat-trust-bar {
  background: #F1F5F9;
  border-bottom: 1px solid var(--rct-chat-border);
  padding: 0.35rem 0.75rem;
  font-size: 0.725rem;
  font-weight: 600;
  color: #475569;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

/* Scrollable Chat History Body */
.rct-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.15rem 1rem;
  background: var(--rct-chat-body-bg);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  scroll-behavior: smooth;
}

/* Message Rows */
.rct-msg-row {
  display: flex;
  max-width: 90%;
  gap: 8px;
}

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

.rct-msg-row.rct-msg-user {
  align-self: flex-end;
  flex-direction: column;
}

.rct-msg-bot-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  margin-top: 2px;
}

.rct-msg-bubble-wrap {
  display: flex;
  flex-direction: column;
}

.rct-msg-bubble {
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  font-size: 0.885rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

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

.rct-msg-user .rct-msg-bubble {
  background: var(--rct-chilli-red);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.25);
}

.rct-msg-user .rct-msg-bubble a {
  color: #FFFFFF;
  text-decoration: underline;
}

.rct-msg-time {
  font-size: 0.675rem;
  color: var(--rct-chat-text-muted);
  margin-top: 3px;
  align-self: flex-end;
}

/* Markdown formatting in bot messages */
.rct-msg-bot .rct-msg-bubble h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  color: var(--rct-chat-primary);
}

.rct-msg-bot .rct-msg-bubble p {
  margin: 0 0 0.5rem;
}

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

.rct-msg-bot .rct-msg-bubble ul {
  margin: 0.35rem 0;
  padding-left: 1.25rem;
}

.rct-msg-bot .rct-msg-bubble li {
  margin-bottom: 0.25rem;
}

.rct-msg-bot .rct-msg-bubble a {
  color: var(--rct-chilli-red);
  font-weight: 600;
  text-decoration: none;
}

.rct-msg-bot .rct-msg-bubble a:hover {
  text-decoration: underline;
}

/* Tour Suggestion Preview Cards */
.rct-chat-cards-carousel {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.5rem;
  width: 100%;
}

.rct-tour-preview-card {
  background: #FFFFFF;
  border: 1px solid var(--rct-chat-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rct-tour-preview-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.rct-card-img-wrap {
  position: relative;
  width: 100%;
  height: 105px;
  overflow: hidden;
}

.rct-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rct-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(20, 40, 63, 0.85);
  color: #FFFFFF;
  font-size: 0.675rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.rct-card-content {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rct-card-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--rct-chat-primary);
  line-height: 1.3;
}

.rct-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin: 3px 0 2px;
}

.rct-card-duration {
  color: var(--rct-chat-text-muted);
  font-size: 0.775rem;
  font-weight: 500;
  white-space: nowrap !important;
}

.rct-card-price,
.rct-card-price-btn {
  color: var(--rct-chilli-red);
  font-weight: 600;
  font-size: 0.75rem;
  background: var(--rct-chilli-light);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(198, 40, 40, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap !important; /* Strictly single line */
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: all 0.2s ease;
  outline: none;
  box-sizing: border-box;
}

.rct-card-price-btn:hover {
  background: var(--rct-chilli-red);
  color: #FFFFFF;
  border-color: var(--rct-chilli-red);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(198, 40, 40, 0.25);
}

.rct-card-actions-row {
  display: flex;
  gap: 6px;
  margin-top: 0.5rem;
}

.rct-card-btn {
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--rct-chat-primary);
  color: #FFFFFF !important;
  font-size: 0.785rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  text-decoration: none !important;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.rct-card-btn:hover {
  background: var(--rct-chilli-red);
}

.rct-card-btn-link {
  flex: 1;
  margin-top: 0 !important;
  background: var(--rct-chat-primary) !important;
  text-align: center;
}

.rct-card-btn-quote {
  flex: 1.25;
  margin-top: 0 !important;
  background: var(--rct-chilli-red) !important;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.rct-card-btn-quote:hover {
  background: var(--rct-chilli-dark) !important;
  transform: translateY(-1px);
}

/* Typing Indicator Animation */
.rct-chat-typing {
  padding: 0.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--rct-chat-text-muted);
  font-size: 0.75rem;
  background: var(--rct-chat-body-bg);
}

.rct-typing-bubble {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  background: #FFFFFF;
  border: 1px solid var(--rct-chat-border);
  border-radius: 12px;
}

.rct-typing-bubble span {
  width: 5px;
  height: 5px;
  background: var(--rct-chilli-red);
  border-radius: 50%;
  animation: rctTypingBounce 1.4s infinite ease-in-out both;
}

.rct-typing-bubble span:nth-child(1) { animation-delay: -0.32s; }
.rct-typing-bubble span:nth-child(2) { animation-delay: -0.16s; }

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

/* Quick Options Chips Carousel */
.rct-chat-quick-replies {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.5rem 0.85rem;
  background: #FFFFFF;
  border-top: 1px solid var(--rct-chat-border);
  scrollbar-width: none;
}

.rct-chat-quick-replies::-webkit-scrollbar {
  display: none;
}

.rct-quick-chip {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  color: #334155;
  font-family: inherit;
  font-size: 0.785rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.rct-quick-chip:hover {
  background: var(--rct-chilli-light);
  border-color: var(--rct-chilli-red);
  color: var(--rct-chilli-red);
  transform: translateY(-1px);
}

.rct-quick-chip.is-wa-chip {
  color: #065F46;
  border-color: #A7F3D0;
  background: #ECFDF5;
}

.rct-quick-chip.is-wa-chip:hover {
  background: #D1FAE5;
  border-color: #10B981;
  color: #047857;
}

/* Inline Lead Card */
.rct-chat-lead-card {
  background: #FFFFFF;
  border-top: 2.5px solid var(--rct-chilli-red);
  border-bottom: 1px solid var(--rct-chat-border);
  padding: 0.85rem 1rem;
}

.rct-lead-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.rct-lead-card-header h4 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--rct-chat-primary);
}

.rct-lead-card-close {
  background: none;
  border: none;
  color: #94A3B8;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
}

.rct-lead-card-desc {
  font-size: 0.75rem;
  color: var(--rct-chat-text-muted);
  margin: 0 0 0.65rem;
}

.rct-lead-field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.rct-chat-input-control {
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  font-family: inherit;
  outline: none;
}

.rct-chat-input-control:focus {
  border-color: var(--rct-chilli-red);
}

.rct-lead-submit-btn {
  width: 100%;
  background: var(--rct-chilli-red);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  padding: 0.55rem;
  font-size: 0.825rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background-color 0.2s ease;
}

.rct-lead-submit-btn:hover {
  background: var(--rct-chilli-dark);
}

/* Chat Footer & Message Form */
.rct-chat-footer {
  background: #FFFFFF;
  border-top: 1px solid var(--rct-chat-border);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rct-chat-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #F8FAFC;
  border: 1px solid #CBD5E1;
  border-radius: 24px;
  padding: 0.35rem 0.45rem 0.35rem 0.85rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rct-chat-form:focus-within {
  border-color: var(--rct-chilli-red);
  background: #FFFFFF;
  box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.12);
}

#rct-chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--rct-chat-text);
  line-height: 1.4;
  padding: 0.25rem 0;
  max-height: 80px;
}

.rct-chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--rct-chilli-red);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #FFFFFF;
  transition: background-color 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.rct-chat-send-btn:hover {
  background: var(--rct-chilli-dark);
  transform: scale(1.05);
}

.rct-chat-send-btn:active {
  transform: scale(0.95);
}

.rct-chat-brand-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.685rem;
  color: #94A3B8;
  padding: 0 0.25rem;
}

.rct-chat-wa-direct {
  color: #059669;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.rct-chat-wa-direct:hover {
  text-decoration: underline;
}

/* ==========================================================================
   3. MOBILE RESPONSIVENESS & SAFE AREAS
   ========================================================================== */
@media (max-width: 991px) {
  /* On tablets/mobiles with sticky quote bar at bottom, entire vertical stack sits above it */
  .rct-floating-actions-stack {
    bottom: 80px;
    right: 20px;
  }
}

@media (max-width: 576px) {
  /* Mobile full-screen / responsive drawer chat window */
  .rct-chatbot-window {
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 100000 !important;
  }

  .rct-chat-header {
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  }

  .rct-chat-footer {
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  }

  .rct-lead-field-group {
    grid-template-columns: 1fr;
  }
}
