.chat-widget {
  --chat-launcher-right: 22px;
  --chat-launcher-bottom: 22px;
  --chat-launcher-size: 76px;
  --zalo-launcher-size: 56px;
}
.chat-launcher{position:fixed;right:var(--chat-launcher-right);bottom:var(--chat-launcher-bottom);width:var(--chat-launcher-size);height:var(--chat-launcher-size);border:0;border-radius:50%;background:#08a5c9;color:#fff;box-shadow:0 4px 18px #0003;display:grid;place-items:center;z-index:1000;cursor:pointer}.chat-launcher span{position:absolute;right:-3px;top:-3px;border-radius:20px;background:#ef3f36;color:white;font-size:12px;min-width:22px;padding:2px}.chat-window{position:fixed;right:22px;bottom:94px;width:min(360px,calc(100vw - 24px));max-height:calc(100dvh - 120px);overflow:auto;border:1px solid #ddd;border-radius:14px;background:#fff;color:#222;box-shadow:0 8px 35px #0003;z-index:1000}.chat-window header{display:flex;align-items:center;justify-content:space-between;background:#08a5c9;color:white;padding:14px}.chat-window header button{background:transparent;color:white;border:0;font-size:28px;cursor:pointer}.chat-intro{font-size:13px;padding:0 14px}.chat-messages{height:280px;overflow:auto;padding:12px;background:#f6f8fa;overscroll-behavior:contain}.chat-bubble{max-width:88%;width:fit-content;background:#fff;border-radius:12px;padding:9px 12px;margin-bottom:10px;overflow-wrap:anywhere}.chat-bubble p{white-space:pre-wrap;margin:0 0 4px}.chat-bubble small{font-size:10px;color:#53616c}.chat-bubble.is-outgoing{margin-left:auto;margin-right:0;background:#dff5fc}.chat-bubble.is-incoming{margin-left:0;margin-right:auto;background:#fff}.chat-status{font-size:13px;color:#b42318;margin:8px 12px}.chat-window form{padding:12px}.chat-window input,.chat-window textarea{font-size:14px;padding:10px;width:100%;min-width:0}.chat-window form,.chat-identity{display:grid;gap:8px}.chat-window [hidden],.chat-launcher [hidden],.chat-identity[hidden]{display:none!important}.chat-admin-layout{display:grid;grid-template-columns:290px minmax(0,1fr);gap:24px}.chat-admin-layout .chat-messages{height:420px}.chat-admin-layout form{display:grid;gap:10px}.chat-thread{display:block;width:100%;text-align:left;padding:12px;border:1px solid #dbe3ec;border-radius:8px;background:white;color:#222;margin-bottom:8px;cursor:pointer;overflow-wrap:anywhere}.chat-thread.selected{background:#e0f4fc;border-color:#08a5c9}@media(max-width:700px){.chat-admin-layout{grid-template-columns:1fr}.chat-widget{--chat-launcher-right:14px;--chat-launcher-bottom:16px}.chat-window{right:12px;bottom:86px}.chat-messages{height:240px}}

.chat-launcher{animation:chat-pulse 2.6s ease-out infinite}.chat-launcher svg{width:38px;height:38px}.chat-window{bottom:110px}.chat-toolbar{display:flex;gap:8px}.chat-toolbar button,.chat-emojis button{background:#f0f7fa;border:1px solid #d9e6ec;border-radius:8px;padding:7px;cursor:pointer}.chat-emojis{display:flex;flex-wrap:wrap;gap:5px}.chat-emojis[hidden]{display:none}.chat-emojis button{font-size:22px}.chat-pending{display:grid;gap:6px}.chat-pending>div{display:flex;align-items:center;gap:6px;font-size:12px;overflow-wrap:anywhere}.chat-pending img{width:44px;height:44px;object-fit:cover;border-radius:6px}.chat-pending button{margin-left:auto;cursor:pointer}.chat-attachment{display:block;color:#096788;margin:8px 0;overflow-wrap:anywhere}.chat-attachment img{display:block;max-width:100%;max-height:240px;border-radius:8px;object-fit:contain}.chat-attachment span{font-size:12px}.chat-admin-layout small{font-size:12px}@keyframes chat-pulse{0%{box-shadow:0 4px 18px #0003,0 0 0 0 #08a5c955}70%{box-shadow:0 4px 18px #0003,0 0 0 15px #08a5c900}100%{box-shadow:0 4px 18px #0003,0 0 0 0 #08a5c900}}@media(prefers-reduced-motion:reduce){.chat-launcher{animation:none}}

.chat-window{display:flex;flex-direction:column;height:min(650px,calc(100dvh - 130px));overflow:hidden}.chat-window header,.chat-window .chat-intro{flex-shrink:0}.chat-window .chat-intro{margin:8px 0}.chat-window .chat-messages{flex:1;min-height:60px;height:auto}.chat-window form{flex-shrink:0;max-height:55%;overflow:auto}.chat-window .chat-status{flex-shrink:0;margin:4px 12px}.chat-window form small{font-size:11px}

.chat-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:12px}.chat-heading h2{margin:0}.chat-conversation-state{padding:10px 12px;background:#e8f7ee;color:#19613b;font-size:13px;border-radius:8px;margin:8px 0}.chat-conversation-state[hidden]{display:none}.chat-window .chat-conversation-state{flex-shrink:0;margin:4px 12px}.chat-bubble.chat-system{margin:12px auto;background:transparent;color:#526273;text-align:center;font-size:12px;max-width:100%}

.chat-composer{display:flex;align-items:flex-end;gap:3px;border:1px solid #e1e4e8;border-radius:22px;background:#fff;padding:5px 6px 5px 12px}.chat-composer textarea,.chat-window .chat-composer textarea{flex:1;min-width:0;width:auto;border:0!important;box-shadow:none!important;outline:none!important;border-radius:0;background:transparent;padding:7px 3px;resize:none;min-height:34px;height:34px;font:inherit;font-size:14px;line-height:20px}.chat-composer-actions{display:flex;align-items:center;gap:0;flex-shrink:0}.chat-composer-actions button{display:grid;place-items:center;width:31px;height:34px;padding:5px;border:0;border-radius:50%;background:transparent;color:#20262d;cursor:pointer}.chat-composer-actions button:hover{background:#edf4f8}.chat-composer-actions button:focus-visible{outline:none;outline-offset:0}.chat-composer-actions svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.chat-composer-actions .chat-send{color:#08a5c9}.chat-composer-actions button:disabled{opacity:.4;cursor:default}.chat-compose-help{color:#687782;font-size:10px!important}.chat-pending:empty{display:none}.chat-emojis:empty{display:none}.chat-window form{gap:6px}.chat-admin-layout form .chat-composer textarea{min-height:34px}.chat-window form .chat-emojis button{padding:4px}

.chat-window-controls{display:flex;align-items:center;gap:8px}.chat-window-controls button{width:28px;height:32px;display:grid;place-items:center;padding:0!important}.chat-end-dialog{border:0;border-radius:16px;padding:24px;width:min(420px,calc(100vw - 32px));color:#243447;box-shadow:0 15px 60px #0004}.chat-end-dialog::backdrop{background:#0006}.chat-end-dialog h2{font-size:21px;margin-top:0}.chat-end-dialog>div{display:flex;gap:10px;justify-content:flex-end}.chat-end-dialog button{border:1px solid #dbe3ec;border-radius:9px;padding:10px 14px;background:white;color:#243447;cursor:pointer}.chat-end-dialog [data-chat-end-confirm]{background:#ef4036;color:white;border-color:#ef4036}.chat-end-dialog [data-chat-end-error]{color:#b42318}

[data-chat-root] .chat-bubble.is-outgoing{margin-left:auto!important;margin-right:0!important;background:#dff5fc!important;color:#172b3a}[data-chat-root] .chat-bubble.is-incoming{margin-left:0!important;margin-right:auto!important;background:#fff!important;color:#172b3a}

.chat-starting .chat-window form{flex:1;max-height:none;display:flex;flex-direction:column;justify-content:center;padding:24px}.chat-starting .chat-identity{display:grid;gap:14px;width:100%;margin:auto 0}.chat-starting .chat-messages,.chat-starting .chat-composer,.chat-starting .chat-emojis,.chat-starting .chat-pending{display:none!important}.chat-start-button{width:100%;border-radius:10px!important;padding:12px!important}.chat-starting .chat-identity input{border-radius:8px;padding:12px}.chat-starting .chat-status:empty{display:none}

.chat-thread-row{display:flex;align-items:center;gap:6px;margin-bottom:8px}.chat-thread-row .chat-thread{flex:1;min-width:0;margin-bottom:0}.chat-thread-trash{display:grid;place-items:center;flex-shrink:0;width:34px;height:38px;border:1px solid #f1d1d1;border-radius:8px;background:#fff;color:#d43b36;cursor:pointer}.chat-thread-trash svg{width:19px;height:19px}.chat-thread-trash:hover{background:#fff0ef}[data-chat-delete-confirm]{background:#ef4036!important;border-color:#ef4036!important;color:white!important}

.zalo-launcher {
  position: fixed;
  right: calc(var(--chat-launcher-right) + (var(--chat-launcher-size) - var(--zalo-launcher-size)) / 2);
  bottom: calc(var(--chat-launcher-bottom) + var(--chat-launcher-size) + 12px);
  width: var(--zalo-launcher-size);
  height: var(--zalo-launcher-size);
  display: grid;
  place-items: center;
  z-index: 1000;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 4px 16px #003c9550;
  animation: zalo-pulse 2.8s ease-out infinite;
  text-decoration: none;
}
.zalo-launcher img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}
.chat-launcher[aria-expanded="true"] + .zalo-launcher { display: none; }
.zalo-launcher:hover img, .zalo-launcher:focus-visible img { transform: scale(1.06); }
@keyframes zalo-pulse {
  0% { box-shadow: 0 4px 16px #003c9550, 0 0 0 0 #0068ff55; }
  65%, 100% { box-shadow: 0 4px 16px #003c9550, 0 0 0 10px #0068ff00; }
}
@media (prefers-reduced-motion: reduce) {
  .zalo-launcher { animation: none; }
}

.chat-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-heading-actions button { min-height: 36px; padding: 7px 12px; }
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  width: fit-content;
  max-width: 88%;
  margin: 0 0 8px;
}
.chat-message.is-outgoing {
  align-items: flex-end;
  margin-inline-start: auto;
}
.chat-message-sender {
  padding-inline: 6px;
  color: #455766;
  font-size: 12px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.chat-message.is-outgoing .chat-message-sender { text-align: end; }
.chat-message > .chat-bubble { max-width: 100%; margin-block: 0; }

.chat-admin-conversation {
  display: flex;
  flex-direction: column;
  height: clamp(380px, calc(100dvh - 200px), 650px);
}
.chat-admin-conversation .chat-messages { flex: 1; min-height: 0; height: auto; }
.chat-admin-conversation :is(.chat-heading, .chat-conversation-state, .chat-status, form) { flex: none; }
.chat-admin-conversation form { gap: 6px; }
.chat-status:empty { display: none; }

.chat-pending { grid-template-columns: repeat(3, minmax(0, 104px)); }
.chat-pending > div {
  position: relative;
  display: grid;
  grid-template-rows: 42px auto;
  align-content: start;
  min-width: 0;
  gap: 2px;
  padding: 4px;
  border: 1px solid #dce6ef;
  border-radius: 8px;
  background: #f6f9fc;
}
.chat-pending img { width: 100%; height: 42px; }
.chat-pending > div > span {
  grid-row: 2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-pending button {
  position: absolute;
  inset: 3px 3px auto auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid #dce6ef;
  border-radius: 50%;
  color: #253449;
  background: #fff;
}

.chat-message--gallery { width: min(88%, 312px); }
.chat-message--gallery > .chat-bubble { width: 100%; }
.chat-attachment-gallery {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  margin-block: 4px;
}
.chat-attachment-gallery .chat-attachment { min-width: 0; margin: 0; }
.chat-attachment-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.chat-attachment-gallery span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
