/**
 * Branded launcher for the minimized chatbot.
 *
 * The contrib ai_chatbot "collapsed minimal" state leaves the chat window's
 * top edge visible plus a bare toggle icon; these overrides hide the window
 * entirely and float the navigator pointer icon alone in the corner. Selectors
 * are scoped to .chat-collapsed-minimal so the expanded widget keeps its
 * stock look.
 */

/* Expanded panel: contrib rounds only the top corners
   (.chat-container { border-radius: 8px 8px 0 0 }) and draws a #ccc border line
   across the top/sides of the header (.ai-deepchat--header { border: 1px solid
   #ccc; border-bottom: none }). Round all four corners to 8px so the panel
   matches the .brn-search card (navigator-search.css), and drop the header
   border line. Scoped with :not(.chat-collapsed-minimal) so these never touch
   the 56px circular launcher, and higher specificity than contrib's single-class
   selectors so the overrides win without !important (both stylesheets are in the
   "theme" CSS group). */
.chat-container:not(.chat-collapsed-minimal) {
  border-radius: 8px;
}

/* The body wrapper paints the bottom of the panel, and on desktop the resizable
   container is overflow:visible (so the resize handle can sit outside it), which
   would otherwise leave square bottom corners. Round + clip the body so the
   deep-chat content follows the panel's rounded bottom. */
.chat-container:not(.chat-collapsed-minimal) .chat-element {
  overflow: hidden;
  border-radius: 0 0 8px 8px;
}

/* Remove the grey/white header border line; keep the rounded top corners. */
.chat-container:not(.chat-collapsed-minimal) .ai-deepchat--header {
  border: 0;
}

/* Mobile: contrib intentionally squares the full-bleed panel
   (@media max-width:768px { border-radius: 0 }). Preserve that. */
@media (max-width: 768px) {
  .chat-container:not(.chat-collapsed-minimal),
  .chat-container:not(.chat-collapsed-minimal) .chat-element {
    border-radius: 0;
  }
}

.chat-container.chat-collapsed-minimal {
  margin-bottom: 76px;
  /* The container clips overflow for the window's rounded corners; while
     minimized that would shear the glyph's halo at the top/right edges. */
  overflow: visible;
}

.chat-container.chat-collapsed-minimal .ai-deepchat--header {
  box-sizing: border-box;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  background-image: url('../assets/navigator-icon-blue.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  box-shadow: none;
  cursor: pointer;
  /* Keeps the blue pointer legible over dark page sections. */
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.95)) drop-shadow(0 0 1px rgba(255, 255, 255, 0.9));
}

.chat-container.chat-collapsed-minimal .toggle-icon {
  display: none;
}

/* Hover hint bubble: nudges visitors to open the assistant. The bubble (::after)
   floats beside the launcher glyph with a small pointer arrow (::before). Shown
   on hover and keyboard focus only. */
.chat-container.chat-collapsed-minimal .ai-deepchat--header::after {
  content: "Hi, I'm the Navigator Assistant! I'm here to help.";
  position: absolute;
  top: 50%;
  right: calc(100% + 14px);
  transform: translateY(-50%) scale(0.96);
  transform-origin: right center;
  width: max-content;
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 12px;
  background-color: #1f374c;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-container.chat-collapsed-minimal .ai-deepchat--header::before {
  content: "";
  position: absolute;
  top: 50%;
  right: calc(100% + 2px);
  transform: translateY(-50%);
  border: 8px solid transparent;
  border-left-color: #1f374c;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.chat-container.chat-collapsed-minimal .ai-deepchat--header:hover::after,
.chat-container.chat-collapsed-minimal .ai-deepchat--header:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.chat-container.chat-collapsed-minimal .ai-deepchat--header:hover::before,
.chat-container.chat-collapsed-minimal .ai-deepchat--header:focus-visible::before {
  opacity: 1;
}

/* JS adds brn-launcher-hint-auto on page load to flash the bubble briefly,
   then removes it. Reuses the same bubble/arrow styling as the hover state,
   but slides the bubble in and pulses the glyph twice to catch the eye. */
.chat-container.chat-collapsed-minimal.brn-launcher-hint-auto .ai-deepchat--header::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
  animation: brn-hint-slide-in 0.35s ease-out;
}

.chat-container.chat-collapsed-minimal.brn-launcher-hint-auto .ai-deepchat--header::before {
  opacity: 1;
}

.chat-container.chat-collapsed-minimal.brn-launcher-hint-auto .ai-deepchat--header {
  animation: brn-hint-glyph-pulse 0.9s ease-out 2;
}

@keyframes brn-hint-slide-in {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(8px) scale(0.98);
  }

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

@keyframes brn-hint-glyph-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 55, 76, 0.45);
  }

  70% {
    box-shadow: 0 0 0 12px rgba(31, 55, 76, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(31, 55, 76, 0);
  }
}

/* Mirror the bubble to the right of the glyph when docked bottom-left. */
.chat-container.chat-collapsed-minimal.bottom-left .ai-deepchat--header::after {
  right: auto;
  left: calc(100% + 14px);
  transform-origin: left center;
}

.chat-container.chat-collapsed-minimal.bottom-left .ai-deepchat--header::before {
  right: auto;
  left: calc(100% + 2px);
  border-left-color: transparent;
  border-right-color: #1f374c;
}

/* Bottom-left sits to the right of the glyph, so slide in from the left. */
.chat-container.chat-collapsed-minimal.bottom-left.brn-launcher-hint-auto .ai-deepchat--header::after {
  animation-name: brn-hint-slide-in-left;
}

@keyframes brn-hint-slide-in-left {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(-8px) scale(0.98);
  }

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

/* The contrib stylesheet outlines the header on any focus, which leaves a
   white box around the glyph after every mouse click. Keep an indicator
   for keyboard focus only. */
.chat-container.chat-collapsed-minimal .ai-deepchat--header:focus {
  outline: none;
}

.chat-container.chat-collapsed-minimal .ai-deepchat--header:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

/* Hide the chat window itself when minimized. The deep-chat element needs
   !important because the component re-enables visibility inline once it
   finishes loading. */
.chat-container.chat-collapsed-minimal .chat-element,
.chat-container.chat-collapsed-minimal .chat-element deep-chat {
  visibility: hidden !important;
}

.chat-container.brn-chatbot-resizing {
  transition: none;
  user-select: none;
}

.chat-container.brn-chatbot-resizable .chat-element {
  min-width: 0 !important;
  position: relative;
}

.brn-chatbot-idle-nudge[hidden] {
  display: none;
}

.brn-chatbot-idle-nudge {
  position: absolute;
  z-index: 5;
  right: 14px;
  bottom: 76px;
  left: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  box-sizing: border-box;
  max-width: calc(100% - 28px);
  padding: 10px 10px 10px 12px;
  border: 1px solid rgba(0, 86, 179, 0.2);
  border-radius: 8px;
  background: #f4f9ff;
  color: #1f374c;
  box-shadow: 0 8px 20px rgba(31, 55, 76, 0.16);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.brn-chatbot-idle-nudge-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.brn-chatbot-idle-nudge-message {
  flex: 1 1 auto;
  min-width: 0;
}

.brn-chatbot-idle-nudge-dismiss {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(31, 55, 76, 0.08);
  color: #1f374c;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

.brn-chatbot-idle-nudge-dismiss:hover,
.brn-chatbot-idle-nudge-dismiss:focus-visible {
  background: #1f374c;
  color: #fff;
}

.brn-chatbot-resize-handle {
  position: absolute;
  z-index: 4;
  top: -8px;
  left: -8px;
  width: 22px;
  height: 22px;
  padding: 0;
  cursor: nwse-resize;
  touch-action: none;
  border: 0;
  background: transparent;
}

.brn-chatbot-resize-handle::before {
  position: absolute;
  inset: 5px;
  content: "";
  opacity: 0.85;
  border-top: 2px solid rgba(31, 55, 76, 0.8);
  border-left: 2px solid rgba(31, 55, 76, 0.8);
  border-radius: 3px 0 0;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.9));
}

.brn-chatbot-resize-handle:focus-visible::before,
.brn-chatbot-resize-handle:hover::before {
  opacity: 1;
  border-color: #0056b3;
}

.chat-container.bottom-left .brn-chatbot-resize-handle {
  right: -8px;
  left: auto;
  cursor: nesw-resize;
}

.chat-container.bottom-left .brn-chatbot-resize-handle::before {
  border-right: 2px solid rgba(31, 55, 76, 0.8);
  border-left: 0;
  border-radius: 0 3px 0 0;
}

.chat-container.bottom-left .brn-chatbot-resize-handle:focus-visible::before,
.chat-container.bottom-left .brn-chatbot-resize-handle:hover::before {
  border-right-color: #0056b3;
}

.chat-container.chat-collapsed .brn-chatbot-resize-handle,
.chat-container.chat-collapsed-minimal .brn-chatbot-resize-handle {
  display: none;
}

@media (max-width: 768px) {
  .brn-chatbot-resize-handle {
    display: none;
  }

  .brn-chatbot-idle-nudge {
    right: 10px;
    bottom: 82px;
    left: 10px;
    max-width: calc(100% - 20px);
    font-size: 12px;
  }
}

@media (min-width: 769px) {
  .chat-container.brn-chatbot-resizable {
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brn-chatbot-idle-nudge {
    transition: none;
  }
}
