/* ===================== BONG BÓNG SÓC ===================== */
/* Cả nhãn và ảnh nằm trong MỘT <button> để nhãn cũng bấm được. */
.soc-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: transform .2s ease;
}

.soc-chat-launcher:hover { transform: translateY(-3px); }
.soc-chat-launcher[hidden] { display: none; }

.soc-chat-launcher-label {
  padding: 10px 14px;
  border: 1px solid rgba(255, 122, 26, .34);
  border-radius: 13px;
  color: #fff;
  background: rgba(28, 32, 41, .96);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .32);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.lbl-short { display: none; }

/* Mở chat rồi thì ẩn nhãn — tiêu đề cửa sổ đã nói rõ đây là Sóc */
.soc-chat-launcher[aria-expanded="true"] .soc-chat-launcher-label { display: none; }

.soc-chat-orb {
  position: relative;
  width: 66px;
  height: 66px;
  flex: 0 0 auto;
  padding: 4px;
  border: 2px solid #ff7a1a;
  border-radius: 50%;
  background: #171a21;
  box-shadow: 0 16px 42px rgba(0, 0, 0, .42), 0 0 0 8px rgba(255, 122, 26, .08);
  transition: box-shadow .2s ease;
}

.soc-chat-launcher:hover .soc-chat-orb {
  box-shadow: 0 20px 48px rgba(0, 0, 0, .48), 0 0 0 10px rgba(255, 122, 26, .1);
}

.soc-chat-avatar {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
}

/* Nhãn AI trung tính — thay chấm xanh "đang trực tuyến" dễ gây hiểu nhầm có người thật */
.soc-chat-ai-badge {
  position: absolute;
  right: -3px;
  bottom: -1px;
  padding: 2px 6px;
  border: 2px solid #171a21;
  border-radius: 999px;
  color: #1a130b;
  background: linear-gradient(135deg, #ff7a1a, #ffb020);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .4px;
  line-height: 1.3;
}

/* ===================== CỬA SỔ CHAT ===================== */
.soc-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 102px;
  z-index: 75;
  width: min(390px, calc(100vw - 32px));
  height: min(610px, calc(100vh - 128px));
  padding: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
  border: 1px solid #343a47;
  border-radius: 22px;
  background: #151820;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .58);
  opacity: 0;
  transform: translateY(18px) scale(.97);
  transform-origin: right bottom;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .22s ease, transform .22s ease, visibility .22s;
}

.soc-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.soc-chat-header {
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #2a2f3a;
  background: linear-gradient(135deg, rgba(255, 122, 26, .15), rgba(255, 176, 32, .04));
}

.soc-chat-header .soc-chat-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 122, 26, .6);
}

.soc-chat-heading {
  min-width: 0;
  flex: 1;
}

.soc-chat-heading strong {
  display: block;
  font-size: 15px;
}

/* Không dùng chấm xanh ở đây nữa */
.soc-chat-status {
  margin-top: 2px;
  color: #b7bfca;
  font-size: 12px;
}

.soc-chat-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  color: #c9ced7;
  background: rgba(255, 255, 255, .055);
  font-size: 23px;
  line-height: 1;
}

.soc-chat-demo-strip {
  padding: 7px 13px;
  border-bottom: 1px solid rgba(255, 176, 32, .15);
  color: #e9c98f;
  background: #211d17;
  font-size: 11px;
  text-align: center;
}

.soc-chat-messages {
  min-height: 0;
  padding: 17px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scrollbar-color: #3a404d transparent;
}

.soc-chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.soc-chat-message.bot {
  align-self: flex-start;
  border: 1px solid #303642;
  border-bottom-left-radius: 5px;
  color: #dce1e8;
  background: #20242d;
}

.soc-chat-message.user {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  color: #1a130b;
  background: linear-gradient(135deg, #ff7a1a, #ffb020);
}

/* Trạng thái cảnh báo: hết quota, lỗi kết nối, bảo trì */
.soc-chat-message.warn {
  align-self: flex-start;
  border: 1px solid rgba(255, 176, 32, .34);
  border-bottom-left-radius: 5px;
  color: #e9c98f;
  background: #211d17;
}

.soc-chat-message.typing {
  width: 54px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.soc-chat-message.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ea6b2;
  animation: soc-chat-typing 1s infinite ease-in-out;
}

.soc-chat-message.typing span:nth-child(2) { animation-delay: .12s; }
.soc-chat-message.typing span:nth-child(3) { animation-delay: .24s; }

.soc-chat-suggestions,
.soc-chat-sources,
.soc-chat-ctas {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.soc-chat-suggestion,
.soc-chat-source {
  padding: 7px 9px;
  border-radius: 999px;
  font-size: 12px;
}

.soc-chat-suggestion {
  border: 1px solid #343b49;
  cursor: pointer;
  color: #dce1e8;
  background: #191d25;
  font-family: inherit;
}

.soc-chat-suggestion:hover {
  border-color: #ff7a1a;
  color: #ffd3a3;
}

/* Nguồn = dẫn chứng của câu trả lời */
.soc-chat-source {
  border: 1px solid rgba(255, 122, 26, .28);
  color: #ffc173;
  background: rgba(255, 122, 26, .07);
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
}

.soc-chat-source:hover {
  border-color: #ff7a1a;
  background: rgba(255, 122, 26, .14);
}

/* CTA = lời mời hành động, tách hẳn khỏi nguồn */
.soc-chat-ctas { margin-top: 2px; }

.soc-chat-cta {
  padding: 8px 12px;
  border-radius: 10px;
  color: #1a130b;
  background: linear-gradient(135deg, #ff7a1a, #ffb020);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.soc-chat-cta.ghost {
  color: #ffc173;
  background: none;
  border: 1px solid rgba(255, 122, 26, .4);
}

.soc-chat-form {
  padding: 11px;
  display: grid;
  grid-template-columns: 1fr 43px;
  gap: 8px;
  align-items: end;
  border-top: 1px solid #2a2f3a;
  background: #171a21;
}

.soc-chat-input {
  width: 100%;
  min-height: 43px;
  max-height: 96px;
  resize: none;
  padding: 10px 11px;
  border: 1px solid #333a47;
  border-radius: 11px;
  color: #e8eaed;
  background: #101319;
  line-height: 1.4;
  font-family: inherit;
  font-size: 14px;
}

.soc-chat-input::placeholder { color: #747d8b; }

.soc-chat-send {
  width: 43px;
  height: 43px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  color: #1c1308;
  background: linear-gradient(135deg, #ff7a1a, #ffb020);
  font-size: 19px;
  font-weight: 900;
}

.soc-chat-send:disabled { cursor: not-allowed; opacity: .45; }

.soc-chat-launcher:focus-visible,
.soc-chat-close:focus-visible,
.soc-chat-suggestion:focus-visible,
.soc-chat-send:focus-visible,
.soc-chat-input:focus-visible,
.soc-chat-source:focus-visible,
.soc-chat-cta:focus-visible {
  outline: 3px solid rgba(255, 176, 32, .48);
  outline-offset: 3px;
}

/* Vị trí nút "Về đầu trang" do index.html tự quản (mục .back-top trong <style>),
   không đặt ở đây nữa để tránh hai file ghi đè nhau ở các breakpoint khác nhau. */

@keyframes soc-chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .55; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 560px) {
  .soc-chat-launcher { right: 14px; bottom: 14px; }
  .lbl-full { display: none; }
  .lbl-short { display: inline; }
  .soc-chat-orb { width: 60px; height: 60px; }
  .soc-chat-panel {
    right: 10px;
    /* 96px thay vì 84px: chừa khoảng an toàn giữa nút Gửi và bong bóng */
    bottom: 96px;
    width: calc(100vw - 20px);
    height: min(70dvh, 610px);
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .soc-chat-launcher,
  .soc-chat-panel,
  .soc-chat-message.typing span { animation: none; transition: none; }
}

/* Bong bóng Sóc nằm cố định ở góc phải dưới, đúng chỗ nút "Về đầu trang" của các
   trang hay đặt. Đẩy nút đó lên cho khỏi chồng — để ở đây thay vì sửa CSS từng
   trang, vì bong bóng đi tới trang nào thì luật tránh nhau đi theo tới đó.
   File này phải được nạp SAU phần <style> của trang để giá trị dưới thắng. */
.back-top { bottom: 106px; }

@media (max-width: 720px) {
  .back-top { bottom: 96px; }
}
