/* Kiểu cơ bản cho ô chat trợ lý. Bạn thiết kế chỉ cần đổi các biến màu bên dưới. */
.lg-assistant {
  --lg-primary: #2e5c8a;
  --lg-primary-text: #ffffff;
  --lg-surface: #ffffff;
  --lg-user-bubble: #2e5c8a;
  --lg-bot-bubble: #eef2f6;
  --lg-system: #6b4a00;
  --lg-border: #d5dbe1;
  --lg-text: #1f2933;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1000;
  font: inherit;
  color: var(--lg-text);
}
.lg-assistant[hidden] { display: none; }

/* Nút bong bóng tròn */
.lg-assistant__toggle {
  display: flex;
  align-items: center;
  flex-direction: row-reverse; /* bong bóng bên phải, chữ nhô ra bên trái */
  gap: 0;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.lg-assistant__bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--lg-primary);
  color: var(--lg-primary-text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  flex: none;
  transition: transform 0.15s;
}
.lg-assistant__toggle:hover .lg-assistant__bubble { transform: scale(1.06); }

/* Dòng chữ bên trái bong bóng, mặc định thu gọn; hiện khi có class lg-peek */
.lg-assistant__hint {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  background: var(--lg-surface);
  color: var(--lg-text);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  font-weight: 600;
  padding: 0;
  margin: 0;
  transition: max-width 0.4s ease, opacity 0.3s ease, padding 0.4s ease, margin 0.4s ease;
}
.lg-assistant.lg-peek .lg-assistant__hint {
  max-width: 260px;
  opacity: 1;
  padding: 10px 16px;
  margin-right: 10px; /* khoảng cách giữa chữ và bong bóng */
}
/* Khi khung chat đang mở thì luôn ẩn dòng chữ cho gọn */
.lg-assistant:has(.lg-assistant__panel:not([hidden])) .lg-assistant__hint {
  display: none;
}
.lg-assistant__panel {
  position: absolute;
  right: 0;
  bottom: 56px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--lg-surface);
  border: 1px solid var(--lg-border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.lg-assistant__panel[hidden] { display: none; }
.lg-assistant__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--lg-primary);
  color: var(--lg-primary-text);
}
.lg-assistant__close {
  background: none;
  border: 0;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.lg-assistant__log {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lg-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.45;
  font-size: 14px;
}
.lg-msg--user { align-self: flex-end; background: var(--lg-user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.lg-msg--assistant { align-self: flex-start; background: var(--lg-bot-bubble); border-bottom-left-radius: 4px; }
.lg-msg--system { align-self: center; color: var(--lg-system); font-size: 13px; text-align: center; }
.lg-msg--typing { opacity: 0.7; font-style: italic; }
.lg-book {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 3px solid var(--lg-primary);
  padding: 6px 10px;
  font-size: 13px;
}
.lg-action {
  align-self: flex-start;
  background: var(--lg-surface);
  color: var(--lg-primary);
  border: 1.5px solid var(--lg-primary);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.lg-action:disabled { opacity: 0.6; cursor: default; }
.lg-assistant__input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--lg-border);
}
.lg-assistant__input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--lg-border);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  font-size: 14px;
}
.lg-assistant__send {
  background: var(--lg-primary);
  color: var(--lg-primary-text);
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}
.lg-assistant__send:disabled { opacity: 0.6; }
.lg-assistant button:focus-visible,
.lg-assistant textarea:focus-visible { outline: 2px solid var(--lg-primary); outline-offset: 2px; }

@media (max-width: 480px) {
  .lg-assistant__panel {
    position: fixed;
    inset: auto 8px calc(72px + env(safe-area-inset-bottom)) 8px;
    width: auto;
  }
}