/* Khung chat tự dựng: avatar người thật, trả lời nguyên tin, màu theo thương hiệu. */
.chat-w {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  font-family: var(--sans, system-ui, sans-serif);
}

.chat-w * { box-sizing: border-box; }

.chat-w-btn {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: var(--chat-accent, #146165);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 26px rgba(10, 40, 38, .28);
  transition: transform .18s ease;
}

.chat-w-btn:hover { transform: translateY(-2px); }
.chat-w-btn svg { width: 26px; height: 26px; }

.chat-w-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(8, 30, 28, .28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .06);
}

.chat-w.is-open .chat-w-panel { display: flex; }

.chat-w-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: #fff;
  background: var(--chat-accent, #146165);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, .16), rgba(0, 0, 0, .12));
}

.chat-w-head img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, .7);
  background: #fff;
}

.chat-w-head b { display: block; font-size: 14.5px; line-height: 1.2; }
.chat-w-head small { display: flex; align-items: center; gap: 6px; font-size: 11.5px; opacity: .92; }
.chat-w-head small::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: #7ff0a8;
  box-shadow: 0 0 0 2px rgba(127, 240, 168, .28);
}

.chat-w-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  opacity: .85;
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
}
.chat-w-close:hover { opacity: 1; }

.chat-w-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #f7f9f8;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-w-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-w-row.is-user { flex-direction: row-reverse; }

.chat-w-row img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: #e7eeec;
}

.chat-w-bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 14px 14px 14px 4px;
  background: #fff;
  color: #1c2b28;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(10, 40, 38, .08);
  word-break: break-word;
}

.chat-w-row.is-user .chat-w-bubble {
  border-radius: 14px 14px 4px 14px;
  background: var(--chat-accent, #146165);
  color: #fff;
}

.chat-w-bubble p { margin: 0 0 8px; }
.chat-w-bubble p:last-child { margin-bottom: 0; }
.chat-w-bubble ul { margin: 0 0 8px; padding-left: 18px; }
.chat-w-bubble li { margin-bottom: 4px; }
.chat-w-bubble strong { font-weight: 700; }

.chat-w-typing { display: flex; gap: 4px; padding: 4px 2px; }
.chat-w-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #8aa39f;
  animation: chat-w-dot 1.1s infinite ease-in-out;
}
.chat-w-typing span:nth-child(2) { animation-delay: .15s; }
.chat-w-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes chat-w-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-w-foot {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, .07);
}

.chat-w-foot textarea {
  flex: 1;
  resize: none;
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  max-height: 90px;
  min-height: 38px;
  outline: none;
}
.chat-w-foot textarea:focus { border-color: var(--chat-accent, #146165); }

.chat-w-send {
  width: 40px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--chat-accent, #146165);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.chat-w-send:disabled { opacity: .5; cursor: default; }
.chat-w-send svg { width: 18px; height: 18px; }

.chat-w-credit {
  padding: 0 10px 8px;
  font-size: 10.5px;
  text-align: center;
  color: #8b9a96;
  background: #fff;
}
.chat-w-credit a { color: inherit; }

@media (max-width: 480px) {
  .chat-w { right: 14px; bottom: 74px; }
  .chat-w-panel {
    position: fixed;
    inset: auto 10px 84px;
    width: auto;
    height: min(70vh, 560px);
    max-height: none;
  }
}
