/* Chatbot AI khách lẻ — riêng khachle */
.kl-ai {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 1400;
  pointer-events: none;
}

.kl-ai__fab,
.kl-ai__panel {
  pointer-events: auto;
}

.kl-ai__fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1401;
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a9fd6 0%, #1a6a9a 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(26, 106, 154, 0.35), 0 2px 8px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kl-ai__fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(26, 106, 154, 0.42);
}

.kl-ai__fab-ico {
  display: flex;
  line-height: 0;
}

/* Trang khách lẻ đã có float Zalo/FB — ẩn FAB, mở chat qua tab Hỗ trợ */
body.kl-land .kl-ai__fab {
  display: none;
}

.kl-ai__panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1402;
  width: min(400px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.kl-ai__panel[hidden] {
  display: none !important;
}

.kl-ai__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #1a6a9a 0%, #2a9fd6 100%);
  color: #fff;
}

.kl-ai__head-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.kl-ai__logo {
  width: 32px;
  height: 32px;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  flex-shrink: 0;
}

.kl-ai__head-main strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
}

.kl-ai__head-main span {
  display: block;
  font-size: 0.74rem;
  font-weight: 500;
  opacity: 0.88;
  margin-top: 1px;
}

.kl-ai__close {
  appearance: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.kl-ai__close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.kl-ai__msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kl-ai__msg {
  display: flex;
  max-width: 92%;
}

.kl-ai__msg--user {
  align-self: flex-end;
}

.kl-ai__msg--assistant {
  align-self: flex-start;
}

.kl-ai__bubble {
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  color: #1e293b;
  word-break: break-word;
}

.kl-ai__msg--user .kl-ai__bubble {
  background: #1a6a9a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.kl-ai__msg--assistant .kl-ai__bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.kl-ai__msg--typing .kl-ai__bubble {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 36px;
}

.kl-ai__msg--typing .kl-ai__bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: kl-ai-dot 1.2s ease-in-out infinite;
}

.kl-ai__msg--typing .kl-ai__bubble span:nth-child(2) {
  animation-delay: 0.15s;
}

.kl-ai__msg--typing .kl-ai__bubble span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes kl-ai-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.kl-ai__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
  background: #fff;
}

.kl-ai__chip {
  appearance: none;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
}

.kl-ai__chip:hover {
  background: #dbeafe;
}

.kl-ai__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid #eef2f7;
}

.kl-ai__form textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: #1e293b;
  outline: none;
  line-height: 1.4;
}

.kl-ai__form textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.kl-ai__send {
  appearance: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #1a6a9a;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kl-ai__send:hover {
  background: #155a84;
}

.kl-ai__send:disabled {
  opacity: 0.55;
  cursor: wait;
}

@media (max-width: 560px) {
  .kl-ai__panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
}
