:root {
  --dscorp-color: #890c0c; /* Đã đổi sang tông đỏ Botpress */
}

:host {
  all: initial; /* Reset toàn bộ CSS từ website */
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999999;
  display: block;
  font-family: 'Inter', Arial, Helvetica, sans-serif;
}

/* Thêm dòng này để đảm bảo hiển thị đúng bên trong Shadow DOM */
.dscorp-chat-widget {
  display: block;
}

/* Container để bao FAB và Tooltip */
.dscorp-fab-container {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

/* Tooltip nhấp nháy - Chỉ hiện khi chưa mở panel */
.dscorp-fab-container:not(.panel-open)::after {
  content: "💬 Trưởng bộ phận hỗ trợ khách hàng 24/7";
  width: 320px;
  color: white;
  background-color: red;
  font-size: 14px;
  font-weight: bold;
  padding: 8px 15px;
  border-radius: 10px;
  position: absolute;
  bottom: 15px;
  right: 80px;
  white-space: nowrap;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  animation: blinkBackground 1s infinite alternate;
  pointer-events: none;
}

.dscorp-fab-container:not(.panel-open)::before {
  content: "";
  position: absolute;
  bottom: 25px;
  right: 65px;
  border-width: 10px;
  border-style: solid;
  border-color: transparent transparent transparent red;
  animation: blinkArrow 1s infinite alternate;
}

@keyframes blinkBackground {
  0% { background-color: red; }
  100% { background-color: darkred; }
}

@keyframes blinkArrow {
  0% { border-left-color: red; }
  100% { border-left-color: darkred; }
}

.dscorp-fab {
  position: relative;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 999px;
  background: var(--dscorp-color);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.dscorp-fab:hover { transform: scale(1.05); }

.dscorp-chat-panel {
  display: none;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 620px;
  max-height: calc(100vh - 110px);
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,.24);
  flex-direction: column;
  margin-bottom: 20px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.dscorp-chat-panel.dscorp-open {
  display: flex;
}

.dscorp-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--dscorp-color); /* Header cùng màu brand cho chuyên nghiệp */
  color: white;
}

.dscorp-chat-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dscorp-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255,255,255,0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.4);
}

.dscorp-chat-title {
  font-size: 16px;
  font-weight: 700;
}

.dscorp-chat-subtitle {
  font-size: 12px;
  opacity: 0.8;
}

.dscorp-chat-head-actions button {
  border: none;
  background: transparent;
  font-size: 20px;
  color: white;
  cursor: pointer;
  opacity: 0.8;
}

.dscorp-chat-head-actions button:hover { opacity: 1; }

.dscorp-chat-body {
  flex: 1;
  min-height: 0;
  background: #f4f7f9;
}

.dscorp-messages {
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.dscorp-msg {
  display: flex;
  margin-bottom: 12px;
}

.dscorp-user { justify-content: flex-end; }
.dscorp-assistant { justify-content: flex-start; }

.dscorp-bubble {
  max-width: 82%;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dscorp-user .dscorp-bubble {
  background: var(--dscorp-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.dscorp-assistant .dscorp-bubble {
  background: #fff;
  color: #222;
  border-bottom-left-radius: 4px;
}

.dscorp-time {
  margin-top: 5px;
  font-size: 10px;
  opacity: .6;
  text-align: right;
}

.dscorp-chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 15px;
  border-top: 1px solid #ececec;
  background: #fff;
  align-items: flex-end;
}

.dscorp-chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid #ddd;
  border-radius: 18px;
  padding: 10px 15px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
}

.dscorp-chat-input:focus { border-color: var(--dscorp-color); }

.dscorp-send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--dscorp-color);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
:host {
right: 12px;
bottom: 12px;
}
.dscorp-chat-panel {
width: calc(100vw - 24px);
height: calc(100vh - 100px);
}
}