/* Global design variables used across the chatbot UI */
:root {
  --macaw-dark: #111827;
  --macaw-blue: #006eb8;
  --macaw-yellow: #ffd84d;
  --macaw-bg: #f7f4ec;
  --macaw-muted: #6b7280;
  --bubble-bg: #ffffff;
  --bubble-border: rgba(17, 24, 39, 0.08);
  --font-main: "Assistant", Arial, Helvetica, sans-serif;
}

/* Ensures predictable sizing for all elements */
* {
  box-sizing: border-box;
}

/* Base page setup */
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-main);
  background: transparent;
}

/* Main chat popup container */
/* Hidden by default and opened by adding the .is-open class */
.chat-popup {
  position: fixed;
  right: 28px;
  bottom: 108px;
  width: min(430px, calc(100vw - 56px));
  height: min(650px, calc(100vh - 138px));
  min-height: 420px;
  border-radius: 24px;
  overflow: hidden;
  background: #ffffff;
  box-shadow:
    0 28px 90px rgba(17, 24, 39, 0.28),
    0 0 0 1px rgba(17, 24, 39, 0.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1001;
}

/* Visible state of the chat popup */
.chat-popup.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header area of the chat popup */
.chat-header {
  height: 64px;
  padding: 0 16px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--macaw-dark);
  color: #ffffff;
  font-family: var(--font-main);
}

/* Container for avatar, title and subtitle */
.chat-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Circular avatar container */
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--macaw-yellow);
  flex: 0 0 auto;
}

/* Avatar image scaling */
.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Text container in the chat header */
.chat-title-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  font-family: var(--font-main);
}

/* Main chatbot title */
.chat-title-text strong {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  font-family: var(--font-main);
}

/* Chat status subtitle */
.chat-title-text span {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.75;
  white-space: nowrap;
  font-family: var(--font-main);
}

/* Header action area, for example reload button */
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Circular icon button in the header */
.chat-icon-button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.2s ease;
  font-family: var(--font-main);
}

/* Hover state for header icon buttons */
.chat-icon-button:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.04);
}

/* Icon sizing inside header buttons */
.chat-icon-button svg {
  width: 20px;
  height: 20px;
}

/* Body area below the header */
/* Contains the Web Chat render target and loading/error overlays */
.chat-body {
  position: relative;
  width: 100%;
  height: calc(100% - 64px);
  background: var(--macaw-bg);
  font-family: var(--font-main);
}

/* Microsoft Bot Framework Web Chat container */
#webchat {
  width: 100%;
  height: 100%;
  background: var(--macaw-bg);
  font-family: var(--font-main);
  font-weight: 400;
}

/* Force the custom font inside Web Chat generated elements */
#webchat,
#webchat * {
  font-family: var(--font-main) !important;
}

/* Force the custom font in important Web Chat areas */
#webchat .webchat__bubble__content,
#webchat .webchat__send-box,
#webchat .webchat__send-box *,
#webchat .webchat__suggested-actions,
#webchat .webchat__suggested-actions * {
  font-family: var(--font-main) !important;
}

/* Default font weight for bot and user message bubbles */
#webchat .webchat__bubble__content {
  font-weight: 400 !important;
}

/* Bold text inside Web Chat messages */
#webchat strong,
#webchat b {
  font-weight: 700 !important;
}

/* Standard-Fokusrahmen entfernen */
/* Removes default focus outlines and box shadows inside Web Chat */
#webchat *:focus,
#webchat *:focus-visible,
#webchat *:focus-within,
#webchat *:active {
  outline: none !important;
  box-shadow: none !important;
}

/* Große Rahmen um Activities entfernen */
/* Removes large focus frames from Web Chat activity wrapper elements */
#webchat .webchat__basic-transcript__activity,
#webchat .webchat__basic-transcript__activity:focus,
#webchat .webchat__basic-transcript__activity:focus-visible,
#webchat .webchat__basic-transcript__activity:focus-within,
#webchat .webchat__basic-transcript__activity:active,
#webchat .webchat__basic-transcript__activity-body,
#webchat .webchat__basic-transcript__activity-body:focus,
#webchat .webchat__basic-transcript__activity-body:focus-visible,
#webchat .webchat__basic-transcript__activity-body:focus-within,
#webchat .webchat__basic-transcript__activity-body:active,
#webchat .webchat__stacked-layout,
#webchat .webchat__stacked-layout:focus,
#webchat .webchat__stacked-layout:focus-visible,
#webchat .webchat__stacked-layout:focus-within,
#webchat .webchat__stacked-layout:active,
#webchat [role="listitem"],
#webchat [role="listitem"]:focus,
#webchat [role="listitem"]:focus-visible,
#webchat [role="listitem"]:focus-within,
#webchat [role="listitem"]:active,
#webchat [role="group"],
#webchat [role="group"]:focus,
#webchat [role="group"]:focus-visible,
#webchat [role="group"]:focus-within,
#webchat [role="group"]:active {
  outline: none !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

/* Suggested-Action-Zeile darf keinen großen Rahmen bekommen */
/* Prevents the whole suggested-action row from receiving a large focus frame */
#webchat .webchat__basic-transcript__activity:has(.webchat__suggested-actions),
#webchat .webchat__basic-transcript__activity:has(button),
#webchat .webchat__basic-transcript__activity-body:has(.webchat__suggested-actions),
#webchat .webchat__basic-transcript__activity-body:has(button),
#webchat .webchat__stacked-layout:has(.webchat__suggested-actions),
#webchat .webchat__stacked-layout:has(button),
#webchat [role="listitem"]:has(.webchat__suggested-actions),
#webchat [role="listitem"]:has(button),
#webchat [role="group"]:has(.webchat__suggested-actions),
#webchat [role="group"]:has(button) {
  outline: none !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

/* Suggested Actions selbst */
/* Removes focus styling from suggested-action containers */
#webchat .webchat__suggested-actions,
#webchat .webchat__suggested-actions:focus,
#webchat .webchat__suggested-actions:focus-visible,
#webchat .webchat__suggested-actions:focus-within,
#webchat .webchat__suggested-actions:active,
#webchat .webchat__suggested-action,
#webchat .webchat__suggested-action:focus,
#webchat .webchat__suggested-action:focus-visible,
#webchat .webchat__suggested-action:focus-within,
#webchat .webchat__suggested-action:active {
  outline: none !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

/* Button bleibt sauber klickbar */
/* Removes unwanted borders and shadows from suggested-action buttons */
#webchat .webchat__suggested-actions button,
#webchat .webchat__suggested-actions [role="button"],
#webchat .webchat__suggested-action button,
#webchat .webchat__suggested-action [role="button"] {
  outline: none !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

/* Optional: nur ein kleiner Fokus direkt um den Button, nicht um die ganze Zeile */
/* Keeps a small accessible focus indicator directly on the button */
#webchat .webchat__suggested-actions button:focus-visible,
#webchat .webchat__suggested-actions [role="button"]:focus-visible,
#webchat .webchat__suggested-action button:focus-visible,
#webchat .webchat__suggested-action [role="button"]:focus-visible {
  outline: 2px solid rgba(17, 24, 39, 0.18) !important;
  outline-offset: 3px !important;
  box-shadow: none !important;
}

/* Web-Chat-Fokusindikatoren ausblenden */
/* Hides internal Web Chat focus and keyboard indicators */
#webchat .webchat__basic-transcript__activity-indicator,
#webchat [class*="activity-indicator"],
#webchat [class*="activityIndicator"],
#webchat [class*="ActivityIndicator"],
#webchat [class*="keyboard-focus"],
#webchat [class*="KeyboardFocus"],
#webchat [class*="focus-indicator"],
#webchat [class*="FocusIndicator"] {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Typing-Bubble: drei bewegte Punkte */
/* Custom styling for the typing indicator bubble */
#webchat .webchat__typing-indicator,
#webchat [class*="typing-indicator"],
#webchat [class*="typingIndicator"] {
  width: 76px !important;
  height: 32px !important;
  min-width: 76px !important;
  min-height: 32px !important;
  padding: 0 !important;
  background: #ffffff !important;
  border: 1px solid rgba(17, 24, 39, 0.08) !important;
  border-radius: 18px !important;
  box-shadow: none !important;
  position: relative !important;
  overflow: hidden !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Hides the default typing indicator content */
#webchat .webchat__typing-indicator *,
#webchat [class*="typing-indicator"] *,
#webchat [class*="typingIndicator"] * {
  display: none !important;
}

/* First animated typing dot */
#webchat .webchat__typing-indicator::before,
#webchat [class*="typing-indicator"]::before,
#webchat [class*="typingIndicator"]::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.28);
  transform: translateY(-50%);
  animation: macawTypingDotOne 1.2s infinite ease-in-out;
}

/* Second animated typing dot */
#webchat .webchat__typing-indicator::after,
#webchat [class*="typing-indicator"]::after,
#webchat [class*="typingIndicator"]::after {
  content: "";
  position: absolute;
  left: 36px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.28);
  transform: translateY(-50%);
  animation: macawTypingDotTwo 1.2s infinite ease-in-out;
}

/* Third animated typing dot using a radial-gradient background */
#webchat .webchat__typing-indicator {
  background:
    radial-gradient(circle, rgba(17, 24, 39, 0.28) 0 3.5px, transparent 4px) 48px 50% / 7px 7px no-repeat,
    #ffffff !important;
  animation: macawTypingDotThree 1.2s infinite ease-in-out !important;
}

/* Animation for the first typing dot */
@keyframes macawTypingDotOne {
  0%, 80%, 100% {
    opacity: 0.28;
    transform: translateY(-50%) scale(0.85);
  }

  30% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

/* Animation for the second typing dot */
@keyframes macawTypingDotTwo {
  0%, 20%, 100% {
    opacity: 0.28;
    transform: translateY(-50%) scale(0.85);
  }

  50% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

/* Animation for the third typing dot */
@keyframes macawTypingDotThree {
  0%, 40%, 100% {
    background:
      radial-gradient(circle, rgba(17, 24, 39, 0.28) 0 3.5px, transparent 4px) 48px 50% / 7px 7px no-repeat,
      #ffffff;
  }

  70% {
    background:
      radial-gradient(circle, rgba(17, 24, 39, 0.85) 0 3.5px, transparent 4px) 48px 50% / 7px 7px no-repeat,
      #ffffff;
  }
}

/* Loading and error overlays */
/* These appear above the Web Chat container */
.chat-loading,
.chat-error {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--macaw-bg);
  z-index: 5;
  font-family: var(--font-main);
}

/* Visible state for loading and error overlays */
.chat-loading.is-visible,
.chat-error.is-visible {
  display: flex;
}

/* Inner message card for loading and error states */
.message-box {
  max-width: 300px;
  padding: 22px;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.12);
  font-family: var(--font-main);
}

/* Title inside loading/error message box */
.message-box strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--macaw-dark);
  font-family: var(--font-main);
}

/* Description text inside loading/error message box */
.message-box p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--macaw-muted);
  font-family: var(--font-main);
}

/* Floating launcher button in the bottom-right corner */
.chat-launcher {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 68px;
  height: 68px;
  border: none;
  border-radius: 50%;
  background: var(--macaw-dark);
  color: #ffffff;
  cursor: pointer;
  box-shadow:
    0 20px 46px rgba(17, 24, 39, 0.28),
    0 0 0 6px rgba(255, 216, 77, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  font-family: var(--font-main);
}

/* Launcher hover animation */
.chat-launcher:hover {
  transform: translateY(-3px) scale(1.03);
}

/* Launcher icon size */
.chat-launcher svg {
  width: 32px;
  height: 32px;
}

/* Launcher appearance when the chat is open */
body.chat-open .chat-launcher {
  background: var(--macaw-dark);
  box-shadow:
    0 20px 46px rgba(17, 24, 39, 0.28),
    0 0 0 6px rgba(255, 216, 77, 0.52);
}

/* Hides citation and reference elements rendered by Web Chat */
/* This is a frontend fallback in addition to the cleanup logic in script.js */
#webchat .webchat__citation,
#webchat .webchat__citations,
#webchat .webchat__footnote,
#webchat .webchat__footnotes,
#webchat .webchat__link-definitions,
#webchat [class*="citation"],
#webchat [class*="Citation"],
#webchat [class*="reference"],
#webchat [class*="Reference"],
#webchat [aria-label*="citation"],
#webchat [aria-label*="Citation"],
#webchat [aria-label*="reference"],
#webchat [aria-label*="Reference"] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
}

/* Mobile layout adjustments */
@media (max-width: 520px) {
  /* Chat popup becomes full width and moves to the bottom on small screens */
  .chat-popup {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 82vh;
    min-height: 0;
    border-radius: 24px 24px 0 0;
  }

  /* Slightly smaller launcher on mobile */
  .chat-launcher {
    right: 18px;
    bottom: 18px;
    width: 62px;
    height: 62px;
  }
}