[data-tv-ai-launcher]{
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:2147483000;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}
[data-tv-ai-launcher] *{ box-sizing:border-box; }

/* Ẩn FAB khi chatbox mở */
[data-tv-ai-launcher].tv-ai-is-open .tv-ai-fab{
  opacity:0;
  pointer-events:none;
  transform:translateY(10px) scale(.95);
}

/* EXTERNAL QUICK BUTTONS */
[data-tv-ai-launcher] .tv-ai-external-actions{
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items:flex-end;
  margin-bottom:10px;
}
[data-tv-ai-launcher] .tv-ai-ext-btn{
  width:56px;
  height:56px;
  border-radius:999px;
  border:0;
  display:grid;
  place-items:center;
  text-decoration:none;
  position:relative;
  transform:translateZ(0);
  box-shadow:0 18px 55px rgba(0,0,0,.22);
  overflow:hidden;
  transition:transform .18s ease,filter .18s ease,box-shadow .18s ease;
  -webkit-tap-highlight-color:transparent;
}
[data-tv-ai-launcher] .tv-ai-ext-btn:hover{
  transform:translateY(-3px) scale(1.04);
  filter:brightness(1.05);
  box-shadow:0 24px 70px rgba(0,0,0,.26);
}
[data-tv-ai-launcher] .tv-ai-ext-btn:active{ transform:translateY(0) scale(.98); }
[data-tv-ai-launcher] .tv-ai-ext-btn::before{
  content:"";
  position:absolute;
  inset:-3px;
  background:
    radial-gradient(70px 70px at 18% 18%, rgba(255,255,255,.55), transparent 55%),
    radial-gradient(110px 110px at 85% 75%, rgba(255,255,255,.22), transparent 60%);
  opacity:.95;
}
[data-tv-ai-launcher] .tv-ai-ext-btn::after{
  content:"";
  position:absolute;
  inset:-18px;
  border-radius:999px;
  border:2px solid rgba(255,255,255,.38);
  animation:tvPulse 1.55s infinite ease-in-out;
  pointer-events:none;
  opacity:.9;
}
@keyframes tvPulse{
  0%{ transform:scale(.82); opacity:.95; }
  70%{ transform:scale(1.18); opacity:0; }
  100%{ transform:scale(1.18); opacity:0; }
}
[data-tv-ai-launcher] .tv-ai-ext-btn.call{ background:linear-gradient(135deg,#10b981,#059669); }
[data-tv-ai-launcher] .tv-ai-ext-btn.zalo{ background:linear-gradient(135deg,#38bdf8,#0284c7); }
[data-tv-ai-launcher] .tv-ai-ext-btn.messenger{ background:linear-gradient(135deg,#a78bfa,#6d28d9); }
[data-tv-ai-launcher] .tv-ai-iconimg{
  width:28px;
  height:28px;
  object-fit:contain;
  position:relative;
  z-index:1;
  filter:drop-shadow(0 10px 18px rgba(0,0,0,.28));
}

/* FAB */
[data-tv-ai-launcher] .tv-ai-fab{
  border:0;
  cursor:pointer;
  border-radius:999px;
  box-shadow:0 18px 55px rgba(0,0,0,.24);
  background:linear-gradient(135deg,#0b1220,#111827);
  color:#fff;
  display:flex;
  gap:10px;
  align-items:center;
  padding:12px 14px;
  position:relative;
  overflow:hidden;
  transform:translateZ(0);
  -webkit-tap-highlight-color:transparent;
  transition:transform .16s ease,opacity .16s ease;
}
[data-tv-ai-launcher] .tv-ai-fab::before{
  content:"";
  position:absolute;
  inset:-2px;
  background:
    radial-gradient(190px 110px at 10% 15%, rgba(37,99,235,.38), transparent 60%),
    radial-gradient(170px 110px at 90% 55%, rgba(34,197,94,.22), transparent 60%);
  opacity:1;
}
[data-tv-ai-launcher] .tv-ai-fab::after{
  content:"";
  position:absolute;
  inset:-3px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
}
[data-tv-ai-launcher] .tv-ai-fab__icon{
  font-size:20px;
  line-height:1;
  position:relative;
  z-index:1;
}
[data-tv-ai-launcher] .tv-ai-fab__text{
  font-weight:900;
  font-size:13px;
  line-height:1.1;
  text-align:left;
  position:relative;
  z-index:1;
  letter-spacing:.2px;
}
[data-tv-ai-launcher] .tv-ai-fab__text small{ font-weight:800; opacity:.9; }

/* CHATBOX */
[data-tv-ai-launcher] .tv-ai-chatbox{
  position:fixed;
  right:16px;
  bottom:0;
  width:min(420px, calc(100vw - 32px));
  height:560px;
  background:#fff;
  border-radius:18px 18px 0 0;
  box-shadow:0 -6px 26px rgba(0,0,0,.18);
  border:1px solid rgba(15,23,42,.10);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  transform:translateY(10px) scale(.985);
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease, transform .18s ease;
  max-height:calc(100vh - 20px);
}
@supports (height:100dvh){
  [data-tv-ai-launcher] .tv-ai-chatbox{ max-height:calc(100dvh - 20px); }
}
[data-tv-ai-launcher].tv-ai-is-open .tv-ai-chatbox{
  opacity:1;
  transform:translateY(0) scale(1);
  pointer-events:auto;
}

/* HEADER */
[data-tv-ai-launcher] .tv-ai-chatbox__header{
  padding:10px 12px;
  border-bottom:1px solid rgba(15,23,42,.10);
  background:linear-gradient(135deg,#2563eb,#7c3aed);
  position:relative;
  flex:0 0 auto;
  color:#fff;
}
[data-tv-ai-launcher] .tv-ai-chatbox__header::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    radial-gradient(200px 140px at 0% 0%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(260px 160px at 100% 0%, rgba(255,255,255,.20), transparent 62%);
  opacity:.65;
}
[data-tv-ai-launcher] .tv-ai-headerbar{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  z-index:1;
}
[data-tv-ai-launcher] .tv-ai-head-left{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
  flex:1 1 auto;
}
[data-tv-ai-launcher] .tv-ai-chatbox__badge{
  width:40px;
  height:40px;
  border-radius:999px;
  background:rgba(15,23,42,.08);
  display:grid;
  place-items:center;
  flex:0 0 auto;
  box-shadow:0 6px 16px rgba(0,0,0,.25);
  border:0;
  color:#fff;
  font-size:20px;
}
[data-tv-ai-launcher] .tv-ai-head-text{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
  color:#fff;
}
[data-tv-ai-launcher] .tv-ai-head-title{
  font-weight:800;
  font-size:15px;
  letter-spacing:.2px;
  line-height:1.15;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
[data-tv-ai-launcher] .tv-ai-head-title b{ font-weight:900; }
[data-tv-ai-launcher] .tv-ai-head-sub{
  font-size:12px;
  color:rgba(255,255,255,.85);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
[data-tv-ai-launcher] .tv-ai-head-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  flex:0 0 auto;
}
[data-tv-ai-launcher] .tv-ai-actions-inline{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:6px;
  margin-top:2px;
}
[data-tv-ai-launcher] .tv-ai-action{
  width:30px;
  height:30px;
  border-radius:999px;
  border:0;
  background:transparent;
  box-shadow:none;
  display:flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  transform:translateZ(0);
  transition:transform .16s ease,filter .16s ease;
  padding:0;
}
[data-tv-ai-launcher] .tv-ai-action:hover{ transform:scale(1.05); filter:brightness(1.05); }
[data-tv-ai-launcher] .tv-ai-action:active{ transform:scale(.96); }
[data-tv-ai-launcher] .tv-ai-action img{
  width:28px;
  height:28px;
  object-fit:contain;
  display:block;
}

/* NÚT X */
[data-tv-ai-launcher] .tv-ai-close-float{
  appearance:none;
  -webkit-appearance:none;
  border:0;
  outline:0;
  background:transparent;
  padding:0;
  margin:0;
  cursor:pointer;
  color:#fff;
  font-size:0;
  line-height:1;
  -webkit-tap-highlight-color:transparent;
  width:26px;
  height:26px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
}
[data-tv-ai-launcher] .tv-ai-close-float::after{
  content:"✕";
  font-size:18px;
  color:#fff;
}
[data-tv-ai-launcher] .tv-ai-close-float:hover{ background:rgba(15,23,42,.18); }
[data-tv-ai-launcher] .tv-ai-close-float:active{ opacity:.8; }

/* BODY */
[data-tv-ai-launcher] .tv-ai-chatbox__body{
  flex:1 1 auto;
  min-height:0;
  padding:12px;
  overflow:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  scroll-behavior:auto;
  background:
    radial-gradient(900px 420px at 90% 20%, rgba(34,197,94,.06), transparent 55%),
    linear-gradient(180deg,#f9fafb,#e5e7eb);
  width:100%;
  max-width:100%;
  overflow-x:hidden;
}

/* MESSAGES */
[data-tv-ai-launcher] .tv-ai-msg{ display:flex; margin:8px 0; }
[data-tv-ai-launcher] .tv-ai-msg--bot{ justify-content:flex-start; }
[data-tv-ai-launcher] .tv-ai-msg--user{ justify-content:flex-end; }
[data-tv-ai-launcher] .tv-ai-bubble{
  max-width:86%;
  padding:8px 11px;
  border-radius:18px;
  line-height:1.4;
  font-size:14px;
  word-wrap:break-word;
  word-break:break-word;
  box-shadow:0 4px 10px rgba(0,0,0,.07);
}
[data-tv-ai-launcher] .tv-ai-msg--bot .tv-ai-bubble{
  background:#ffffff;
  color:#111827;
  border-bottom-left-radius:4px;
}
[data-tv-ai-launcher] .tv-ai-msg--user .tv-ai-bubble{
  background:#0084ff;
  color:#fff;
  border-bottom-right-radius:4px;
}

/* TYPING */
[data-tv-ai-launcher] .tv-ai-typing{
  display:flex;
  gap:6px;
  align-items:center;
  margin:10px 0 4px;
}
[data-tv-ai-launcher] .tv-ai-typing span{
  width:7px;
  height:7px;
  border-radius:999px;
  background:rgba(15,23,42,.35);
  animation:tvDot 1.1s infinite ease-in-out;
}
[data-tv-ai-launcher] .tv-ai-typing span:nth-child(2){ animation-delay:.12s; }
[data-tv-ai-launcher] .tv-ai-typing span:nth-child(3){ animation-delay:.24s; }
@keyframes tvDot{
  0%,80%,100%{ transform:translateY(0); opacity:.35; }
  40%{ transform:translateY(-4px); opacity:.9; }
}

/* FOOTER */
[data-tv-ai-launcher] .tv-ai-chatbox__footer{
  border-top:1px solid rgba(148,163,184,.6);
  background:#f9fafb;
  padding:8px;
  flex:0 0 auto;
  width:100%;
  max-width:100%;
}
[data-tv-ai-launcher] .tv-ai-form{
  display:flex;
  gap:8px;
  align-items:center;
}

/* INPUT */
[data-tv-ai-launcher] .tv-ai-input{
  flex:1 1 auto;
  height:40px;
  border-radius:20px;
  border:1px solid rgba(148,163,184,.9);
  padding:0 12px;
  font-size:15px;
  line-height:1.4;
  outline:none;
  background:#ffffff;
  transition:box-shadow .15s ease, border-color .15s ease;
  width:100%;
  max-width:100%;
}
[data-tv-ai-launcher] .tv-ai-input:focus{
  border-color:#2563eb;
  box-shadow:0 0 0 2px rgba(37,99,235,.25);
}

/* SEND */
[data-tv-ai-launcher] .tv-ai-send{
  width:40px;
  height:40px;
  border-radius:999px;
  border:0;
  padding:0;
  margin:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#0084ff;
  box-shadow:0 8px 16px rgba(37,99,235,.35);
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
[data-tv-ai-launcher] .tv-ai-send__label{
  font-size:11px;
  font-weight:900;
  color:#fff;
  text-transform:uppercase;
  letter-spacing:.2px;
  line-height:1;
  transform:translateY(-1px);
}
[data-tv-ai-launcher] .tv-ai-send:hover{
  filter:brightness(1.03);
  box-shadow:0 10px 22px rgba(37,99,235,.40);
}
[data-tv-ai-launcher] .tv-ai-send:active{ transform:translateY(1px) scale(.97); }

/* SUMMARY – THÔNG TIN XÁC NHẬN */
[data-tv-ai-launcher] .tv-ai-summary{ margin:0; }
[data-tv-ai-launcher] .tv-ai-summary__title{
  font-size:21px;
  font-weight:900;
  color:#2563eb;
  margin:2px 0 12px;
}
[data-tv-ai-launcher] .tv-ai-summary__list{
  margin:0;
  padding:0;
  list-style:none;
}
[data-tv-ai-launcher] .tv-ai-summary__row{
  display:flex;
  gap:10px;
  align-items:flex-start;
  padding:8px 10px;
  margin:3px 0;
  border-radius:10px;
  background:rgba(148,163,184,0.08);
}
[data-tv-ai-launcher] .tv-ai-summary__label{
  min-width:160px;
  font-weight:800;
  color:#0f766e;
  font-size:15px;
  white-space:nowrap;
}
[data-tv-ai-launcher] .tv-ai-summary__label::after{
  content:":";
  margin-left:2px;
}
[data-tv-ai-launcher] .tv-ai-summary__value{
  flex:1 1 auto;
  font-weight:600;
  color:#111827;
  font-size:14px;
  word-break:break-word;
}

/* ĐOẠN HƯỚNG DẪN XÁC NHẬN (đúng class trong PHP) */
[data-tv-ai-launcher] .tv-ai-confirm-hint{
  margin-top:10px;
  font-size:13px;
  color:#475569;
  line-height:1.5;
}
[data-tv-ai-launcher] .tv-ai-confirm-hint b{
  color:#2563eb;
  font-weight:800;
}

/* MOBILE */
@media (max-width:640px){
  [data-tv-ai-launcher]{
    right:12px;
    bottom:calc(12px + env(safe-area-inset-bottom, 0px));
  }
  [data-tv-ai-launcher] .tv-ai-external-actions{
    gap:8px;
    margin-bottom:8px;
  }

  /* FIX TRÀN KHUNG CHAT TRÊN MOBILE */
  [data-tv-ai-launcher] .tv-ai-chatbox{
    position:fixed !important;
    left:0 !important;
    right:0 !important;
    bottom:0 !important;
    top:auto !important;
    width:100vw !important;
    max-width:100vw !important;
    height:var(--tv-vh, 100dvh) !important;
    max-height:var(--tv-vh, 100dvh) !important;
    border-radius:0 !important;
    border-left:0 !important;
    border-right:0 !important;
    border-bottom:0 !important;
    transform:translateY(0) !important;
    overflow:hidden !important;
    padding-bottom:calc(var(--tv-kb, 0px) + env(safe-area-inset-bottom, 0px)) !important;
    touch-action:manipulation;
  }
  [data-tv-ai-launcher] .tv-ai-chatbox__header{
    padding-top:calc(10px + env(safe-area-inset-top, 0px));
  }
  [data-tv-ai-launcher] .tv-ai-chatbox__footer{
    padding-bottom:calc(8px + env(safe-area-inset-bottom, 0px));
  }
  [data-tv-ai-launcher] .tv-ai-bubble{ max-width:92%; }
}

/* LABEL co lại cho màn rất nhỏ */
@media (max-width:420px){
  [data-tv-ai-launcher] .tv-ai-summary__label{
    min-width:110px;
    white-space:normal;
  }
  [data-tv-ai-launcher] .tv-ai-summary__title{ font-size:18px; }
}

/* GIẢM ANIMATION */
@media (prefers-reduced-motion:reduce){
  [data-tv-ai-launcher] .tv-ai-ext-btn,
  [data-tv-ai-launcher] .tv-ai-action,
  [data-tv-ai-launcher] .tv-ai-send{
    transition:none;
  }
  [data-tv-ai-launcher] .tv-ai-ext-btn::after{ animation:none; }
}

/* GLOBAL TEXT SIZE FIX */
html, body{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}
