/* ============================================================================
   DOURADO CHATBOT WIDGET  (upload to: assets/css/chatbot.css)
   Dark + gold to match the Dourado Luxury Cars brand.
   Everything is namespaced with .dcb- so it can't clash with site styles.
   ========================================================================== */

:root {
  --dcb-gold: #c9a35b;
  --dcb-gold-dark: #a8834a;
  --dcb-dark: #16161a;
  --dcb-dark-2: #1f1f25;
  --dcb-dark-3: #2a2a32;
  --dcb-text: #f2efe9;
  --dcb-muted: #9b9890;
  --dcb-radius: 14px;
}

/* ---- Launcher bubble (stacked ABOVE the floating WhatsApp button) --------- */
.dcb-launcher {
  position: fixed;
  left: 1.25rem;   /* same column as .floating-whatsapp */
  bottom: 78px;    /* 20px + 46px button + 12px gap = right above WhatsApp */
  z-index: 99990;
  height: 46px;    /* identical size + expand-on-hover, same as WhatsApp Us */
  min-width: 46px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--dcb-gold), var(--dcb-gold-dark));
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
  display: flex;
  align-items: center;
  padding: 0;
  transition: padding .3s ease;
}
.dcb-launcher:hover { padding-right: 1rem; }
.dcb-launcher-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dcb-launcher svg { width: 24px; height: 24px; fill: #16161a; }
.dcb-launcher-label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #16161a;
  font-family: "Oswald", 'Segoe UI', sans-serif;
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .02em;
  transition: max-width .35s ease;
}
.dcb-launcher:hover .dcb-launcher-label { max-width: 150px; }

/* ---- Teaser bubble ("chat with our AI assistant") -------------------------- */
.dcb-teaser {
  position: fixed;
  left: calc(1.25rem + 56px);
  bottom: 82px;               /* vertically centered on the launcher */
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--dcb-dark-2);
  border: 1px solid var(--dcb-gold);
  color: var(--dcb-text);
  border-radius: 999px;
  padding: 9px 12px 9px 15px;
  font-family: 'Segoe UI', system-ui, Arial, sans-serif;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
  animation: dcbTeaserIn .35s ease-out;
  max-width: min(300px, calc(100vw - 110px));
}
.dcb-teaser strong { color: var(--dcb-gold); font-weight: 700; }
.dcb-teaser-close {
  border: none;
  background: none;
  color: var(--dcb-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 3px 5px;
  flex: 0 0 auto;
}
.dcb-teaser-close:hover { color: var(--dcb-text); }
@keyframes dcbTeaserIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.dcb-launcher .dcb-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #e04545;
  color: #fff;
  font: 700 12px/20px Arial, sans-serif;
  text-align: center;
  padding: 0 5px;
  display: none;
}
.dcb-launcher.dcb-has-badge .dcb-badge { display: block; }

/* ---- Panel ---------------------------------------------------------------- */
.dcb-panel {
  position: fixed;
  left: 20px;
  bottom: 136px;   /* above the launcher, which is above WhatsApp */
  z-index: 99991;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 160px);
  background: var(--dcb-dark);
  border: 1px solid rgba(201, 163, 91, .25);
  border-radius: var(--dcb-radius);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}
.dcb-panel.dcb-open {
  display: flex;
  animation: dcbRise .22s ease-out;
}
@keyframes dcbRise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Header ---------------------------------------------------------------- */
.dcb-head {
  background: linear-gradient(135deg, #23222a, #17161c);
  border-bottom: 1px solid rgba(201, 163, 91, .3);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.dcb-head-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--dcb-gold), var(--dcb-gold-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.dcb-head-avatar svg { width: 22px; height: 22px; fill: #16161a; }
.dcb-head-titles { flex: 1; min-width: 0; }
.dcb-head-titles strong { display: block; color: var(--dcb-text); font-size: 15px; }
.dcb-head-titles span {
  color: var(--dcb-gold);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.dcb-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4caf50; display: inline-block;
}
.dcb-head button {
  background: none; border: none; cursor: pointer; padding: 6px;
  color: var(--dcb-muted); border-radius: 8px;
}
.dcb-head button:hover { color: var(--dcb-text); background: rgba(255,255,255,.06); }
.dcb-head button svg { width: 20px; height: 20px; fill: currentColor; display: block; }

/* ---- Messages --------------------------------------------------------------- */
.dcb-msgs {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;   /* don't drag the page behind the chat */
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--dcb-dark-3) transparent;
}
.dcb-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.dcb-msg.dcb-bot {
  align-self: flex-start;
  background: var(--dcb-dark-2);
  color: var(--dcb-text);
  border-bottom-left-radius: 4px;
}
.dcb-msg.dcb-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--dcb-gold), var(--dcb-gold-dark));
  color: #171310;
  border-bottom-right-radius: 4px;
}
.dcb-msg a { color: var(--dcb-gold); text-decoration: underline; }
.dcb-msg.dcb-user a { color: #171310; }
.dcb-bullet { color: var(--dcb-gold); font-weight: 700; }

/* typing indicator */
.dcb-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.dcb-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dcb-muted);
  animation: dcbBlink 1.2s infinite;
}
.dcb-typing i:nth-child(2) { animation-delay: .2s; }
.dcb-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes dcbBlink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }

/* ---- Car cards ---------------------------------------------------------------- */
.dcb-cars {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  max-width: 100%;
  align-self: stretch;
  scrollbar-width: thin;
}
.dcb-car {
  flex: 0 0 200px;
  background: var(--dcb-dark-2);
  border: 1px solid rgba(201, 163, 91, .2);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  transition: border-color .15s;
}
.dcb-car:hover { border-color: var(--dcb-gold); }
.dcb-car img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
  background: var(--dcb-dark-3);
}
.dcb-car-body { padding: 9px 11px 11px; }
.dcb-car-title {
  color: var(--dcb-text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dcb-car-price { color: var(--dcb-gold); font-size: 13px; font-weight: 700; margin-top: 5px; }
.dcb-car-meta { color: var(--dcb-muted); font-size: 11px; margin-top: 3px; }

/* ---- Quick replies -------------------------------------------------------------- */
.dcb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 95%;
}
.dcb-chip {
  border: 1px solid var(--dcb-gold);
  color: var(--dcb-gold);
  background: transparent;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.dcb-chip:hover { background: var(--dcb-gold); color: #171310; }

/* ---- WhatsApp handoff row --------------------------------------------------------- */
.dcb-wa {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #25d366;
  color: #06300f;
  font-weight: 700;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 22px;
  text-decoration: none;
}
.dcb-wa svg { width: 18px; height: 18px; fill: #06300f; }
.dcb-wa:hover { filter: brightness(1.05); }

/* ---- Pre-chat gate form ------------------------------------------------------------ */
.dcb-form {
  align-self: stretch;
  background: var(--dcb-dark-2);
  border: 1px solid rgba(201, 163, 91, .25);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.dcb-f-in {
  background: var(--dcb-dark);
  border: 1px solid var(--dcb-dark-3);
  color: var(--dcb-text);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.dcb-f-in:focus { border-color: var(--dcb-gold); }
.dcb-f-in::placeholder { color: var(--dcb-muted); }
.dcb-f-phonerow { display: flex; gap: 8px; }
.dcb-f-cc {
  flex: 0 0 118px;
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dcb-f-phone { flex: 1; min-width: 0; }
/* honeypot: invisible to humans, tempting to bots */
.dcb-f-hp {
  position: absolute !important;
  left: -6000px !important;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.dcb-f-btn {
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--dcb-gold), var(--dcb-gold-dark));
  color: #171310;
  font-weight: 700;
  font-size: 14px;
  border-radius: 22px;
  padding: 11px;
  transition: filter .15s;
}
.dcb-f-btn:hover { filter: brightness(1.08); }
.dcb-f-err { color: #e05545; font-size: 12.5px; min-height: 0; }
.dcb-f-err:empty { display: none; }
.dcb-f-note { color: var(--dcb-muted); font-size: 11px; text-align: center; }

/* ---- Input ---------------------------------------------------------------------- */
.dcb-inputrow {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  background: var(--dcb-dark);
}
.dcb-input {
  flex: 1;
  background: var(--dcb-dark-2);
  border: 1px solid var(--dcb-dark-3);
  color: var(--dcb-text);
  border-radius: 22px;
  padding: 11px 16px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 90px;
  font-family: inherit;
}
.dcb-input:focus { border-color: var(--dcb-gold); }
.dcb-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--dcb-gold), var(--dcb-gold-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.dcb-send:disabled { opacity: .45; cursor: default; }
.dcb-send svg { width: 20px; height: 20px; fill: #16161a; }
.dcb-note {
  text-align: center;
  color: var(--dcb-muted);
  font-size: 10.5px;
  padding: 0 10px 8px;
  background: var(--dcb-dark);
}

/* ---- Mobile: full screen, premium feel ---------------------------------------------- */
@media (max-width: 520px) {
  .dcb-panel {
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;      /* fills the real visible area, shrinks with the keyboard */
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .dcb-panel.dcb-open { animation: dcbSlideUp .26s ease-out; }
  .dcb-launcher { bottom: 78px; }               /* stays above WhatsApp on mobile too */
  .dcb-teaser { font-size: 12.5px; }

  /* iOS Safari auto-zooms any input under 16px - this is what caused the
     "zoom in" jump when tapping the chat. 16px = no zoom, ever. */
  .dcb-input,
  .dcb-f-in {
    font-size: 16px;
  }

  /* keyboard-safe input row (iPhone home-bar area) */
  .dcb-inputrow { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .dcb-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .dcb-note { display: none; }   /* reclaim space on small screens */
}
@keyframes dcbSlideUp {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

/* page behind the chat can't scroll while the chat is open on mobile */
html.dcb-lock, html.dcb-lock body { overflow: hidden !important; height: 100%; }