/**
 * @file
 * Conseiller virtuel UCM ("Hugo"): floating launcher + Web Chat panel.
 *
 * Ported from the integration snippet provided by UCM. Two deliberate changes:
 * - the custom properties are scoped to the widget instead of :root, so they
 *   cannot collide with anything else on the page;
 * - the font stack reuses the self-hosted "roboto" of ucm_theme instead of
 *   pulling Roboto from Google Fonts (same rendering, no third-party request).
 */

#ucm-launcher,
#ucm-widget {
  --ucm-chat-blue: #143cc8;
  --ucm-chat-blue-dark: #0f2e9a;
  --ucm-chat-font: roboto, Roboto, Arial, sans-serif;
}

/* Launcher (floating bubble). */
#ucm-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--ucm-chat-blue);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  z-index: 2147483000;
}

#ucm-launcher:hover {
  background: var(--ucm-chat-blue-dark);
  transform: scale(1.05);
}

#ucm-launcher svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

/* Panel. */
#ucm-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: none; /* .open switches it to flex. */
  flex-direction: column;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 48px);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  z-index: 2147483000;
}

#ucm-widget.open {
  display: flex;
}

/* Header: UCM blue band. */
#ucm-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--ucm-chat-blue);
  color: #fff;
  font-family: var(--ucm-chat-font);
  font-size: 15px;
  font-weight: 700;
}

#ucm-header .ucm-title {
  flex: 1;
}

#ucm-header button {
  display: flex;
  align-items: center;
  padding: 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.85;
}

#ucm-header button:hover {
  background: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

#ucm-header svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* Web Chat canvas. */
#ucm-webchat {
  flex: 1 1 auto;
  min-height: 0;
}

/* Link colour inside bot answers is not exposed by styleOptions, hence the
   override here (otherwise Web Chat renders its default lilac). */
#ucm-webchat .webchat__render-markdown a {
  color: var(--ucm-chat-blue) !important;
}

#ucm-webchat .ucm-webchat-error {
  margin: 0;
  padding: 16px;
  color: #b00020;
  font-family: var(--ucm-chat-font);
  font-size: 14px;
}

/* Full screen on mobile. */
@media (max-width: 480px) {
  #ucm-widget {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}
