/* Home Movers AI Widget v2 */
#hmw * { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

#hmw {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 2147483647;
}

/* Trigger button */
#hmw-btn {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--hmw-color, #1a3a6b);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.28);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  animation: hmw-pulse 3s ease-in-out infinite;
}
#hmw-btn:hover { transform: scale(1.08); box-shadow: 0 10px 32px rgba(0,0,0,0.32); }

@keyframes hmw-pulse {
  0%,100% { box-shadow: 0 6px 24px rgba(0,0,0,0.28); }
  50%      { box-shadow: 0 6px 24px rgba(0,0,0,0.28), 0 0 0 10px rgba(26,58,107,0.14); }
}

#hmw-dot {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px;
  background: #e53e3e; border: 2px solid #fff;
  border-radius: 50%; font-size: 9px; font-weight: 800;
  color: #fff; display: flex; align-items: center; justify-content: center;
}

/* Panel — hidden by default */
#hmw-panel {
  position: absolute;
  bottom: 74px; right: 0;
  width: 340px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.07);
  flex-direction: column;
  overflow: hidden;
  max-height: 520px;
  /* KEY FIX: use visibility+opacity instead of display:none
     so the button can still toggle it without destroying DOM */
  display: flex;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

#hmw-panel.hmw-open {
  visibility: visible;
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0s;
}

/* Header */
#hmw-head {
  background: var(--hmw-color, #1a3a6b);
  padding: 13px 15px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
#hmw-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
#hmw-head-info { flex: 1; }
#hmw-head-name  { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.2; }
#hmw-head-status {
  color: rgba(255,255,255,0.8); font-size: 11px;
  display: flex; align-items: center; gap: 5px;
}
#hmw-head-status::before {
  content: ''; width: 6px; height: 6px;
  background: #48bb78; border-radius: 50%; display: inline-block;
}
#hmw-close {
  background: none; border: none;
  color: rgba(255,255,255,0.75); font-size: 20px;
  cursor: pointer; line-height: 1; padding: 2px 6px;
  border-radius: 6px; transition: background 0.15s, color 0.15s;
}
#hmw-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* Messages */
#hmw-msgs {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 9px;
  scrollbar-width: thin; scrollbar-color: #ddd transparent;
}

.hmw-bbl {
  max-width: 84%; padding: 10px 13px;
  border-radius: 16px; font-size: 13.5px; line-height: 1.52;
  animation: hmw-in 0.22s ease;
}
@keyframes hmw-in {
  from { opacity:0; transform: translateY(7px); }
  to   { opacity:1; transform: translateY(0); }
}
.hmw-bbl.ai {
  background: #eef2fb; color: #1a1f2e;
  align-self: flex-start; border-bottom-left-radius: 4px;
}
.hmw-bbl.me {
  background: var(--hmw-color, #1a3a6b); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.hmw-sender {
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--hmw-color, #1a3a6b);
  margin-bottom: 4px;
}

/* Typing dots */
.hmw-typing {
  display: flex; gap: 4px; align-items: center;
  background: #eef2fb; padding: 10px 14px;
  border-radius: 16px; border-bottom-left-radius: 4px;
  width: fit-content; align-self: flex-start;
}
.hmw-typing span {
  width: 7px; height: 7px; background: #9ba3b4; border-radius: 50%;
  animation: hmw-dots 1.2s infinite;
}
.hmw-typing span:nth-child(2) { animation-delay: 0.18s; }
.hmw-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes hmw-dots {
  0%,60%,100% { transform:translateY(0); }
  30%          { transform:translateY(-6px); }
}

/* Quick replies */
#hmw-quick {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 13px 10px; flex-shrink: 0;
}
.hmw-qr {
  background: #fff;
  border: 1.5px solid var(--hmw-color, #1a3a6b);
  color: var(--hmw-color, #1a3a6b);
  padding: 5px 12px; border-radius: 100px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.hmw-qr:hover { background: var(--hmw-color, #1a3a6b); color: #fff; }

/* WhatsApp strip */
#hmw-wa {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: #f0fff4;
  border-top: 1px solid #c6f6d5;
  font-size: 12px; color: #276749; font-weight: 600;
  cursor: pointer; text-decoration: none; flex-shrink: 0;
  transition: background 0.15s;
}
#hmw-wa:hover { background: #dcfce7; }

/* Input */
#hmw-row {
  display: flex; gap: 7px; padding: 10px;
  border-top: 1px solid #e5e7eb; flex-shrink: 0;
}
#hmw-input {
  flex: 1; border: 1.5px solid #e2e8f0; border-radius: 100px;
  padding: 9px 15px; font-size: 13.5px; font-family: inherit;
  outline: none; color: #1a1f2e; transition: border-color 0.15s;
}
#hmw-input:focus { border-color: var(--hmw-color, #1a3a6b); }
#hmw-input::placeholder { color: #b0b8c8; }
#hmw-input:disabled { background: #f9fafb; }

#hmw-send {
  background: var(--hmw-color, #1a3a6b); border: none;
  border-radius: 50%; width: 40px; height: 40px; flex-shrink: 0;
  cursor: pointer; color: #fff; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
}
#hmw-send:hover:not(:disabled) { transform: scale(1.09); }
#hmw-send:disabled { opacity: 0.45; cursor: default; }

/* Success state */
#hmw-success {
  padding: 28px 20px; text-align: center; display: none; flex-shrink: 0;
}
#hmw-success .s-icon { font-size: 52px; margin-bottom: 12px; }
#hmw-success h3 { color: #1a3a6b; font-size: 18px; margin-bottom: 8px; }
#hmw-success p  { font-size: 13px; color: #6b7280; line-height: 1.65; }
#hmw-success a  { color: #1a3a6b; font-weight: 700; }

/* No-key warning */
#hmw-nokey {
  padding: 20px; background: #fffbeb;
  border-top: 1px solid #fde68a; font-size: 13px;
  color: #92400e; display: none; flex-shrink: 0; text-align: center;
}

@media (max-width: 420px) {
  #hmw { bottom: 16px; right: 16px; }
  #hmw-panel { width: calc(100vw - 32px); }
}
