/* ============================================================
   PROPLAND CHATBOT - น้อง Propland
   Pixel 3D Floating Chat Widget
   ============================================================ */

/* =====================
   PIXEL ART KEYFRAMES
   ===================== */

/* ลอยขึ้นลง แบบ pixel steps */
@keyframes propbot-float {
  0%   { transform: translateY(0px)  scale(1);    }
  25%  { transform: translateY(-5px) scale(1.02); }
  50%  { transform: translateY(-7px) scale(1.03); }
  75%  { transform: translateY(-5px) scale(1.02); }
  100% { transform: translateY(0px)  scale(1);    }
}

/* กระโดดเมื่อ hover */
@keyframes propbot-hop {
  0%,100% { transform: translateY(0px)   scale(1);    }
  30%      { transform: translateY(-10px) scale(1.05); }
  60%      { transform: translateY(-4px)  scale(1.02); }
}

@keyframes propbot-glow {
  0%, 100% { filter: drop-shadow(0 3px 8px rgba(232,93,74,0.3)); }
  50%       { filter: drop-shadow(0 5px 16px rgba(232,93,74,0.65)); }
}

@keyframes propbot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-7px); opacity: 1; }
}

@keyframes propbot-slide-up {
  from { transform: scale(0.85) translateY(24px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes propbot-badge-pop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes propbot-msg-in-bot {
  from { transform: translateX(-12px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes propbot-msg-in-user {
  from { transform: translateX(12px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* =====================
   FAB BUTTON (เปิด/ปิด)
   ===================== */
#propbot-fab {
  position: fixed;
  right: 45px;        /* เท่ากับ scrollToHome */
  bottom: 106px;      /* scrollToHome bottom:45 + height:50 + gap:11 */
  width: 50px;        /* เท่ากับ scrollToHome */
  height: 50px;
  cursor: pointer;
  z-index: 9998;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pixel wrap — ลอยขึ้นลง */
.propbot-pixel-wrap {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: propbot-float 3s steps(8) infinite, propbot-glow 3s ease-in-out infinite;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#propbot-fab:hover .propbot-pixel-wrap {
  animation: propbot-hop 0.6s steps(6) infinite, propbot-glow 1.2s ease-in-out infinite;
}

.propbot-pixel-wrap svg {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
}

/* Badge การแจ้งเตือน */
#propbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  background: #F5C518;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #181A20;
  font-family: 'Poppins', sans-serif;
  z-index: 1;
  animation: propbot-badge-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

/* =====================
   CHAT WINDOW
   ===================== */
#propbot-window {
  position: fixed;
  right: 20px;
  bottom: 176px;
  width: 360px;
  height: 530px;
  background: #FFFFFF;
  border-radius: 22px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.16), 0 4px 12px rgba(232,93,74,0.12);
  display: flex;
  flex-direction: column;
  z-index: 9997;
  overflow: hidden;
  transform: scale(0.82) translateY(28px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1),
              opacity 0.25s ease;
  transform-origin: bottom right;
}

#propbot-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
  animation: propbot-slide-up 0.35s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

/* =====================
   HEADER
   ===================== */
.propbot-header {
  background: linear-gradient(135deg, #E85D4A 0%, #c94535 100%);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.propbot-header-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(1px 1px 0 #5A100A);
}

.propbot-header-avatar svg {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.propbot-header-info {
  flex: 1;
  min-width: 0;
}

.propbot-header-name {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #FFFFFF;
  margin: 0;
  line-height: 1.2;
}

.propbot-header-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px;
  color: rgba(255,255,255,0.82);
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.propbot-online-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 5px rgba(74,222,128,0.7);
}

.propbot-close-btn {
  background: rgba(255,255,255,0.18);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: 13px;
  transition: background 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.propbot-close-btn:hover {
  background: rgba(255,255,255,0.32);
}

/* =====================
   MESSAGES AREA
   ===================== */
.propbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F6F7F9;
  scroll-behavior: smooth;
}

.propbot-messages::-webkit-scrollbar { width: 4px; }
.propbot-messages::-webkit-scrollbar-track { background: transparent; }
.propbot-messages::-webkit-scrollbar-thumb { background: #DDD; border-radius: 2px; }

/* =====================
   MESSAGE BUBBLES
   ===================== */
.propbot-msg {
  display: flex;
  gap: 7px;
  align-items: flex-end;
  max-width: 88%;
}

.propbot-msg.bot {
  align-self: flex-start;
  animation: propbot-msg-in-bot 0.25s ease forwards;
}

.propbot-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  animation: propbot-msg-in-user 0.25s ease forwards;
}

.propbot-msg-avatar-sm {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(1px 1px 0 #5A100A);
}

.propbot-msg-bubble {
  padding: 9px 13px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.propbot-msg.bot .propbot-msg-bubble {
  background: #FFFFFF;
  color: #181A20;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.propbot-msg.user .propbot-msg-bubble {
  background: #E85D4A;
  color: #FFFFFF;
  border-radius: 16px 16px 4px 16px;
}

/* =====================
   TYPING INDICATOR
   ===================== */
.propbot-typing {
  display: flex;
  gap: 7px;
  align-items: flex-end;
  align-self: flex-start;
}

.propbot-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #FFFFFF;
  padding: 12px 15px;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.propbot-typing-bubble span {
  width: 7px;
  height: 7px;
  background: #E85D4A;
  border-radius: 50%;
  animation: propbot-bounce 1.3s ease infinite;
}

.propbot-typing-bubble span:nth-child(2) { animation-delay: 0.18s; }
.propbot-typing-bubble span:nth-child(3) { animation-delay: 0.36s; }

/* =====================
   PROPERTY CARDS (in chat)
   ===================== */
.propbot-prop-card {
  display: block;
  background: #FFFFFF;
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.09);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-top: 6px;
  border: 1px solid rgba(232,93,74,0.1);
}

.propbot-prop-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(232,93,74,0.22);
  text-decoration: none;
}

.propbot-prop-card:last-child {
  margin-bottom: 2px;
}

.propbot-prop-img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}

.propbot-prop-img-placeholder {
  width: 100%;
  height: 90px;
  background: linear-gradient(135deg, rgba(232,93,74,0.1), rgba(245,197,24,0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #E85D4A;
  font-size: 26px;
}

.propbot-prop-body {
  padding: 9px 11px 10px;
}

.propbot-prop-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 12px;
  color: #181A20;
  margin: 0 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.propbot-prop-price {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #E85D4A;
  margin: 0 0 2px;
}

.propbot-prop-meta {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: #888;
  margin: 0;
}

/* =====================
   QUICK SUGGESTION CHIPS
   ===================== */
.propbot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.propbot-chip {
  background: #FFF0EE;
  border: 1px solid rgba(232,93,74,0.35);
  color: #E85D4A;
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.propbot-chip:hover {
  background: #E85D4A;
  color: #FFFFFF;
}

/* =====================
   INPUT AREA
   ===================== */
.propbot-input-area {
  padding: 10px 12px;
  background: #FFFFFF;
  border-top: 1px solid #EFEFEF;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.propbot-input {
  flex: 1;
  border: 1.5px solid #E5E5E5;
  border-radius: 22px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  color: #181A20;
  background: #F8F9FA;
  resize: none;
  outline: none;
  max-height: 96px;
  min-height: 40px;
  transition: border-color 0.2s;
  line-height: 1.45;
  overflow-y: auto;
}

.propbot-input:focus {
  border-color: #E85D4A;
  background: #FFFFFF;
}

.propbot-input::placeholder {
  color: #AAAAAA;
}

.propbot-send-btn {
  width: 40px;
  height: 40px;
  background: #E85D4A;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: 15px;
  transition: background 0.2s, transform 0.12s;
  flex-shrink: 0;
  padding: 0;
}

.propbot-send-btn:hover  { background: #c94535; }
.propbot-send-btn:active { transform: scale(0.92); }
.propbot-send-btn:disabled {
  background: #CCCCCC;
  cursor: not-allowed;
}

/* =====================
   RESPONSIVE - Mobile
   ===================== */
@media (max-width: 480px) {
  #propbot-window {
    right: 0;
    left: 0;
    bottom: 0 !important;
    width: 100vw;
    height: 78vh;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
  }

  #propbot-window.open {
    transform: translateY(0);
    animation: none;
  }

  #propbot-fab {
    right: 18px;
    bottom: 95px;
  }
}
