:root{
  --ztgc-accent: #2f6bff;
  --ztgc-navy-1: #071629;
  --ztgc-navy-2: #0b1f3a;
  --ztgc-text: rgba(255,255,255,0.92);
  --ztgc-border: rgba(255,255,255,0.14);
  --ztgc-shadow: 0 20px 60px rgba(0,0,0,0.35);
  --ztgc-radius: 18px;
  --ztgc-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

#ztgc-root{ position: fixed; right: 18px; bottom: 18px; z-index: 999999; font-family: var(--ztgc-font); }

/* Floating button */
/* Floating button (FAB) */
.ztgc-fab{
  width: 64px; height: 64px;
  border-radius: 999px;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; user-select:none;
  position: relative;
  overflow: visible;
  background: radial-gradient(120% 120% at 18% 18%, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0) 55%),
              linear-gradient(135deg, var(--ztgc-accent) 0%, var(--ztgc-accent2, #32d2ff) 45%, var(--ztgc-accent3, #39d07a) 100%);
  box-shadow: var(--ztgc-shadow);
  border: 1px solid rgba(255,255,255,0.20);
  transition: transform .15s ease, filter .15s ease;
}

/* FAB inner wrapper: keeps the icon clipped while allowing outer pulse ring */
.ztgc-fab-iconwrap{
  width: 100%;
  height: 100%;
  border-radius: 999px;
  overflow: visible;
  display:flex;
  align-items:center;
  justify-content:center;
  position: relative;
  z-index: 2;
}

/* Gentle wave/pulse when chat is closed */
.ztgc-fab-pulse{
  position:absolute;
  inset: 0;
  border-radius: 999px;
  pointer-events:none;
  z-index: 0;
}
.ztgc-fab-pulse::before,
.ztgc-fab-pulse::after{
  content:'';
  position:absolute;
  inset: -7px;
  border-radius: 999px;
  border: 2px solid rgba(var(--ztgc-accent-rgb, 47,107,255), 0.30);
  opacity: 0;
  transform: scale(0.85);
}
.ztgc-fab.ztgc-attn .ztgc-fab-pulse::before{ animation: ztgcWave 2.6s ease-out infinite; }
.ztgc-fab.ztgc-attn .ztgc-fab-pulse::after{ animation: ztgcWave 2.6s ease-out infinite 1.3s; }

@keyframes ztgcWave{
  0%{ opacity: 0; transform: scale(0.88); }
  12%{ opacity: 0.65; }
  100%{ opacity: 0; transform: scale(1.55); }
}

/* Unread badge (number) */
.ztgc-fab-badge{
  position:absolute;
  right: 4px;
  top: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display:none;
  align-items:center;
  justify-content:center;
  background: #ff3b30;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.92), 0 10px 20px rgba(0,0,0,0.18);
  z-index: 5;
}
.ztgc-fab.ztgc-unread .ztgc-fab-badge{ display:flex; }
.ztgc-fab::before{
  content:'';
  position:absolute;
  left: 10px;
  top: 8px;
  width: 70%;
  height: 46%;
  border-radius: 999px;
  background: radial-gradient(closest-side at 20% 20%, rgba(255,255,255,0.90) 0%, rgba(255,255,255,0) 70%);
  transform: rotate(-10deg);
  opacity: 0.9;
  pointer-events:none;
}
.ztgc-fab-tail{
  position:absolute;
  left: 14px;
  bottom: -6px;
  width: 18px;
  height: 18px;
  transform: rotate(45deg);
  border-radius: 0 0 10px 0;
  background: linear-gradient(135deg, var(--ztgc-accent) 0%, var(--ztgc-accent2, #32d2ff) 45%, var(--ztgc-accent3, #39d07a) 100%);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
  pointer-events:none;
}
.ztgc-fab-dots{
  width: 36px;
  height: 10px;
  position: relative;
  pointer-events:none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.18));
  z-index: 2;
}
.ztgc-fab-dots::before{
  content:'';
  position:absolute;
  left: 0;
  top: 1px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.95);
  box-shadow: 14px 0 0 rgba(255,255,255,0.95), 28px 0 0 rgba(255,255,255,0.95);
}
.ztgc-fab svg{ width: 26px; height: 26px; fill: white; opacity: .95; }

.ztgc-fab .ztgc-fab-custom-icon{
  width: var(--ztgc-fab-icon-size, 30px);
  height: var(--ztgc-fab-icon-size, 30px);
  object-fit: contain;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.18));
}
.ztgc-fab.ztgc-hasicon .ztgc-fab-dots{ display:none; }

.ztgc-fab:hover{ transform: translateY(-2px); filter: brightness(1.05); }

/* Image-only FAB: replace the whole button with the icon (matches sample) */
.ztgc-fab.ztgc-hasicon{
  background: transparent !important;
  border: none !important;
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
}
.ztgc-fab.ztgc-hasicon .ztgc-fab-iconwrap{
  overflow: hidden;
}
.ztgc-fab.ztgc-hasicon::before{ display:none !important; }
.ztgc-fab.ztgc-hasicon .ztgc-fab-tail{ display:none !important; }
.ztgc-fab.ztgc-hasicon svg{ display:none !important; }
.ztgc-fab.ztgc-hasicon .ztgc-fab-custom-icon{
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  filter: none !important;
}

.ztgc-fab.ztgc-unread{
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 0 0 6px rgba(255,59,48,0.18);
}
.ztgc-fab.ztgc-nudge{
  animation: ztgcNudge 0.9s ease;
}

@keyframes ztgcPulse{
  0%{ transform: scale(0.9); opacity: 0.9; }
  60%{ transform: scale(1.1); opacity: 1; }
  100%{ transform: scale(0.9); opacity: 0.9; }
}
@keyframes ztgcNudge{
  0%{ transform: translateY(0); }
  20%{ transform: translateY(-3px); }
  40%{ transform: translateY(0); }
  60%{ transform: translateY(-2px); }
  100%{ transform: translateY(0); }
}

/* First-visit hint: flash FAB so users notice the chat button */
.ztgc-fab.ztgc-hint{
  animation: ztgcFabFlash 1.45s ease-in-out infinite;
}
.ztgc-fab.ztgc-hint:hover{ filter: brightness(1.03); }

@keyframes ztgcFabFlash{
  0%{
    transform: translateY(0) scale(1);
    box-shadow: var(--ztgc-shadow), 0 0 0 0 rgba(var(--ztgc-accent-rgb, 47,107,255), 0.35);
  }
  55%{
    transform: translateY(-2px) scale(1.03);
    box-shadow: var(--ztgc-shadow), 0 0 0 18px rgba(var(--ztgc-accent-rgb, 47,107,255), 0.00);
  }
  100%{
    transform: translateY(0) scale(1);
    box-shadow: var(--ztgc-shadow), 0 0 0 0 rgba(var(--ztgc-accent-rgb, 47,107,255), 0.00);
  }
}

/* Main panel */

.ztgc-panel{
  position: absolute;
  right: 0; bottom: 72px;
  width: 380px; max-width: calc(100vw - 36px);
  height: 540px; max-height: calc(100vh - 110px);
  border-radius: var(--ztgc-radius);
  /* cho phép nút X lồi ra ngoài mép */
  overflow: visible;
  background: #ffffff;
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 18px 45px rgba(15,23,42,0.35);
  display:none;
}
.ztgc-panel.open{ display:flex; flex-direction:column; }

/* Nút X kiểu "chấm đỏ" lồi ra ngoài mép trái */
.ztgc-close-out{
  position:absolute;
  left: -42px;
  top: 14px;
  width: 32px;
  height: 32px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.95);
  background: radial-gradient(circle at 30% 30%, #ff6b63 0%, #ff3b30 55%, #d81f1a 100%);
  color: #ffffff;
  cursor: pointer;
  padding: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 14px 34px rgba(15,23,42,0.32);
  z-index: 60;
  transition: transform .12s ease, filter .12s ease;
}
.ztgc-close-out:hover{ transform: translateY(-1px); filter: brightness(1.03); }
.ztgc-close-out:active{ transform: translateY(0); filter: brightness(0.98); }
.ztgc-close-char{
  display:block;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

/* Header */
.ztgc-header{
  border-top-left-radius: var(--ztgc-radius);
  border-top-right-radius: var(--ztgc-radius);
  padding: 12px 12px 12px 12px;
  display:flex; align-items:center; justify-content:flex-end;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 58%, #1d4ed8 100%);
  border-bottom: 1px solid rgba(15,23,42,0.10);
  position: relative;
  overflow: hidden;
}

.ztgc-header::after{
  content:"";
  position:absolute;
  top:0;
  right:0;
  width: 22px;
  height: 22px;
  background: #ffffff;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.ztgc-actions{ display:flex; gap:0; margin-right: 0; }
.ztgc-btn{
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #f59e0b 0%, #fb923c 100%);
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: transform .12s ease, filter .12s ease;
}
.ztgc-btn:hover{ transform: translateY(-1px); filter: brightness(1.05); }
.ztgc-min-char{
  display:block;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  color: rgba(255,255,255,0.92);
  transform: translateY(-1px);
}

/* Chat body */
.ztgc-body{
  flex: 1 1 auto;
  margin: 0;
  padding: 16px 18px;
  overflow:auto;
  display:flex; flex-direction:column; gap:10px;
  background: #ffffff;
  border-top: 1px solid rgba(15,23,42,0.04);
  border-bottom: 1px solid rgba(15,23,42,0.04);
}

.ztgc-msg{
  max-width: 86%;
  display:flex;
  flex-direction:column;
  gap: 4px;
  font-size: 13px;
  line-height: 1.35;
  word-wrap: break-word;
}
.ztgc-msg.admin{ align-self:flex-start; }
.ztgc-msg.user{ align-self:flex-end; }

.ztgc-bubble{
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.06);
  background: #f3f5f9;
  color: #0b1220;
}

.ztgc-msg.user .ztgc-bubble{
  /* Softer but CRISP user bubble (avoid blur / low-contrast text) */
  background: linear-gradient(135deg,
    rgba(var(--ztgc-accent-rgb,47,107,255),0.86) 0%,
    rgba(var(--ztgc-accent-rgb,47,107,255),0.68) 100%);
  border-color: rgba(var(--ztgc-accent-rgb,47,107,255),0.26);
  color: #ffffff;
}
/* Admin header (name + avatar) */
.ztgc-admin-meta{
  display:flex;
  align-items:center;
  gap: 6px;
  line-height: 1.1;
  margin: 0;
  opacity: 1;
}
.ztgc-admin-name{
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.2px;
  color: rgba(15,23,42,0.62);
}
.ztgc-admin-avatar{
  width: 16px;
  height: 16px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(0,0,0,0.10);
}

/* User header (name + avatar) */
.ztgc-user-meta{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 6px;
  line-height: 1.1;
  margin: 0;
  opacity: 1;
}
.ztgc-user-avatar{
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(15,23,42,0.06);
  border: 1px solid rgba(15,23,42,0.12);
  color: rgba(15,23,42,0.55);
}
.ztgc-user-avatar svg{ width: 12px; height: 12px; fill: currentColor; }
.ztgc-user-name{
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.2px;
  color: rgba(15,23,42,0.62);
}
.ztgc-msg.pending{ opacity: 0.65; }
.ztgc-msg.failed{ opacity: 0.9; }
.ztgc-msg.failed .ztgc-bubble{ border-color: rgba(255,0,0,0.25); background: #fff4f4; color: #7a0b0b; }
.ztgc-msg.ztgc-system{ max-width: 92%; }
.ztgc-msg.ztgc-system .ztgc-bubble{ background: #eef2ff; border-color: rgba(47,107,255,0.18); }

.ztgc-time{ margin-top: 6px; font-size: 11px; opacity: 0.7; }
.ztgc-msg.user .ztgc-bubble .ztgc-time{ color: rgba(255,255,255,0.85); opacity: 0.85; }

/* File cards in chat */
.ztgc-filecard{ display:flex; flex-direction:column; gap:6px; }
.ztgc-filelink{
  display:inline-block;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.08);
  background: #ffffff;
  color: #0b1220;
  text-decoration:none;
  font-weight: 700;
}
.ztgc-filemeta{ font-size: 12px; opacity: 0.75; }
.ztgc-imagecard .ztgc-filelink{ padding:0; border:none; background:transparent; }
.ztgc-image{
  max-width: 220px;
  max-height: 220px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.08);
  object-fit: cover;
}

/* Footer / Compose */
.ztgc-footer{
  margin: 0;
  padding: 8px 18px 10px;
  background: #ffffff;
  border-radius: 0 0 var(--ztgc-radius) var(--ztgc-radius);
  border-top: 1px solid #e5e7eb;
}

.ztgc-compose{ width: 100%; }
.ztgc-compose-bubble{ display:flex; flex-direction:column; gap: 3px; }

.ztgc-input{
  width: 100%;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #e5e7eb;
  background: transparent;
  color: #0b1220;
  padding: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.45;
  outline:none;
  resize:none;
  min-height: 28px;
  max-height: 120px;
  box-shadow: none;
}
.ztgc-input::placeholder{ color: rgba(107,114,128,0.95); }
.ztgc-input:focus{
  border-bottom-color: #3b82f6;
  box-shadow: none;
}

.ztgc-compose-actions{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap: 12px;
}

.ztgc-action{
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: transparent;
  cursor:pointer;
  padding: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: none;
  transition: background .12s ease, transform .12s ease;
}
.ztgc-action:hover{ background: #f3f4f6; transform: none; }
.ztgc-action:active{ background: #e5e7eb; }
.ztgc-emoji-face{ font-size: 15px; line-height: 1; color:#6b7280; }
.ztgc-action svg{ width: 15px; height: 15px; fill: #6b7280; }

.ztgc-send{
  margin-left:auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: none;
  background: #f3f4f6;
  color: #111827;
  font-weight: 600;
  cursor:pointer;
  box-shadow: none;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 0;
  transition: background .12s ease, transform .12s ease;
}
.ztgc-send::before{
  content: '\2191';
  font-size: 15px;
  line-height: 1;
  color: #6b7280;
}
.ztgc-send:hover{ background:#e5e7eb; transform: none; }
.ztgc-send:active{ background:#d1d5db; transform: translateY(1px); }

.ztgc-send-on{
  background:#3b82f6;
}
.ztgc-send-on::before{
  color:#ffffff;
}

.ztgc-hide{ display:none !important; }

/* Emoji popover */
.ztgc-emoji-pop{
  position: absolute;
  left: 12px;
  bottom: 86px;
  width: 280px;
  max-width: calc(100% - 24px);
  padding: 10px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 14px 40px rgba(0,0,0,0.18);
  display:none;
  gap: 6px;
  flex-wrap: wrap;
  z-index: 5;
}
.ztgc-emoji-pop.open{ display:flex; }
.ztgc-emoji{
  width: 34px; height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  background: #fff;
  cursor:pointer;
  font-size: 18px;
  display:flex; align-items:center; justify-content:center;
}
.ztgc-emoji:hover{ background:#f4f6ff; }

@media (max-width: 420px){
  #ztgc-root{ right: 12px; bottom: 12px; }
  .ztgc-panel{ width: calc(100vw - 24px); height: calc(100vh - 110px); }

  .ztgc-close-out{ left: -10px; top: 12px; width: 30px; height: 30px; }

  .ztgc-footer{ padding: 6px 12px 8px; }
  .ztgc-input{ min-height: 36px; }
  .ztgc-action{ width: 26px; height: 26px; }
  .ztgc-send{ width: 32px; height: 32px; border-radius: 999px; }
  .ztgc-emoji-pop{ bottom: 82px; }
}

/* ZingServer header text override */

