/* =========================
   HBC Chatbot – Updated CSS
   ========================= */

#hbc-chatbot-root{
  position: fixed;
  bottom: 18px;
  z-index: 9999999;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  pointer-events: none; /* chỉ cho con nhận click */
}

#hbc-chatbot-root.right{ right: 18px; left: auto; }
#hbc-chatbot-root.left{  left: 18px;  right: auto; }

/* Panel nằm trên button, không làm button “nhảy” */
.hbc-chatbot-panel{
  width: 360px;
  max-width: calc(100vw - 36px);
  min-height: 480px;
  max-height: calc(100vh - 140px);

  background: #fff;
  border-radius: 16px;
  overflow: hidden;

  box-shadow: 0 18px 55px rgba(15,23,42,.18);
  border: 1px solid rgba(15,23,42,.10);

  margin-bottom: 12px;
  display: none;

  pointer-events: auto;
}

.hbc-chatbot-panel.open{ display: block; }

/* Button mở chat luôn cố định */
.hbc-chatbot-btn{
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.18);
  cursor: pointer;

  color: #fff;
  font-weight: 800;

  box-shadow: 0 12px 30px rgba(15,23,42,.20);
  display: inline-flex;
  align-items: center;
  justify-content: center;

  pointer-events: auto;

  /* chống theme làm lệch */
  transform: none !important;
  margin: 0 !important;
  border-radius: 50px !important;
}

.hbc-chatbot-btn:hover{ filter: brightness(.98); }
.hbc-chatbot-btn:active{ transform: translateY(1px) !important; }

/* Header đẹp + chừa chỗ nút X */
.hbc-chatbot-header{
  position: relative;
  padding: 12px 52px 12px 14px; /* chừa chỗ cho nút đóng */
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: flex-start;

  background: linear-gradient(135deg, var(--hbc-primary, #0ea5e9), #2563eb);
}

.hbc-chatbot-header .title{
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .2px;
}

/* Nút đóng không bị che */
.hbc-chatbot-close{
  position: absolute;
  top: 10px;
  right: 10px;

  width: 34px;
  height: 34px;

  border-radius: 12px !important;
  padding: 0 !important;

  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);

  color: #fff;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 18px;
  line-height: 18px;
}

.hbc-chatbot-close:hover{
  background: rgba(255,255,255,.22);
}

/* Messages */
.hbc-chatbot-messages{
  padding: 14px;
  height: calc(480px - 54px - 64px); /* min-height - header - input */
  max-height: calc(100vh - 140px - 54px - 64px);
  overflow: auto;

  background:
    radial-gradient(80% 60% at 10% 0%, rgba(14,165,233,.10), transparent 60%),
    radial-gradient(70% 60% at 100% 20%, rgba(37,99,235,.10), transparent 55%),
    #fff;
}

/* Bubble layout */
.hbc-msg{
  margin: 10px 0;
  display: flex;
  gap: 8px;
}

.hbc-msg.user{ justify-content: flex-end; }
.hbc-msg.bot{ justify-content: flex-start; }

.hbc-bubble{
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;

  border: 1px solid rgba(15,23,42,.10);
  box-shadow: 0 8px 22px rgba(15,23,42,.06);
}

/* User bubble */
.hbc-msg.user .hbc-bubble{
  background: rgba(14,165,233,.14);
  border-color: rgba(14,165,233,.28);
  color: #0b1220;
  border-bottom-right-radius: 10px;
}

/* Bot bubble */
.hbc-msg.bot .hbc-bubble{
  background: #fff;
  color: #0f172a;
  border-bottom-left-radius: 10px;
}

/* Input bar */
.hbc-chatbot-input{
  display: flex;
  gap: 10px;
  padding: 12px;

  border-top: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.hbc-chatbot-input input{
  flex: 1;
  height: 42px;

  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.14);

  padding: 0 12px;
  outline: none;

  font-size: 13px;
  color: #0f172a;
  background: #fff;
}

.hbc-chatbot-input input:focus{
  border-color: rgba(14,165,233,.55);
  box-shadow: 0 0 0 4px rgba(14,165,233,.12);
}

/* Button gửi gọn, không bị dài */
/* --- SEND BUTTON AS ICON --- */
.hbc-chatbot-input button{
  width: 42px !important;
  min-width: 42px !important;
  padding: 0 !important;

  border-radius: 14px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  font-size: 0 !important; /* ẩn text nếu còn sót */
}

.hbc-chatbot-input button svg{
  width: 18px;
  height: 18px;
  display: block;
}


/* ===============================
   ICON-ONLY BUTTONS (NO BACKGROUND)
   =============================== */

/* CLOSE BUTTON */
/* ===============================
   ICON-ONLY BUTTONS (NO BACKGROUND)
   =============================== */

/* CLOSE BUTTON */
.hbc-chatbot-close{
  background: transparent !important;
  border: none !important;

  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  margin: 0 !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  color: #ffffff !important;
  font-size: 18px !important;
  line-height: 0 !important;

  cursor: pointer;
  opacity: .9;
}

.hbc-chatbot-close:hover{
  opacity: 1;
  transform: scale(1.05);
}

/* SEND BUTTON */
.hbc-chatbot-input button{
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;

  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;

  padding: 0 !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  color: #2563eb !important; /* xanh nổi bật */
  font-size: 0 !important;

  cursor: pointer;
  opacity: .9;
}

.hbc-chatbot-input button:hover{
  opacity: 1;
  transform: translateY(-1px);
}

/* Icon SVG */
.hbc-chatbot-input button svg{
  width: 20px;
  height: 20px;
  display: block;
}

/* Focus / accessibility */
.hbc-chatbot-close:focus,
.hbc-chatbot-input button:focus{
  outline: none;
}


/* SEND BUTTON */
.hbc-chatbot-input button{
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;

  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;

  padding: 0 !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  color: #2563eb !important; /* xanh nổi bật */
  font-size: 0 !important;

  cursor: pointer;
  opacity: .9;
}

.hbc-chatbot-input button:hover{
  opacity: 1;
  transform: translateY(-1px);
}

/* Icon SVG */
.hbc-chatbot-input button svg{
  width: 20px;
  height: 20px;
  display: block;
}

/* Focus / accessibility */
.hbc-chatbot-close:focus,
.hbc-chatbot-input button:focus{
  outline: none;
}

/* Rich formatting inside bot bubble */
.hbc-msg.bot .hbc-bubble h1,
.hbc-msg.bot .hbc-bubble h2,
.hbc-msg.bot .hbc-bubble h3{
  margin: 6px 0 8px;
  font-weight: 800;
  line-height: 1.25;
}
.hbc-msg.bot .hbc-bubble h1{ font-size: 15px; }
.hbc-msg.bot .hbc-bubble h2{ font-size: 14px; }
.hbc-msg.bot .hbc-bubble h3{ font-size: 13.5px; }

.hbc-msg.bot .hbc-bubble p{
  margin: 0 0 8px;
}
.hbc-msg.bot .hbc-bubble p:last-child{ margin-bottom: 0; }

.hbc-msg.bot .hbc-bubble ul,
.hbc-msg.bot .hbc-bubble ol{
  margin: 6px 0 10px 18px;
  padding: 0;
}
.hbc-msg.bot .hbc-bubble li{ margin: 4px 0; }

.hbc-msg.bot .hbc-bubble blockquote{
  margin: 8px 0;
  padding: 8px 10px;
  border-left: 3px solid rgba(37,99,235,.35);
  background: rgba(37,99,235,.06);
  border-radius: 10px;
}

.hbc-msg.bot .hbc-bubble code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.10);
}

.hbc-msg.bot .hbc-bubble pre{
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.10);
  overflow: auto;
}
.hbc-msg.bot .hbc-bubble pre code{
  padding: 0;
  border: none;
  background: transparent;
}

/* Mobile */
@media (max-width: 480px){
  .hbc-chatbot-panel{
    width: calc(100vw - 36px);
    min-height: 65vh;
    max-height: 75vh;
  }
   .hbc-chatbot-messages{
    min-height: 450px;
    max-height: calc(75vh - 54px - 64px);
    padding-bottom: 0;
  }
}
