/* ==========================================================================
   Chatbot widget – plain CSS (no utility framework)

   Colours come from the CSS custom properties below. The defaults here are
   overridden by the colours saved in Settings → Chatbot (printed in <head>).
   ========================================================================== */

/* ---------- Variables ---------- */
.cb-widget {
  --cb-primary: #C24C33;
  --cb-dark: #5C2A20;
  --cb-secondary: #A93E28;
  --cb-icon-bg: #5C2A20;
  --cb-body-bg: #FDFAF8;
  --cb-welcome-clr: #5C2A20;
  --cb-accent-clr: #B0685A;
  --cb-pr-rgb: 194, 76, 51;
  --cb-dr-rgb: 92, 42, 32;

  /* Derived from the dashboard colours – nothing below is a fixed brand colour */
  --cb-text: var(--cb-dark);
  --cb-border: #E8D9D0;
  --cb-border: color-mix(in srgb, var(--cb-primary) 22%, #fff);
  --cb-border-soft: #F2E4DC;
  --cb-border-soft: color-mix(in srgb, var(--cb-primary) 14%, #fff);
  --cb-glow: #F09367;
  --cb-glow: color-mix(in srgb, var(--cb-primary) 60%, #fff);

  --cb-toggle-size: 56px;
  --cb-header-avatar: 48px;
  --cb-hero-avatar: 96px;
}

@media (min-width: 768px) {
  .cb-widget {
    --cb-toggle-size: 64px;
    --cb-hero-avatar: 112px;
  }
}

/* ---------- Base / reset (scoped to the widget) ---------- */
.cb-widget,
.cb-widget *,
.cb-widget *::before,
.cb-widget *::after {
  box-sizing: border-box;
}

/* Neutralise theme styles for buttons/inputs (e.g. [type=button] borders, colours, radius, hover fill) */
#chatbotWidget button,
#chatbotWidget input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  font: inherit;
  letter-spacing: normal;
  text-decoration: none;
  text-shadow: none;
  text-transform: none;
  white-space: normal;
  outline: none;
  transition: none;
}

#chatbotWidget button:focus-visible {
  outline: 2px solid var(--cb-primary);
  outline-offset: 2px;
}



/* ---------- Widget root ---------- */
.cb-widget {
  position: fixed;
  right: 16px;
  bottom: 10px;
  z-index: 1000000;
  font-family: Fustat, sans-serif;
  pointer-events: none;
}

.cb-widget > * {
  pointer-events: auto;
}

@media (min-width: 768px) {
  .cb-widget {
    right: 28px;
    bottom: 20px;
  }
}

/* ==========================================================================
   Toggle button
   ========================================================================== */
#chatbotWidget .cb-toggle {
  position: relative;
  display: block;
  width: var(--cb-toggle-size);
  height: var(--cb-toggle-size);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

#chatbotWidget .cb-toggle:hover {
  transform: scale(1.1);
}

.cb-toggle__halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-color: var(--cb-primary);
  opacity: .3;
}

.cb-toggle__face {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(to bottom right, var(--cb-primary), var(--cb-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px -12px rgba(var(--cb-pr-rgb), .55), 0 4px 12px rgba(var(--cb-pr-rgb), .25);
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

.cb-toggle__icon {
  position: absolute;
  width: 100%;
  height: 100%;
  padding: 8px;
  border-radius: 50%;
  object-fit: cover;
  opacity: 1;
  transform: scale(1) rotate(0deg);
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

.cb-toggle__close {
  position: absolute;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #fff;
  opacity: 0;
  transform: scale(.5) rotate(-90deg);
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

@media (min-width: 768px) {
  .cb-toggle__close {
    width: 28px;
    height: 28px;
  }
}

/* Notification badge */
.cb-toggle__badge {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
  display: flex;
  width: 16px;
  height: 16px;
}

.cb-toggle__badge-ping {
  position: absolute;
  display: inline-flex;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--cb-glow);
  opacity: .7;
  animation: cbPing 1s cubic-bezier(0, 0, .2, 1) infinite;
}

.cb-toggle__badge-dot {
  position: relative;
  display: inline-flex;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: linear-gradient(to bottom right, #4ade80, #22c55e); /* Light green to vibrant green */
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.6); /* Green glow effect */
}

/* Toggle while the chat is open */
#chatbotWidget.is-open .cb-toggle {
  opacity: 0;
  transform: scale(.5);
  pointer-events: none;
}

.cb-widget.is-open .cb-toggle__halo {
  opacity: 0;
}

.cb-widget.is-open .cb-toggle__icon {
  opacity: 0;
  transform: scale(.5) rotate(90deg);
}

.cb-widget.is-open .cb-toggle__close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.cb-widget.is-open .cb-toggle__badge {
  display: none;
}

/* ==========================================================================
   Chat panel
   ========================================================================== */
.cb-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 16px);
  width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 28px;
  box-shadow:
    0 32px 64px -16px rgba(var(--cb-dr-rgb), .28),
    0 12px 24px -8px rgba(var(--cb-dr-rgb), .12),
    0 0 0 1px rgba(var(--cb-dr-rgb), .06);
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px) scale(.96);
  transition: opacity .3s cubic-bezier(.4, 0, .2, 1), transform .3s cubic-bezier(.4, 0, .2, 1), bottom .3s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .3s;
}

@supports (height: 100dvh) {
  .cb-panel {
    height: min(640px, calc(100dvh - 120px));
  }
}

@media (min-width: 768px) {
  .cb-panel {
    width: 420px;
  }
}

.cb-widget.is-open .cb-panel {
  bottom: 0;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition-delay: 0s;
}

/* ---------- Header ---------- */
.cb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 20px 24px;
  color: #fff;
  background: linear-gradient(to bottom right, var(--cb-dark), var(--cb-secondary));
}

.cb-header__main {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.cb-header__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--cb-header-avatar);
  height: var(--cb-header-avatar);
  padding: 8px;
  overflow: hidden;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--cb-icon-bg);
  box-shadow: 0 0 0 3px var(--cb-border-soft);
}

.cb-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cb-avatar-fallback {
  display: none;
  fill: #fff;
}

.cb-header__avatar .cb-avatar-fallback {
  width: 22px;
  height: 22px;
}

.cb-header__text {
  flex: 1;
  min-width: 0;
}

.cb-header__title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
}

.cb-header__status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, .82);
}

.cb-header__status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #4ADE80; /* online indicator stays green */
}

.cb-header__status.is-typing::before {
  background-color: var(--cb-glow);
  animation: cbStatusPulse 1.2s ease-in-out infinite;
}

.cb-header__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

#chatbotWidget .cb-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0 !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: rgba(255, 255, 255, .9) !important;
  cursor: pointer;
  transition: background-color .2s ease;
}

#chatbotWidget #chatbotMaximize {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0 !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: rgba(255, 255, 255, .9) !important;
  cursor: pointer;
  transition: background-color .2s ease;
}

/* Hide on mobile screens */
@media (max-width: 768px) {
  #chatbotWidget #chatbotMaximize {
    display: none !important;
  }
}

#chatbotWidget .cb-icon-btn:hover {
  background-color: rgba(255, 255, 255, .15) !important;
}

#chatbotWidget .cb-icon-btn svg {
  display: block;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
}

#chatbotWidget .cb-icon-btn--close svg {
  width: 26px;
  height: 26px;
}

/* ==========================================================================
   Messages area
   ========================================================================== */
.cb-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 0%;
  min-height: 0;
  padding: 24px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scroll-behavior: smooth;
  background-color: var(--cb-body-bg);
}

.cb-messages > * {
  flex-shrink: 0;
}

.cb-messages::-webkit-scrollbar {
  width: 6px;
}

.cb-messages::-webkit-scrollbar-track {
  background: transparent;
}

.cb-messages::-webkit-scrollbar-thumb {
  background: var(--cb-border);
  border-radius: 9999px;
}

/* ---------- Welcome screen ---------- */
.chatbot-welcome {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  animation: cbFadeInUp .25s ease-out forwards;
}

.cb-welcome__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 0%;
  padding: 16px 0;
  text-align: center;
}

.chatbot-hero-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--cb-hero-avatar);
  height: var(--cb-hero-avatar);
  padding: 16px;
  overflow: hidden;
  border-radius: 50%;
  border: 5px solid #fff;
  background: var(--cb-icon-bg);
  box-shadow: 0 0 0 5px var(--cb-border-soft);
}

.chatbot-hero-avatar .cb-avatar-fallback {
  width: 52px;
  height: 52px;
}

.cb-welcome__text {
  max-width: 330px;
  margin: 24px 0 0;
  font-size: 19px;
  font-weight: 500;
  line-height: 1.375;
  color: var(--cb-welcome-clr);
  overflow-wrap: break-word;
}

@media (min-width: 768px) {
  .cb-welcome__text {
    font-size: 21px;
  }
}

/* Quick replies */
.chatbot-quick-replies-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.cb-qr-line {
  flex: 1 1 0%;
  height: 1px;
  opacity: .5;
}

.cb-qr-line--left {
  background: linear-gradient(to right, transparent, var(--cb-border));
}

.cb-qr-line--right {
  background: linear-gradient(to left, transparent, var(--cb-border));
}

.cb-qr-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cb-accent-clr);
}

.cb-qr-title svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: #000;
  color: #000;
}

.chatbot-quick-replies {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  text-align: center;
}

#chatbotWidget .chatbot-quick-reply {
  width: 100%;
  margin-bottom: 4px;
  padding: 8px 20px;
  border: 1px solid rgba(var(--cb-pr-rgb), .35) !important;
  border-radius: 26px !important;
  background: transparent !important;
  color: var(--cb-dark) !important;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.375;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
}

#chatbotWidget .chatbot-quick-reply:hover {
  border-color: var(--cb-primary) !important;
  background-color: #FBF1EB;
  background-color: color-mix(in srgb, var(--cb-body-bg) 60%, var(--cb-primary) 10%) !important;
}

#chatbotWidget.is-maximized .chatbot-quick-reply {
  width: auto;
}

/* ==========================================================================
   Messages
   ========================================================================== */
.cb-msg {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 88%;
}

.cb-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cb-fade-in {
  animation: cbFadeInUp .25s ease-out forwards;
}

.cb-msg__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 4px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--cb-icon-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.cb-msg__avatar--user {
  width: 28px;
  height: 28px;
  padding: 0;
  background: linear-gradient(to bottom right, var(--cb-dark), var(--cb-secondary));
  box-shadow: none;
}

.cb-msg__avatar--user svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--cb-glow);
}

.chatbot-msg__bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.625;
  overflow-wrap: break-word;
}

.chatbot-msg__bubble > p {
  margin: 0;
}

.chatbot-msg__bubble > p + p {
  margin-top: 8px;
}

.cb-bubble--bot {
  border: 1px solid var(--cb-border-soft);
  border-bottom-left-radius: 2px;
  background: #fff;
  color: var(--cb-text);
  box-shadow: 0 2px 6px rgba(var(--cb-dr-rgb), .04);
}

.cb-bubble--user {
  border: 0;
  border-bottom-right-radius: 2px;
  background: linear-gradient(to bottom right, var(--cb-primary), var(--cb-secondary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(var(--cb-pr-rgb), .2);
}

/* Error state – declared after .cb-bubble--bot so it wins */
.cb-bubble--error {
  border-color: #FECACA;
  background: #FEF2F2;
  color: #991B1B;
}

/* Links inside messages */
.chatbot-contact-link {
  color: var(--cb-primary);
  font-weight: 600;
  text-decoration: underline;
  transition: color .2s ease;
}

.chatbot-contact-link:hover {
  color: var(--cb-secondary);
}

/* Typing indicator */
.chatbot-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 12px 18px;
  border: 1px solid var(--cb-border-soft);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(var(--cb-dr-rgb), .04);
}

.chatbot-typing-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--cb-primary);
  animation: cbTypingBounce 1.4s ease-in-out infinite both;
}

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

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

/* Streaming cursor */
.chatbot-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  margin-left: 2px;
  border-radius: 1px;
  background-color: var(--cb-primary);
  vertical-align: -1px;
  animation: cbCursorBlink .75s infinite;
}

/* Route confirmation ("Take me there?") */
.chatbot-route-confirm {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  padding-left: 46px;
  animation: cbFadeInUp .25s ease-out forwards;
}

#chatbotWidget .cb-route-btn {
  padding: 8px 16px;
  border-radius: 9999px !important;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  cursor: pointer;
}

#chatbotWidget .cb-route-btn--yes {
  border: 0 !important;
  background: linear-gradient(to bottom right, var(--cb-primary), var(--cb-secondary)) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(var(--cb-pr-rgb), .2) !important;
  transition: transform .15s ease;
}

#chatbotWidget .cb-route-btn--yes:hover {
  transform: scale(1.05);
}

#chatbotWidget .cb-route-btn--no {
  border: 1px solid rgba(var(--cb-pr-rgb), .25) !important;
  background: #fff !important;
  color: var(--cb-primary) !important;
  transition: background-color .15s ease;
}

#chatbotWidget .cb-route-btn--no:hover {
  background-color: #F8EBE2;
  background-color: color-mix(in srgb, var(--cb-body-bg) 70%, var(--cb-primary) 10%) !important;
}

/* Link card shown when the redirect is declined */
.chatbot-route-link {
  display: flex;
  align-items: center;
  gap: 12px;
  align-self: flex-start;
  max-width: 80%;
  margin-left: 46px;
  padding: 12px 16px;
  border: 1px solid rgba(var(--cb-pr-rgb), .18);
  border-radius: 16px;
  background-color: #FBF1EB;
  background-color: color-mix(in srgb, var(--cb-body-bg) 60%, var(--cb-primary) 8%);
  color: var(--cb-primary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .15s ease;
  animation: cbFadeInUp .25s ease-out forwards;
}

.chatbot-route-link:hover {
  background-color: #F8EBE2;
  background-color: color-mix(in srgb, var(--cb-body-bg) 40%, var(--cb-primary) 15%);
}

.cb-route-link__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.cb-route-link__sub {
  font-size: 12px;
  font-weight: 400;
  opacity: .7;
}

.cb-route-link__arrow {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
}

/* ==========================================================================
   Input form
   ========================================================================== */
.cb-form {
  flex-shrink: 0;
  margin: 0;
  padding: 8px 16px 16px;
  background-color: var(--cb-body-bg);
}

.cb-form__box {
  display: flex;
  flex-direction: column;
  padding: 16px 20px 12px;
  border: 2px solid var(--cb-border);
  border-radius: 24px;
  background-color: var(--cb-body-bg);
  transition: all .2s ease;
}

.cb-form__box:focus-within {
  border-color: var(--cb-primary);
  box-shadow: 0 0 0 3px rgba(var(--cb-pr-rgb), .1);
}

#chatbotWidget .cb-form .cb-form__input {
  width: 100%;
  min-width: 0;
  padding: 0 0 20px;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: var(--cb-text);
  font-size: 16px;
}

#chatbotWidget .cb-form .cb-form__input::placeholder {
  color: var(--cb-accent-clr);
  opacity: .7;
}

.cb-form__row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

#chatbotWidget .cb-send {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0 !important;
  border-radius: 50% !important;
  background: linear-gradient(to bottom right, var(--cb-primary), var(--cb-secondary)) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(var(--cb-pr-rgb), .25) !important;
  cursor: pointer;
  transition: all .2s ease;
}

#chatbotWidget .cb-send:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(var(--cb-pr-rgb), .35) !important;
}

#chatbotWidget .cb-send:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

#chatbotWidget .cb-send svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #fff;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes cbPing {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes cbFadeInUp {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cbTypingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: .35;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

@keyframes cbCursorBlink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes cbStatusPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: .35;
    transform: scale(.85);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cb-widget *,
  .cb-widget *::before,
  .cb-widget *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Keep focus/active identical to the resting look (theme :focus fills would otherwise show) */
#chatbotWidget .cb-icon-btn:focus,
#chatbotWidget .cb-icon-btn:active {
  background-color: transparent;
  color: rgba(255, 255, 255, .9);
}

#chatbotWidget .cb-icon-btn:hover:focus,
#chatbotWidget .cb-icon-btn:hover:active {
  background-color: rgba(255, 255, 255, .15) !important;
}

#chatbotWidget .cb-toggle:focus,
#chatbotWidget .cb-toggle:active {
  background: transparent !important;
}

#chatbotWidget .chatbot-quick-reply:focus,
#chatbotWidget .chatbot-quick-reply:active {
  color: var(--cb-dark) !important;
}

#chatbotWidget .cb-send:focus,
#chatbotWidget .cb-send:active {
  color: #fff !important;
  background: linear-gradient(to bottom right, var(--cb-primary), var(--cb-secondary)) !important;
}

#chatbotWidget .cb-route-btn--yes:focus,
#chatbotWidget .cb-route-btn--yes:active {
  color: #fff !important;
  background: linear-gradient(to bottom right, var(--cb-primary), var(--cb-secondary)) !important;
}

#chatbotWidget .cb-route-btn--no:focus,
#chatbotWidget .cb-route-btn--no:active {
  color: var(--cb-primary) !important;
}
