/* ============================================================
   APEX PRECISION — Luxury Studio Concierge Chatbot Styles
   Theme: Alabaster Silk (#FAFAF7), Sahara Gold (#C28736), Obsidian Typography (#181512)
   ============================================================ */

/* ── Positioning & Layout Alignment with WhatsApp Float ── */
.whatsapp-float {
  position: fixed;
  bottom: 24px;
  left: 24px;
  right: auto;
  width: 54px;
  height: 54px;
  background: #25D366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #FFFFFF;
  z-index: 998;
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.whatsapp-float:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 12px 30px rgba(37, 211, 102, 0.5);
  color: #FFFFFF;
}

/* ── Chatbot Floating Wrapper ── */
.apex-chatbot-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  left: auto;
  z-index: 999;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  pointer-events: none;
}

/* ── Floating Launcher Trigger ── */
.apex-cb-trigger {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C28736 0%, #9E651E 100%);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(194, 135, 54, 0.42), 0 2px 8px rgba(24, 21, 18, 0.15);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: absolute;
  bottom: 0;
  right: 0;
  pointer-events: auto;
  outline: none;
}

.apex-cb-trigger:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 14px 34px rgba(194, 135, 54, 0.6), 0 4px 12px rgba(24, 21, 18, 0.2);
}

.apex-cb-trigger:active {
  transform: scale(0.96);
}

.apex-cb-trigger svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  transition: transform 0.3s ease;
}

.apex-cb-trigger.active svg {
  transform: rotate(90deg);
}

/* Pulse Ring */
.apex-cb-pulse {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(194, 135, 54, 0.5);
  animation: apexPulse 2.4s cubic-bezier(0.25, 1, 0.5, 1) infinite;
  pointer-events: none;
}

@keyframes apexPulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Online Indicator on Launcher */
.apex-cb-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background: #10B981;
  border: 2px solid #FAFAF7;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

/* Tooltip */
.apex-cb-tooltip {
  position: absolute;
  right: 66px;
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  background: #181512;
  color: #FAFAF7;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(194, 135, 54, 0.4);
}

.apex-cb-tooltip::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 5px 0 5px 5px;
  border-style: solid;
  border-color: transparent transparent transparent #181512;
}

.apex-chatbot-wrapper:hover .apex-cb-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ── Chatbot Window (Light Luxury Glassmorphic) ── */
.apex-cb-window {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 390px;
  max-width: min(400px, 92vw);
  height: 560px;
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  background: rgba(250, 250, 247, 0.98);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(194, 135, 54, 0.35);
  border-radius: 22px;
  box-shadow: 0 25px 70px rgba(24, 21, 18, 0.16), 0 4px 20px rgba(194, 135, 54, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px) scale(0.95);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}

.apex-cb-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Chatbot Header ── */
.apex-cb-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, #181512 0%, #2A241C 100%);
  color: #FAFAF7;
  border-bottom: 2px solid #C28736;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

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

.apex-cb-avatar {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #C28736 0%, #9E651E 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: #FAFAF7;
  position: relative;
  box-shadow: 0 2px 10px rgba(194, 135, 54, 0.4);
  flex-shrink: 0;
}

.apex-cb-avatar-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #10B981;
  border-radius: 50%;
  border: 2px solid #181512;
}

.apex-cb-header-text h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: #FFFFFF;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.apex-cb-verified-badge {
  color: #C28736;
  font-size: 0.75rem;
  display: inline-flex;
}

.apex-cb-header-text span {
  font-size: 0.72rem;
  color: #DDAA5E;
  display: block;
  margin-top: 1px;
}

.apex-cb-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.apex-cb-btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #FAFAF7;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  text-decoration: none;
}

.apex-cb-btn-icon:hover {
  background: #C28736;
  color: #FFFFFF;
  border-color: #C28736;
  transform: scale(1.05);
}

.apex-cb-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.2s ease;
}

.apex-cb-close-btn:hover {
  color: #FFFFFF;
}

/* ── Quick Prompt Chips Bar ── */
.apex-cb-chips-bar {
  padding: 10px 14px;
  background: #F4EFEA;
  border-bottom: 1px solid #E8E2D8;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
  touch-action: pan-x;
  position: relative;
  z-index: 2;
}

.apex-cb-chips-bar::-webkit-scrollbar {
  display: none;
}

.apex-cb-chip {
  background: #FFFFFF;
  color: #4A443D;
  border: 1px solid #E2D9CD;
  padding: 5px 11px;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.apex-cb-chip:hover {
  background: #C28736;
  color: #FFFFFF;
  border-color: #C28736;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(194, 135, 54, 0.25);
}

/* ── Messages Container ── */
.apex-cb-messages {
  flex: 1 1 0;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #FAFAF7;
}

.apex-cb-messages::-webkit-scrollbar {
  width: 5px;
}

.apex-cb-messages::-webkit-scrollbar-thumb {
  background: rgba(194, 135, 54, 0.25);
  border-radius: 4px;
}

/* ── Message Bubbles ── */
.apex-cb-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: apexMsgFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

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

.apex-cb-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.86rem;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}

.apex-cb-msg-bot .apex-cb-msg-bubble {
  background: #FFFFFF;
  color: #181512;
  border: 1px solid #E8E2D8;
  border-left: 3px solid #C28736;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(24, 21, 18, 0.04);
}

.apex-cb-msg-user .apex-cb-msg-bubble {
  background: linear-gradient(135deg, #C28736 0%, #A87024 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(194, 135, 54, 0.28);
}

.apex-cb-msg-bubble strong {
  font-weight: 700;
  color: inherit;
}

.apex-cb-msg-bot .apex-cb-msg-bubble strong {
  color: #181512;
}

.apex-cb-msg-bubble a {
  color: #C28736;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  transition: color 0.2s ease;
}

.apex-cb-msg-user .apex-cb-msg-bubble a {
  color: #FFFFFF;
}

.apex-cb-msg-bubble a:hover {
  color: #9E651E;
}

.apex-cb-time {
  font-size: 0.65rem;
  color: #7A7268;
  margin-top: 3px;
  padding: 0 4px;
}

.apex-cb-msg-user .apex-cb-time {
  text-align: right;
}

/* ── In-Chat Interactive Quote Builder ── */
.apex-interactive-quote-builder {
  margin-top: 10px;
  background: #FFFFFF;
  border: 1.5px solid #C28736;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(194, 135, 54, 0.1);
}

.apex-quote-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: #181512;
  display: flex;
  align-items: center;
  gap: 6px;
}

.apex-quote-select, .apex-quote-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #D8CFC2;
  border-radius: 8px;
  background: #FAFAF7;
  font-family: inherit;
  font-size: 0.8rem;
  color: #181512;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.apex-quote-select:focus, .apex-quote-input:focus {
  border-color: #C28736;
  box-shadow: 0 0 0 2px rgba(194, 135, 54, 0.15);
}

.apex-quote-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.apex-quote-cb-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #4A443D;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.2s;
}

.apex-quote-cb-label:hover {
  background: #F4EFEA;
}

.apex-quote-cb-label input {
  margin-right: 6px;
  accent-color: #C28736;
}

.apex-quote-result {
  background: #181512;
  color: #FAFAF7;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.apex-quote-result-val {
  font-family: 'Space Grotesk', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: #DDAA5E;
}

.apex-quote-result-days {
  font-size: 0.72rem;
  color: #A8A29E;
  text-align: right;
}

/* ── In-Chat Lead Form ── */
.apex-lead-form {
  margin-top: 10px;
  background: #FFFFFF;
  border: 1px solid #E0D6C8;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.apex-lead-btn {
  background: linear-gradient(135deg, #C28736 0%, #A87024 100%);
  color: #FFFFFF;
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.apex-lead-btn:hover {
  background: linear-gradient(135deg, #DDAA5E 0%, #C28736 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(194, 135, 54, 0.35);
  color: #FFFFFF;
}

.apex-btn-wa-direct {
  background: #25D366;
  color: #FFFFFF !important;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-decoration: none !important;
  margin-top: 6px;
}

.apex-btn-wa-direct:hover {
  background: #20BA5A;
  color: #FFFFFF !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

/* ── Typing Indicator ── */
.apex-cb-typing {
  display: flex;
  gap: 5px;
  padding: 6px 4px;
  align-items: center;
}

.apex-cb-typing span {
  width: 7px;
  height: 7px;
  background: #C28736;
  border-radius: 50%;
  animation: apexTypingDot 1.4s infinite both;
}

.apex-cb-typing span:nth-child(1) { animation-delay: 0s; }
.apex-cb-typing span:nth-child(2) { animation-delay: 0.2s; }
.apex-cb-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Input Area ── */
.apex-cb-input-area {
  padding: 12px 16px;
  background: #FFFFFF;
  border-top: 1px solid #E8E2D8;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.apex-cb-input {
  flex: 1;
  background: #FAFAF7;
  border: 1px solid #E2D9CD;
  border-radius: 9999px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.85rem;
  color: #181512;
  outline: none;
  transition: all 0.2s ease;
}

.apex-cb-input:focus {
  border-color: #C28736;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(194, 135, 54, 0.12);
}

.apex-cb-input::placeholder {
  color: #9C9488;
}

.apex-cb-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C28736 0%, #9E651E 100%);
  border: none;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.apex-cb-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(194, 135, 54, 0.35);
}

.apex-cb-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.apex-cb-send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── Responsive Behavior for Laptops & Shorter Viewports ── */
@media (max-height: 740px) {
  .apex-chatbot-wrapper {
    bottom: 16px;
    right: 16px;
    left: auto;
  }
  .whatsapp-float {
    bottom: 16px;
    left: 16px;
    right: auto;
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
  }
  .apex-cb-trigger {
    width: 48px;
    height: 48px;
  }
  .apex-cb-window {
    bottom: 58px;
    max-height: calc(100vh - 75px);
    max-height: calc(100dvh - 75px);
    border-radius: 18px;
  }
  .apex-cb-header {
    padding: 12px 14px;
  }
  .apex-cb-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .apex-cb-messages {
    height: 220px;
    max-height: calc(100vh - 180px);
    max-height: calc(100dvh - 180px);
    padding: 12px;
    gap: 10px;
  }
  .apex-cb-input-area {
    padding: 8px 12px;
  }
}

@media (max-height: 600px) {
  .apex-cb-window {
    bottom: 52px;
    max-height: calc(100vh - 55px);
    max-height: calc(100dvh - 55px);
  }
  .apex-cb-messages {
    height: 175px;
    max-height: calc(100vh - 145px);
    max-height: calc(100dvh - 145px);
  }
}

/* ── Mobile Devices (≤ 480px) ── */
@media (max-width: 480px) {
  .whatsapp-float {
    bottom: 20px;
    left: 16px;
    right: auto;
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  }
  /* Automatically tuck away WhatsApp launcher when chatbot is open to avoid touch collision */
  body.chatbot-open .whatsapp-float {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transform: scale(0.6) translateY(20px) !important;
    z-index: 100 !important;
  }
  .apex-chatbot-wrapper {
    right: 16px;
    left: auto;
    bottom: 20px;
    z-index: 2000;
  }
  .apex-cb-trigger {
    width: 48px;
    height: 48px;
  }
  /* When chat is open on mobile, launcher gracefully hides to give full focus to chat */
  .apex-cb-trigger.active {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.6);
  }
  .apex-cb-tooltip {
    display: none;
  }
  .apex-cb-window {
    position: fixed;
    bottom: 16px;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: min(400px, 92vw);
    margin: 0 auto;
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
    border-radius: 20px;
    z-index: 2100;
  }
  .apex-cb-messages {
    max-height: calc(100vh - 220px);
    max-height: calc(100dvh - 220px);
    height: auto;
    flex: 1;
  }
}
