/* ============================================================
   ASHMIL HOMES — Chatbot Widget
   Floating bottom-right. Sits ABOVE the WhatsApp button.
   Full mobile-first positioning with safe-area support.
   ============================================================ */

.chatbot-root {
  --cb-navy: #0A1A2F;
  --cb-navy-deep: #051020;
  --cb-gold: #D4AF37;
  --cb-gold-dark: #B8860B;
  position: fixed;
  z-index: 46;
  font-family: 'Manrope', sans-serif;
  right: 1rem;
  /* Mobile: WhatsApp sits at bottom 5rem (80px). Chatbot needs
     to sit ABOVE it with a gap. 80px + 56px + 16px gap = 152px */
  bottom: calc(env(safe-area-inset-bottom, 0px) + 9.5rem);
}
@media (min-width: 768px) {
  .chatbot-root {
    right: 1.5rem;
    /* Desktop: WhatsApp at bottom 1.5rem (24px) + 56px height + 16px gap */
    bottom: 5.5rem;
  }
}
/* Small phones in landscape — pull it tighter */
@media (max-height: 500px) {
  .chatbot-root {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
  }
}

/* ---- Launcher button ---- */
.chatbot-launcher {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--cb-gold) 0%, var(--cb-gold-dark) 100%);
  color: var(--cb-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px -6px rgba(212,175,55,0.55), 0 4px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  border: 0;
  transition: transform .25s cubic-bezier(.4,0,.2,1), box-shadow .25s ease;
  position: relative;
}
.chatbot-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 12px 30px -6px rgba(212,175,55,0.7), 0 6px 16px rgba(0,0,0,0.2);
}
.chatbot-launcher:active { transform: scale(0.96); }
.chatbot-launcher svg { width: 26px; height: 26px; }

/* Pulsing dot */
.chatbot-launcher::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #10b981;
  border: 2px solid #fff;
  animation: cbPulse 2s ease-in-out infinite;
}
.chatbot-root.open .chatbot-launcher::after { display: none; }
@keyframes cbPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.85; }
}

/* ---- Panel ---- */
.chatbot-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(calc(100vw - 2rem), 380px);
  height: min(560px, calc(100vh - 8rem));
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 24px 60px -12px rgba(5,16,32,0.35), 0 8px 24px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.4,.64,1), opacity .2s ease;
}
.chatbot-root.open .chatbot-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ---- Header ---- */
.chatbot-header {
  background: linear-gradient(135deg, var(--cb-navy) 0%, var(--cb-navy-deep) 100%);
  color: #fff;
  padding: 1rem 1.125rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--cb-gold) 0%, var(--cb-gold-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cb-navy);
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}
.chatbot-header-text { flex: 1; min-width: 0; }
.chatbot-name {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.1;
}
.chatbot-status {
  font-size: .6875rem;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-top: .15rem;
}
.chatbot-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.25);
}
.chatbot-close {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.75);
  padding: .375rem;
  border-radius: .5rem;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chatbot-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.chatbot-close svg { width: 20px; height: 20px; }

/* ---- Messages area ---- */
.chatbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  scroll-behavior: smooth;
}
.chatbot-body::-webkit-scrollbar { width: 6px; }
.chatbot-body::-webkit-scrollbar-track { background: transparent; }
.chatbot-body::-webkit-scrollbar-thumb { background: rgba(10,26,47,0.15); border-radius: 999px; }

.chatbot-msg {
  max-width: 85%;
  padding: .75rem .875rem;
  border-radius: 1rem;
  font-size: .875rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: cbMsgIn .35s cubic-bezier(.4,0,.2,1) both;
}
@keyframes cbMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chatbot-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--cb-navy);
  border: 1px solid #eef1f5;
  border-bottom-left-radius: .375rem;
  box-shadow: 0 2px 6px rgba(5,16,32,0.04);
}
.chatbot-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--cb-navy) 0%, var(--cb-navy-deep) 100%);
  color: #fff;
  border-bottom-right-radius: .375rem;
}
.chatbot-msg a {
  color: var(--cb-gold);
  font-weight: 600;
  text-decoration: underline;
}
.chatbot-msg.bot a { color: var(--cb-gold-dark); }

/* Typing indicator */
.chatbot-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #eef1f5;
  padding: .75rem .875rem;
  border-radius: 1rem;
  border-bottom-left-radius: .375rem;
  display: flex;
  gap: .25rem;
  align-items: center;
  box-shadow: 0 2px 6px rgba(5,16,32,0.04);
}
.chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #cbd5e1;
  animation: cbTyping 1.4s infinite ease-in-out;
}
.chatbot-typing span:nth-child(2) { animation-delay: .2s; }
.chatbot-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cbTyping {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---- Quick suggestion chips ---- */
.chatbot-suggestions {
  padding: 0 1rem .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  background: #f8fafc;
  flex-shrink: 0;
}
.chatbot-chip {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: var(--cb-navy);
  font-size: .75rem;
  font-weight: 500;
  padding: .375rem .75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .1s ease;
  font-family: inherit;
}
.chatbot-chip:hover {
  border-color: var(--cb-gold);
  background: rgba(212,175,55,0.06);
}
.chatbot-chip:active { transform: scale(.96); }

/* ---- Input row ---- */
.chatbot-footer {
  padding: .75rem;
  background: #fff;
  border-top: 1px solid #eef1f5;
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-shrink: 0;
}
.chatbot-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: .625rem 1rem;
  font-size: .875rem;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
  font-family: inherit;
  background: #f8fafc;
  color: var(--cb-navy);
  min-width: 0;
}
.chatbot-input:focus {
  border-color: var(--cb-gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.15);
  background: #fff;
}
.chatbot-input::placeholder { color: #9ca3af; }
.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, var(--cb-gold) 0%, var(--cb-gold-dark) 100%);
  color: var(--cb-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s ease, opacity .2s ease;
}
.chatbot-send:hover { transform: scale(1.05); }
.chatbot-send:active { transform: scale(.94); }
.chatbot-send:disabled { opacity: .5; cursor: not-allowed; }
.chatbot-send svg { width: 18px; height: 18px; }

/* ---- "Talk to human" link ---- */
.chatbot-human {
  text-align: center;
  padding: .5rem 1rem .75rem;
  font-size: .75rem;
  color: #64748b;
  background: #fff;
}
.chatbot-human a {
  color: var(--cb-gold-dark);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed rgba(184,134,11,0.4);
}
.chatbot-human a:hover { border-bottom-style: solid; }

/* ============================================================
   MOBILE — full-screen sheet, clears WhatsApp + bottom bar
   ============================================================ */
@media (max-width: 640px) {
  .chatbot-panel {
    position: fixed;
    right: .5rem;
    left: .5rem;
    top: 4rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8.5rem);
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 1.25rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8.5rem);
  }
  /* When open on mobile, chat panel sits above the mobile action bar */
  .chatbot-root.open .chatbot-panel {
    /* no transform shift on mobile — full fixed already */
  }
}

/* Extra small phones */
@media (max-width: 380px) {
  .chatbot-root { right: .75rem; }
  .chatbot-panel {
    right: .25rem;
    left: .25rem;
    top: 3.5rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8rem);
  }
}

/* Landscape phones — tighten */
@media (max-height: 500px) and (max-width: 900px) {
  .chatbot-panel {
    top: 3rem;
    bottom: 5rem;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .chatbot-panel,
  .chatbot-msg,
  .chatbot-launcher,
  .chatbot-send,
  .chatbot-chip { animation: none !important; transition: none !important; }
  .chatbot-launcher::after { animation: none; }
}
