/* ============================================================
   widget.css — Trợ lý tư vấn TNC Furniture
   Đặt tại: httpdocs/api/agent/widget.css
   ============================================================ */

/* Biến màu — sửa ở đây là đổi toàn bộ giao diện */
:root {
  --tnc-do:        #C8102E;   /* đỏ thương hiệu */
  --tnc-do-dam:    #A00D25;
  --tnc-nen:       #FFFFFF;
  --tnc-nen-phu:   #F5F5F7;
  --tnc-chu:       #1A1A1A;
  --tnc-chu-nhat:  #6B6B70;
  --tnc-vien:      #E3E3E6;
  --tnc-canh-bao:  #E8A33D;   /* vàng — cảnh báo */
  --tnc-chan:      #D93025;   /* đỏ — chặn */
  --tnc-bong:      0 4px 24px rgba(0,0,0,.14);
}

/* ---------- Nút nổi ---------- */
.tnc-nut {
  position: fixed;
  left: 20px;                 /* đặt bên TRÁI vì phải đã có Zalo + Messenger */
  bottom: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--tnc-do);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--tnc-bong);
  display: flex; align-items: center; justify-content: center;
  z-index: 99998;
  transition: transform .18s ease, background .18s ease;
}
.tnc-nut:hover { transform: scale(1.06); background: var(--tnc-do-dam); }
.tnc-nut svg { width: 26px; height: 26px; }

/* Chấm đỏ báo có tin nhắn chưa đọc */
.tnc-nut-cham {
  position: absolute; top: 2px; right: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--tnc-canh-bao);
  border: 2px solid #fff;
  display: none;
}
.tnc-nut.co-tin .tnc-nut-cham { display: block; }

/* ---------- Khung chat ---------- */
.tnc-khung {
  position: fixed;
  left: 20px; bottom: 88px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--tnc-nen);
  border-radius: 16px;
  box-shadow: var(--tnc-bong);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--tnc-chu);
}
.tnc-khung.mo { display: flex; animation: tnc-hien .22s ease; }
@keyframes tnc-hien {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Thanh tiêu đề ---------- */
.tnc-dau {
  background: var(--tnc-do);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.tnc-dau-ten { font-weight: 600; font-size: 15px; }
.tnc-dau-phu { font-size: 12px; opacity: .85; margin-top: 1px; }
.tnc-dong {
  margin-left: auto;
  background: transparent; border: none; color: #fff;
  cursor: pointer; padding: 4px; opacity: .85;
  display: flex; align-items: center;
}
.tnc-dong:hover { opacity: 1; }

/* ---------- Vùng tin nhắn ---------- */
.tnc-than {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--tnc-nen-phu);
  display: flex; flex-direction: column; gap: 12px;
}
.tnc-than::-webkit-scrollbar { width: 6px; }
.tnc-than::-webkit-scrollbar-thumb { background: #C9C9CE; border-radius: 3px; }

.tnc-tin { max-width: 85%; padding: 10px 14px; border-radius: 14px; word-wrap: break-word; }
.tnc-tin.khach {
  align-self: flex-end;
  background: var(--tnc-do);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.tnc-tin.agent {
  align-self: flex-start;
  background: var(--tnc-nen);
  border: 1px solid var(--tnc-vien);
  border-bottom-left-radius: 4px;
}
.tnc-tin code {
  background: rgba(0,0,0,.07);
  padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
}
.tnc-tin.khach code { background: rgba(255,255,255,.22); }
.tnc-tin strong { font-weight: 600; }

/* Dòng trạng thái — vd "đang xin chiết khấu" */
.tnc-trang-thai {
  align-self: center;
  font-size: 12px;
  color: var(--tnc-chu-nhat);
  background: #EFEFF2;
  padding: 5px 12px;
  border-radius: 12px;
}

/* Dòng thông báo đồng ý — hiện một lần khi mở khung */
.tnc-dong-y {
  align-self: stretch;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--tnc-chu-nhat);
  background: #EFEFF2;
  border: 1px solid var(--tnc-vien);
  padding: 9px 12px;
  border-radius: 10px;
}
.tnc-dong-y a { color: var(--tnc-do); text-decoration: underline; }

/* Ba chấm đang gõ */
.tnc-dang-go {
  align-self: flex-start;
  background: var(--tnc-nen);
  border: 1px solid var(--tnc-vien);
  padding: 12px 16px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex; gap: 4px;
}
.tnc-dang-go span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #B4B4BA;
  animation: tnc-nhap 1.2s infinite;
}
.tnc-dang-go span:nth-child(2) { animation-delay: .18s; }
.tnc-dang-go span:nth-child(3) { animation-delay: .36s; }
@keyframes tnc-nhap {
  0%, 60%, 100% { transform: translateY(0);   opacity: .45; }
  30%           { transform: translateY(-5px); opacity: 1;  }
}

/* ---------- Ô nhập ---------- */
.tnc-chan-khung {
  padding: 12px;
  background: var(--tnc-nen);
  border-top: 1px solid var(--tnc-vien);
  flex-shrink: 0;
}
.tnc-o-nhap { display: flex; gap: 8px; align-items: flex-end; }
.tnc-o-nhap textarea {
  flex: 1;
  border: 1px solid var(--tnc-vien);
  border-radius: 20px;
  padding: 10px 14px;
  font-family: inherit; font-size: 14px; line-height: 1.4;
  resize: none;
  max-height: 96px;
  outline: none;
  transition: border-color .16s;
}
.tnc-o-nhap textarea:focus { border-color: var(--tnc-do); }
.tnc-gui {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--tnc-do);
  border: none; color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .16s;
}
.tnc-gui:hover:not(:disabled) { background: var(--tnc-do-dam); }
.tnc-gui:disabled { background: #C9C9CE; cursor: not-allowed; }
.tnc-gui svg { width: 18px; height: 18px; }

.tnc-ghi-chu {
  font-size: 11px;
  color: var(--tnc-chu-nhat);
  text-align: center;
  margin-top: 8px;
}
.tnc-ghi-chu a { color: var(--tnc-chu-nhat); }

/* ---------- Cảnh báo inline trên dòng sản phẩm ---------- */
/* Widget tự gắn class này lên dòng sản phẩm ở trang cấu hình */
.tnc-canh-bao-dong {
  border-left: 4px solid var(--tnc-canh-bao) !important;
  background: #FFF9EF !important;
  position: relative;
}
.tnc-chan-dong {
  border-left: 4px solid var(--tnc-chan) !important;
  background: #FEF2F2 !important;
  position: relative;
}
.tnc-nhan-loi {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
}
.tnc-canh-bao-dong .tnc-nhan-loi { background: #FDF0D9; color: #8A5A00; }
.tnc-chan-dong    .tnc-nhan-loi { background: #FBE0DE; color: #96150E; }
.tnc-nhan-loi b { font-weight: 600; }

/* ---------- Điện thoại ---------- */
@media (max-width: 480px) {
  .tnc-khung {
    left: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%;
    height: 100%; max-height: 100%;
    border-radius: 0;
  }
  .tnc-nut { left: 16px; bottom: 90px; }
}