/* ============================================================
   ZambiaRent Chatbot – chatbot.css
   Floating chat widget that sits above the footer.
   Design system matches site: Plus Jakarta Sans, --zr-blue.
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --cb-blue:        #1a6fc4;
  --cb-blue-dark:   #155fa0;
  --cb-blue-light:  #e8f0fd;
  --cb-green:       #2ea44f;
  --cb-bg:          #f8f9fc;
  --cb-border:      #e4e8ee;
  --cb-text:        #1a1f2e;
  --cb-muted:       #6b7280;
  --cb-shadow:      0 8px 32px rgba(26,111,196,.22);
  --cb-radius:      18px;
  --cb-w:           360px;
  --cb-h:           520px;
}

/* ── Floating toggle button ──────────────────────────────── */
#cb-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cb-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26,111,196,.45);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1),
              background .2s, box-shadow .2s;
  outline: none;
}
#cb-toggle:hover {
  background: var(--cb-blue-dark);
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(26,111,196,.55);
}
#cb-toggle:active { transform: scale(.96); }
#cb-toggle svg,
#cb-toggle i { color: #fff; font-size: 1.5rem; pointer-events: none; }

/* Unread badge */
#cb-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  animation: cb-pulse 2s ease-in-out infinite;
}
#cb-badge.visible { display: flex; }

@keyframes cb-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50%       { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

/* ── Chat window ─────────────────────────────────────────── */
#cb-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: var(--cb-w);
  height: var(--cb-h);
  background: #fff;
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--cb-border);

  /* Hidden state */
  opacity: 0;
  transform: translateY(20px) scale(.97);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.34,1.56,.64,1);
}
#cb-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────── */
#cb-header {
  background: linear-gradient(135deg, var(--cb-blue) 0%, #0d4e96 100%);
  padding: 16px 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
.cb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.35);
}
.cb-header-info { flex: 1; min-width: 0; }
.cb-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.cb-header-status {
  font-size: 12px;
  color: rgba(255,255,255,.75);
  display: flex;
  align-items: center;
  gap: 5px;
}
.cb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: cb-blink 2.5s ease-in-out infinite;
}
@keyframes cb-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}
#cb-close {
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  transition: background .15s;
  flex-shrink: 0;
}
#cb-close:hover { background: rgba(255,255,255,.28); }
#cb-minimize {
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .85rem;
  transition: background .15s;
  flex-shrink: 0;
  margin-right: 4px;
}
#cb-minimize:hover { background: rgba(255,255,255,.28); }

/* ── Messages area ───────────────────────────────────────── */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cb-bg);
  scroll-behavior: smooth;
}
#cb-messages::-webkit-scrollbar { width: 4px; }
#cb-messages::-webkit-scrollbar-track { background: transparent; }
#cb-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── Message bubbles ─────────────────────────────────────── */
.cb-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: cb-slide-in .2s ease both;
}
@keyframes cb-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bot message */
.cb-msg.bot { align-self: flex-start; }
.cb-msg.bot .cb-bubble {
  background: #fff;
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.cb-bot-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cb-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  flex-shrink: 0;
  margin-top: 2px;
}

/* User message */
.cb-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.cb-msg.user .cb-bubble {
  background: var(--cb-blue);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}

.cb-bubble {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.cb-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cb-bubble a:hover { opacity: .8; }

/* ── Property card inside chat ───────────────────────────── */
.cb-prop-card {
  background: #fff;
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 6px;
  transition: box-shadow .15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.cb-prop-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
  color: inherit;
}
.cb-prop-card img {
  width: 100%;
  height: 90px;
  object-fit: cover;
}
.cb-prop-info { padding: 9px 11px 10px; }
.cb-prop-price {
  font-weight: 700;
  color: var(--cb-blue);
  font-size: 13px;
}
.cb-prop-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cb-text);
  margin: 2px 0 1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cb-prop-loc {
  font-size: 11px;
  color: var(--cb-muted);
}
.cb-prop-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.cb-chip {
  font-size: 10px;
  background: var(--cb-blue-light);
  color: var(--cb-blue);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.cb-chip.green { background: #dcfce7; color: #166534; }

/* ── Typing indicator ────────────────────────────────────── */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: cb-slide-in .2s ease both;
}
.cb-typing-bubble {
  background: #fff;
  border: 1px solid var(--cb-border);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.cb-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: cb-bounce .9s ease-in-out infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: .15s; }
.cb-typing-dot:nth-child(3) { animation-delay: .30s; }
@keyframes cb-bounce {
  0%, 80%, 100% { transform: scale(1); opacity: .5; }
  40%            { transform: scale(1.3); opacity: 1; }
}

/* ── Quick reply chips ───────────────────────────────────── */
#cb-quick-replies {
  padding: 6px 14px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--cb-bg);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}
.cb-quick-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--cb-blue);
  background: #fff;
  color: var(--cb-blue);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.cb-quick-btn:hover {
  background: var(--cb-blue);
  color: #fff;
}

/* ── City buttons ────────────────────────────────────────── */
.cb-city-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.cb-city-btn {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 20px;
  border: 1.5px solid #dde1e9;
  background: #fff;
  color: var(--cb-muted);
  cursor: pointer;
  transition: all .15s;
}
.cb-city-btn:hover {
  border-color: var(--cb-blue);
  color: var(--cb-blue);
  background: var(--cb-blue-light);
}

/* ── Stats grid in chat ──────────────────────────────────── */
.cb-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.cb-stat-box {
  background: var(--cb-blue-light);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.cb-stat-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--cb-blue);
  display: block;
  line-height: 1.1;
}
.cb-stat-lbl {
  font-size: 10px;
  color: var(--cb-muted);
  font-weight: 500;
}

/* ── Input area ──────────────────────────────────────────── */
#cb-footer {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--cb-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
#cb-input {
  flex: 1;
  border: 1.5px solid var(--cb-border);
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: var(--cb-bg);
  color: var(--cb-text);
  transition: border-color .2s, box-shadow .2s;
  resize: none;
  height: 40px;
  line-height: 1.4;
}
#cb-input:focus {
  border-color: var(--cb-blue);
  box-shadow: 0 0 0 3px rgba(26,111,196,.1);
  background: #fff;
}
#cb-input::placeholder { color: #b0b7c3; }
#cb-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cb-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
#cb-send:hover { background: var(--cb-blue-dark); transform: scale(1.08); }
#cb-send:active { transform: scale(.95); }
#cb-send:disabled { background: #d1d5db; cursor: not-allowed; transform: none; }

/* ── Welcome banner (first open) ────────────────────────── */
.cb-welcome {
  background: linear-gradient(135deg, var(--cb-blue) 0%, #0d4e96 100%);
  border-radius: 14px;
  padding: 14px 16px;
  color: #fff;
  margin-bottom: 4px;
}
.cb-welcome-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.cb-welcome-sub   { font-size: 12px; opacity: .85; line-height: 1.5; }

/* ── Timestamp ───────────────────────────────────────────── */
.cb-time {
  font-size: 10px;
  color: #c4c9d4;
  text-align: center;
  margin: 4px 0;
  align-self: center;
}

/* ── "View all" link row ─────────────────────────────────── */
.cb-view-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cb-blue);
  text-decoration: none;
  background: var(--cb-blue-light);
  padding: 5px 12px;
  border-radius: 20px;
  margin-top: 6px;
  transition: background .15s;
}
.cb-view-all:hover { background: #d1e3fa; color: var(--cb-blue); }

/* ── Divider ─────────────────────────────────────────────── */
.cb-divider {
  border: none;
  border-top: 1px solid var(--cb-border);
  margin: 4px 0;
}

/* ── Mobile responsive ───────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --cb-w: calc(100vw - 24px);
    --cb-h: 72vh;
  }
  #cb-window {
    bottom: 90px;
    right: 12px;
  }
  #cb-toggle {
    bottom: 18px;
    right: 18px;
    width: 54px;
    height: 54px;
  }
}
