/* Reset and Base Styles */
.chat-window * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #fbe7ef transparent;
}

/* Chat bot GLOBAL SCROLLBAR */
.chat-window::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.chat-window::-webkit-scrollbar-track {
  background: transparent;
}

.chat-window::-webkit-scrollbar-thumb {
  background: #b5c3d1;
  border-radius: 10px;
}

.chat-window::-webkit-scrollbar-thumb:hover {
  background: #7d8da5;
}

.chat-window,
.chat-window input,
.chat-window textarea,
.chat-window button {
  font-family: "Montserrat", sans-serif;
}

.suggestion-bubbles-img {
  height: 16px !important;
  width: 16px !important;
}

/* Reset and Base Styles */
#queryInputId:focus {
  --tw-ring-shadow: none !important;
}

.chat-msg strong {
  font-weight: 700 !important;
}

/* Utility Classes (replacing Bootstrap) */
.d-flex {
  display: flex;
}

.align-items-center {
  align-items: center;
}

.text-center {
  text-align: center;
}

.justify-content-between {
  justify-content: space-between;
}

.p-2 {
  padding: 0.5rem;
}

.p-3 {
  padding: 1rem;
}

.d-none {
  display: none !important;
}

.shadow-lg {
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Chat Message Styles */
.chat-msg.bot p {
  margin-bottom: 0.5rem;
}

.chat-msg.bot ul,
.chat-msg.bot ol {
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
  padding-left: 1.5rem;
  list-style-position: outside;
}

.chat-msg.bot ul {
  list-style-type: disc;
}

.chat-msg.bot ol {
  list-style-type: decimal;
}

.chat-msg.bot li {
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
  line-height: 1.5;
}

.chat-msg.bot a {
  color: #d30e5e;
}

.chat-msg.bot hr {
  margin-bottom: 0.5rem;
}

/* Nested lists */
.chat-msg.bot ul ul {
  list-style-type: circle;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.chat-msg.bot ul ul ul {
  list-style-type: square;
}

.chat-msg.bot h1,
.chat-msg.bot h2,
.chat-msg.bot h3,
.chat-msg.bot h4,
.chat-msg.bot h5,
.chat-msg.bot h6 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 550;
}

/* Table Styles in Bot Messages */
.chat-table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0;
  border-radius: 8px;
}

.chat-msg.bot table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 0;
  margin: 0.35rem 0;
  background: #ffffff;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  overflow: hidden;
}

.chat-msg.bot th,
.chat-msg.bot td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #d0d7de;
  border-right: 1px solid #d0d7de;
  width: auto;
  max-width: none;
  white-space: normal;
  overflow-wrap: break-word;
}

.chat-msg.bot tr > :last-child {
  border-right: none;
}

.chat-msg.bot tr:last-child > td {
  border-bottom: none;
}

.chat-msg.bot th {
  font-weight: 600;
  background: #fbe7ef;
  color: #08161b;
}

.chat-msg.bot > table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Floating Chat Button */
.chat-float-btn {
  position: fixed;
  bottom: 25px;
  left: 25px;
  width: 56px;
  height: 56px;
  background: #d30d5f;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  transition: 0.3s ease;
  z-index: 2147483640;
  border: none;
}

.chat-float-btn img {
  width: 24px;
  height: 24px;
}

.chat-float-btn:hover {
  transform: scale(1.1);
}

/* Ring animation */
.chat-float-btn::before {
  content: "";
  position: absolute;
  width: 72px;
  height: 72px;
  background: #d30d5f40;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  animation: ringPulse 1.8s infinite;
  z-index: -1;
}

/* Smooth pulsating ring */
@keyframes ringPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.6;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 0;
  }

  100% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.6;
  }
}

/* Chat Window */
.chat-window {
  --header-height: 70px;
  /* --footer-height: 120px; */
  /* Default, will be updated by JS */
  width: 494px;
  height: 592px;
  /* background-color: #E5F3F8; */
  position: fixed;
  bottom: 90px;
  left: 25px;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483640;
  border-radius: 24px;
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
}

/* OPEN */
.chat-window.open {
  opacity: 1;
  transform: translateY(0px) scale(1);
  pointer-events: auto;
}

/* CLOSING STATE */
.chat-window.closing {
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  pointer-events: none;
}

/* EXPAND MODE */
.chat-window.expand {
  width: 550px;
  height: 85vh;
  max-height: 85vh;
}

.chat-window.expand #chat-body {
  flex: 1;
  min-height: 0;
  max-height: calc(85vh - var(--header-height) - var(--footer-height));
  height: calc(85vh - var(--header-height) - var(--footer-height));
}

/* When chat is expanded, give the textarea more room to grow */
.chat-window.expand .chat-textarea {
  min-height: 80px;
  max-height: 300px;
}

/* Header */
.chat-header {
  background: #fbe7ef;
  color: #184859;
  padding: 20px 22px;
  border-bottom: 0.5px solid #f6cfdf;
  overflow: visible;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-main-title {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.chat-main-title h6 {
  font-weight: 600;
  font-size: 16px;
  margin: 0;
  color: #d30d5f;
}

.chat-avatar {
  width: 28px;
  height: 28px;
}

.icon-list {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: visible;
  position: relative;
  z-index: 10;
}

.new-chat-wrapper {
  display: inline-flex;
  cursor: pointer;
  border-radius: 8px;
  position: relative;
  padding: 4px;
  transition: background-color 0.2s ease;
}

.new-chat-wrapper:hover {
  background-color: #fff4f8;
}

/* Tooltip Styles */
.new-chat-wrapper[data-tooltip] {
  position: relative;
  overflow: visible;
}

.new-chat-wrapper[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background-color: #333;
  color: white;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  min-width: max-content;
}

.new-chat-wrapper[data-tooltip]:hover::before {
  content: "";
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: #333;
  z-index: 10001;
  pointer-events: none;
}

/* Chat Messages */
.chat-msg {
  font-weight: 500;
  font-size: 15px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 60%;
  padding: 10px;
  width: fit-content;
  border-radius: 18px;
  color: #08161b;
}

/* USER MESSAGE = RIGHT SIDE */
.chat-msg.user {
  background: #d30d5f;
  color: white;
  margin-left: auto;
  border-radius: 8px 8px 2px 8px;
  margin-bottom: 10px;
}

/* BOT MESSAGE = LEFT SIDE */
.chat-msg.bot {
  background-color: #f2f2f2;
  margin-right: auto;
  border-radius: 8px;
  max-width: 90% !important;
  font-size: 15px;
  font-weight: 500;
  color: #404040;
}

/* Chat body scroll limit */
#chat-body {
  height: calc(500px - var(--footer-height));
  max-height: calc(500px - var(--footer-height));
  overflow-y: auto;
  padding-bottom: 15px;
  position: relative;
  display: flex;
  flex-direction: column;
  flex-shrink: 1;
  flex-grow: 1;
  background-color: #ffffff;
}

/* Typing indicator placed like bot message (left) */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-top: 6px;
  margin-bottom: 10px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 18px 18px 18px 0;
}

/* Hide typing indicator */
.typing-indicator-hidden {
  display: none;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 10px;
  height: 10px;
  background: #fbe7ef;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

/* Animations: delay for each dot */
.typing-dots span:nth-child(1) {
  animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.4s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.8s;
}

@keyframes typingBounce {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0) scale(0.9);
  }

  40% {
    opacity: 1;
    transform: translateY(-6px) scale(1);
  }
}

.chat-footer-main {
  position: relative;
  flex-shrink: 0;
}

/* Footer */
.chat-footer {
  background: #ffffff;
  /* border-radius: 0 0 24px 24px; */
  flex-shrink: 0;
}

.chat-footer-divider {
  border: none;
  height: 1px;
  background-color: #e2e2e2;
  margin: auto !important;
}

.chat-input-outer-box {
  padding: 16px;
  padding-bottom: 0;
}

.chat-input-box {
  /* padding: 16px; */
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  border: 1px solid #e2e2e2;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.chat-form-cls {
  width: 100%;
  position: relative;
}

.chat-textarea {
  width: 90%;
  min-height: 55px;
  max-height: 120px;
  resize: none;
  border: none;
  outline: none;
  padding-left: 0 !important;
  padding-right: 10px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  font-size: 15px;
  line-height: 18px;
  overflow-y: auto;
  font-family: "Montserrat", sans-serif;
}

.chat-input-box:has(.chat-textarea:focus) {
  border-color: #d30d5f;
}

.chat-textarea::placeholder {
  color: #667085;
  font-weight: 500;
  font-size: 15px;
}

.chat-send-btn {
  position: absolute;
  right: 0px;
  bottom: 0px;
  background: #d30d5f;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: #ad054b;
}

.chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send-btn img {
  width: 18px;
}

.chat-suggestions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 5px;
  /* overflow: auto; */
  flex-direction: column;
  padding: 4px 2px;
  width: 100%;
  margin-top: 5px;
  margin-bottom: 10px;
}

.suggestion-bubble {
  background: #ffffff;
  border: 1px solid #f4f8fa;
  padding: 12px 8px;
  font-size: 15px;
  font-weight: 500;
  color: #667085;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 0 1 auto;
  text-align: start;
  line-height: normal;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 44px;
}

.suggestion-bubble:hover {
  /* transform: translateY(-2px); */
  background-color: #fff4f8;
  color: #404040;
}

.suggestion-bubble:active {
  transform: translateY(0);
}

.chat-msg.bot.handoff-card {
  max-width: 100% !important;
}

.handoff-card input,
.handoff-card textarea {
  width: 100%;
  box-sizing: border-box;
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid #c9d6dc;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
}

.handoff-card textarea {
  resize: vertical;
  min-height: 64px;
}

.handoff-card input:focus {
  outline: none;
  border: 1px solid #d30d5f;
}

.handoff-card textarea:focus {
  outline: none !important;
  border: 1px solid #d30d5f;
}

.handoff-error {
  color: #b00020;
  font-size: 13px;
  margin-top: 4px;
}

.handoff-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.handoff-send,
.handoff-decline {
  padding: 8px 14px;
  min-height: 36px;
  line-height: 1.3;
  margin: 0;
  border-radius: 20px;
  border: 1px solid #d30d5f;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.handoff-send {
  background: #d30d5f;
  color: #fff;
}

.handoff-decline {
  background: #fff;
  color: #08161b;
}

.handoff-send:disabled,
.handoff-decline:disabled {
  opacity: 0.6;
  cursor: default;
}

.bottom-bot-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.bottom-bot-notice p {
  color: #404040;
  font-size: 11px;
  font-weight: 500;
  padding: 8px 0px;
}

/* Hide Button while Cookie banner is available */
body:has(.cky-consent-container:not(.cky-hide)) #chat-btn {
  display: none;
}

/* Hide Button while the cookie preferences window is open */
body:has(.cky-modal.cky-modal-open) #chat-btn {
  display: none;
}

@media (max-width: 600px) {
  .chat-window {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    /* Pin modal to top on mobile so header is never cut off */
    top: 0 !important;
    left: 0 !important;
  }

  .chat-window.closing {
    transform: none !important;
  }

  .chat-header {
    border-radius: 0 !important;
    padding-top: max(20px, env(safe-area-inset-top));
  }

  .chat-window #chat-body {
    flex: 1 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
  }

  .chat-footer-main {
    padding-bottom: env(safe-area-inset-bottom);
  }

  #expand-chat {
    display: none !important;
  }

  .chat-msg.bot th,
  .chat-msg.bot td {
    padding: 6px 8px;
    font-size: 13px;
  }

  .chat-msg.bot:has(.chat-table-wrapper) {
    max-width: 100% !important;
  }
}

/* Chat bot panel move the left side When screen height is short */
@media (min-width: 601px) and (max-height: 680px) {
  .chat-window {
    right: 95px !important;
    bottom: 25px !important;
    height: calc(100vh - 40px) !important;
    height: calc(100dvh - 40px) !important;
    max-height: calc(100vh - 40px) !important;
    max-height: calc(100dvh - 40px) !important;
    width: min(494px, calc(100vw - 120px)) !important;
  }

  .chat-window #chat-body {
    flex: 1 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
  }

  .chat-window.expand {
    width: min(550px, calc(100vw - 120px)) !important;
    height: calc(100vh - 40px) !important;
    max-height: calc(100vh - 40px) !important;
  }
}