/* ========================= */
/* XVE ADVANCED CHAT BOT UI */
/* ========================= */

:root {
  --chat-gold: #f5c542;
  --chat-gold-soft: #ffe26f;
  --chat-black: #070707;
  --chat-dark: #0e0e0e;
  --chat-panel: #111111;
  --chat-panel-2: #171717;
  --chat-border: rgba(245, 197, 66, 0.22);
  --chat-text: #ffffff;
  --chat-muted: #a9a9a9;
  --chat-user: #f5c542;
  --chat-font: "Chakra Petch", "Poppins", sans-serif;
}

/* Floating chat Button */
.chat-toggle {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 60px;
  height: 60px;
  background: var(--chat-gold);
  border: 1px solid rgba(245, 197, 66, 0.7);
  border-radius: 18px;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.45),
    0 0 20px rgba(245, 197, 66, 0.22);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 9999 !important;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.chat-toggle:hover {
  background: var(--chat-gold-soft);
  transform: translateY(-2px);
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.5),
    0 0 26px rgba(245, 197, 66, 0.28);
}

.chat-toggle:active {
  transform: scale(0.95);
}

/* Keep button visible in normal state, but behind chat box when overlapping */
body.chat-open .chat-toggle {
  z-index: 9999 !important;
}

.chat-toggle * {
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
}

.chat-toggle span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

.chat-toggle img {
  width: 25px;
  height: 25px;
}

.chat-icon-close {
  font-size: 34px;
  font-weight: 600;
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Box */
.chat-box {
  position: fixed;
  bottom: 24px;
  right: 94px;
  width: 390px;
  max-width: calc(100vw - 120px);
  height: 620px;
  max-height: calc(100vh - 48px);
  color: var(--chat-text);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.04), transparent 35%),
    var(--chat-black);
  border: 1px solid var(--chat-border);
  border-radius: 22px;
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.6),
    0 0 28px rgba(245, 197, 66, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 999999 !important;
  overflow: hidden;
  font-family: var(--chat-font);
  isolation: isolate;
}

.chat-box.hidden {
  display: none;
}

/* Header */
.chat-header {
  position: relative;
  background:
    linear-gradient(135deg, rgba(245, 197, 66, 0.12), rgba(255, 255, 255, 0.02)),
    var(--chat-panel);
  padding: 15px 15px 14px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid rgba(245, 197, 66, 0.16);
  z-index: 3;
}

.chat-header::before {
  content: "";
  position: absolute;
  left: 15px;
  right: 15px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--chat-gold), transparent);
  opacity: 0.55;
}

.chat-header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--chat-gold);
  font-family: var(--chat-font);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.chat-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
  border-radius: 8px;
}

.chat-status {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #4caf50;
  margin-top: 6px;
  margin-left: 2px;
  font-weight: 700;
  letter-spacing: 0.03em;
  animation: fadeIn 0.25s ease-in-out;
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: #4caf50;
  border-radius: 50%;
  margin-right: 7px;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.7);
  animation: pulse-glow 1.5s infinite ease-in-out;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.4);
    opacity: 0.65;
  }

  50% {
    box-shadow: 0 0 12px rgba(76, 175, 80, 1);
    opacity: 1;
  }

  100% {
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.4);
    opacity: 0.65;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-header button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--chat-gold);
  border: 1px solid rgba(245, 197, 66, 0.22);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  border-radius: 12px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.chat-header button:hover {
  background: var(--chat-gold);
  color: #111111;
  transform: scale(1.04);
}

/* Agent chips */
.agent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.agent-bubble {
  background: rgba(245, 197, 66, 0.11);
  color: var(--chat-gold);
  border: 1px solid rgba(245, 197, 66, 0.24);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Chat Body */
.chat-body {
  padding: 14px;
  height: 100%;
  overflow-y: auto;
  background:
    radial-gradient(circle at top right, rgba(245, 197, 66, 0.05), transparent 28%),
    #0b0b0b;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
  z-index: 2;
}

.chat-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Message wrappers */
.message-wrapper {
  display: flex;
  align-items: flex-start;
  margin-bottom: 10px;
}

.bot-wrapper {
  flex-direction: row;
}

.user-wrapper {
  justify-content: flex-end;
}

.message-wrapper .avatar {
  width: 36px;
  height: 36px;
  border-radius: 13px;
  margin-right: 8px;
  object-fit: cover;
  border: 1px solid rgba(245, 197, 66, 0.28);
  background: #111111;
}

/* Message bubbles */
.message {
  position: relative;
  padding: 10px 12px;
  margin: 0;
  border-radius: 15px;
  max-width: 80%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  font-family: var(--chat-font);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  animation: slideIn 0.24s forwards;
}

@keyframes slideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.bot {
  color: #eeeeee;
  background: var(--chat-panel-2);
  border: 1px solid rgba(245, 197, 66, 0.12);
  border-top-left-radius: 5px;
}

.message.user {
  color: #111111;
  background: var(--chat-user);
  border: 1px solid rgba(245, 197, 66, 0.42);
  align-self: flex-end;
  text-align: left;
  border-top-right-radius: 5px;
}

.message.confirm-clear {
  border-color: rgba(255, 90, 90, 0.35);
}

.message-time {
  font-size: 10.5px;
  color: #8b8b8b;
  margin-top: 5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.message.user .message-time {
  color: rgba(0, 0, 0, 0.65);
}

.message-status {
  font-size: 10.5px;
  margin-left: 6px;
  color: #000000;
  font-weight: 700;
  opacity: 0.62;
}

/* Typing bubble */
.message.bot .typing-dots-wrap {
  padding: 0;
  margin: 0;
}

.message.bot.typing {
  padding: 7px 10px !important;
  line-height: 1;
  min-height: unset;
  font-size: 0;
}

.typing-dots-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 18px;
  padding: 0;
  margin: 0;
}

.typing-dot {
  width: 5px;
  height: 5px;
  background-color: var(--chat-gold);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(1);
    opacity: 0.55;
  }

  40% {
    transform: scale(1.45);
    opacity: 1;
  }
}

/* Input area */
.chat-input {
  display: flex;
  padding: 13px;
  border-top: 1px solid rgba(245, 197, 66, 0.15);
  background: var(--chat-panel);
  flex-direction: column;
  position: relative;
  z-index: 3;
}

.input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.input-wrapper textarea {
  width: 100%;
  height: 62px;
  resize: none;
  border: 1px solid rgba(245, 197, 66, 0.18);
  border-radius: 14px;
  background: #0b0b0b;
  color: var(--chat-text);
  padding: 11px 92px 10px 13px;
  outline: none;
  font-family: var(--chat-font);
  font-size: 13.5px;
  font-weight: 500;
  box-sizing: border-box;
  transition: border 0.2s ease, background 0.2s ease;
}

.input-wrapper textarea::placeholder {
  color: #777777;
}

.input-wrapper textarea:focus {
  border-color: rgba(245, 197, 66, 0.55);
  background: #090909;
}

/* Icon buttons */
.input-wrapper button#send-btn,
.input-wrapper button#image-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: #171717;
  border: 1px solid rgba(245, 197, 66, 0.18);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  height: 32px;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.input-wrapper button#send-btn:hover,
.input-wrapper button#image-btn:hover {
  background: var(--chat-gold);
  border-color: var(--chat-gold);
  transform: translateY(-50%) scale(1.04);
}

.input-wrapper button#send-btn img,
.input-wrapper button#image-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}

.input-wrapper button#send-btn {
  right: 10px;
}

.input-wrapper button#image-btn {
  right: 48px;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--chat-muted);
}

.powered-by {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--chat-muted);
}

.powered-by span {
  color: var(--chat-gold);
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.word-counter {
  font-size: 11.5px;
  color: var(--chat-muted);
  text-align: right;
  margin-top: 0;
  font-weight: 600;
}

.clear-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0.65;
  transition: 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
}

.clear-btn img {
  width: 100%;
  height: auto;
  display: block;
  filter: brightness(1.4);
}

.clear-btn:hover {
  opacity: 1;
  transform: scale(1.08);
}

/* Quick Replies */
.quick-replies {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 2px 0 10px;
  align-items: flex-end;
}

.quick-reply-btn {
  border: 1px solid rgba(245, 197, 66, 0.55);
  background: rgba(245, 197, 66, 0.08);
  color: var(--chat-gold);
  padding: 8px 11px;
  font-size: 12.5px;
  border-radius: 999px;
  font-weight: 700;
  font-family: var(--chat-font);
  cursor: pointer;
  transition: 0.2s ease;
  text-align: center;
  max-width: 82%;
}

.quick-reply-btn:hover {
  background-color: var(--chat-gold);
  color: #111111;
  transform: translateY(-1px);
}

/* Mobile */
@media (max-width: 568px) {
  body.chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  .chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 17px;
    z-index: 9999 !important;
  }

  body.chat-open .chat-toggle {
    z-index: 9999 !important;
  }

  .chat-toggle img {
    width: 23px;
    height: 23px;
  }

  .chat-box {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    z-index: 999999 !important;
    isolation: isolate;
  }

  .chat-header,
  .chat-body,
  .chat-input {
    position: relative;
    z-index: 3;
    background-clip: padding-box;
  }

  .chat-header {
    padding: 13px 14px 12px;
  }

  .chat-title {
    font-size: 15px;
  }

  .chat-logo {
    height: 28px;
  }

  .agent-list {
    gap: 5px;
  }

  .agent-bubble {
    font-size: 10px;
    padding: 4px 7px;
  }

  .chat-body {
    height: calc(100dvh - 168px);
    padding: 12px;
  }

  .message {
    max-width: 84%;
    font-size: 13.5px;
  }

  .chat-input {
    padding: 12px;
    background: var(--chat-panel);
  }

  .input-wrapper textarea {
    height: 60px;
    font-size: 13.5px;
  }
}

@media (max-width: 360px) {
  .chat-title {
    font-size: 14px;
  }

  .agent-bubble {
    font-size: 9.5px;
    padding: 4px 6px;
  }

  .message {
    max-width: 86%;
  }

  .quick-reply-btn {
    max-width: 90%;
  }
}


@media (max-width: 568px), (pointer: coarse) {
  body.chat-open {
    overflow: auto !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    touch-action: auto !important;
  }
}