/* ═══════════════════════════════════════
   AI Property Assistant — Chat Widget
   ═══════════════════════════════════════ */

/* ── Bubble ── */
#chatWidget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#chatBubble {
  height: 48px;
  padding: 0 18px 0 14px;
  border-radius: 28px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  box-shadow: 0 6px 24px rgba(79,70,229,.45);
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
#chatBubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(79,70,229,.6);
}
.chat-bubble-label {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}

/* ── Welcome Tooltip ── */
.chat-tooltip {
  background: #1f2937;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: .82rem;
  line-height: 1.5;
  margin-bottom: 10px;
  max-width: 200px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  animation: chatFadeIn .4s ease;
  position: relative;
}
.chat-tooltip span { color: #93c5fd; font-size: .78rem; }
.chat-tooltip-arrow {
  position: absolute;
  bottom: -7px;
  right: 24px;
  width: 14px;
  height: 8px;
  background: #1f2937;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Avatar wrap */
.chat-avatar-wrap {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Panel ── */
.chat-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 360px;
  max-height: 560px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.08);
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideUp .25s ease;
}
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  flex-shrink: 0;
}
.chat-header-left  { display: flex; align-items: center; gap: 10px; }
.chat-avatar       { font-size: 1.6rem; line-height: 1; }
.chat-header-title { font-size: .95rem; font-weight: 700; }
.chat-header-sub   { font-size: .72rem; opacity: .8; margin-top: 1px; }
.chat-header-actions { display: flex; gap: 6px; }
.chat-action-btn {
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.chat-action-btn:hover { background: rgba(255,255,255,.28); }

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: #f8fafc;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── Message Bubbles ── */
.chat-msg { display: flex; flex-direction: column; max-width: 92%; }
.chat-msg-user { align-self: flex-end; align-items: flex-end; }
.chat-msg-bot  { align-self: flex-start; align-items: flex-start; }

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .875rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg-user .chat-msg-bubble {
  background: linear-gradient(135deg, #1a56db, #0ea5e9);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-bot .chat-msg-bubble {
  background: #fff;
  color: #1f2937;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ── Typing indicator ── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  width: fit-content;
}
.chat-typing span {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: chatBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatBounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-6px); }
}

/* ── Quick Suggestion Chips ── */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.chat-chip {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: .76rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.chat-chip:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* ── Property Cards ── */
.chat-msg-cards { max-width: 100%; width: 100%; }
.chat-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.chat-card {
  display: flex;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .2s, transform .15s;
  cursor: pointer;
}
.chat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  transform: translateY(-1px);
}
.chat-card-img {
  width: 80px;
  height: 70px;
  flex-shrink: 0;
  overflow: hidden;
  background: #f3f4f6;
}
.chat-card-img img { width: 100%; height: 100%; object-fit: cover; }
.chat-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.chat-card-body { padding: 8px 10px; flex: 1; min-width: 0; }
.chat-card-title {
  font-size: .8rem;
  font-weight: 700;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-card-area  { font-size: .72rem; color: #6b7280; margin-top: 2px; }
.chat-card-price { font-size: .82rem; font-weight: 700; color: #1a56db; margin-top: 3px; }
.chat-card-specs { font-size: .7rem; color: #9ca3af; margin-top: 2px; }

/* ── Active Filter Chips Strip ── */
.chat-filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 14px 6px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
}
.chat-fchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s;
}
.chat-fchip:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* ── Trust Badges on Cards ── */
.cc-badge {
  display: inline-block;
  font-size: .65rem;
  padding: 1px 4px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 2px;
}
.cc-featured { background: #fef3c7; }
.cc-verified { background: #d1fae5; }
.cc-owner    { background: #eff6ff; }

/* ── Card enhancements ── */
.chat-card-img { position: relative; }
.chat-card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; }
.chat-card-title { font-size: .8rem; font-weight: 700; color: #1f2937; flex: 1; line-height: 1.3; }
.chat-card-suffix { font-size: .7rem; color: #9ca3af; }
.chat-card-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cc-chip {
  font-size: .68rem; font-weight: 600;
  background: #f3f4f6; color: #6b7280;
  padding: 2px 7px; border-radius: 10px;
  border: 1px solid #e5e7eb;
}

/* AI Match % */
.cc-match { font-size: .72rem; font-weight: 700; margin-top: 4px; }

/* Dynamic badges on chat cards */
.cc-dyn-wrap { position: absolute; top: 4px; right: 4px; display: flex; flex-direction: column; gap: 2px; }
.cc-dyn { font-size: .65rem; font-weight: 700; padding: 1px 5px; border-radius: 8px; }
.cc-new { background: rgba(16,185,129,.9); color: #fff; }
.cc-hot { background: rgba(239,68,68,.9);  color: #fff; }
.cc-roi { background: rgba(245,158,11,.9); color: #fff; }

/* ── Smart Suggestion Chips (no results) ── */
.chat-suggest-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.chat-suggest-btn {
  background: #fff;
  border: 1.5px solid #1a56db;
  color: #1a56db;
  font-size: .8rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.chat-suggest-btn:hover {
  background: #eff6ff;
}

/* ── View All Link ── */
.chat-view-all {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  color: #1a56db;
  text-decoration: none;
  padding: 6px 12px;
  background: #eff6ff;
  border-radius: 20px;
  border: 1px solid #bfdbfe;
  margin-top: 2px;
  transition: background .15s;
}
.chat-view-all:hover { background: #dbeafe; }

/* ── Input Area ── */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 22px;
  padding: 9px 16px;
  font-size: .875rem;
  outline: none;
  font-family: inherit;
  transition: border-color .2s;
  background: #f8fafc;
}
.chat-input:focus { border-color: #1a56db; background: #fff; }
.chat-input::placeholder { color: #9ca3af; }

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .2s, transform .15s;
}
.chat-send-btn:hover    { transform: scale(1.05); }
.chat-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Mobile ── */
@media (max-width: 480px) {
  #chatWidget { bottom: 16px; right: 16px; }
  .chat-panel {
    width: calc(100vw - 32px);
    right: 0;
    max-height: 70vh;
    bottom: 66px;
  }
}
