/* AI assistant floating button + resizable popup (logged-in users only) */

#ai-assistant-button {
  position: fixed;
  right: 20px;
  bottom: 70px;
  z-index: 9997;
  width: auto;
  min-height: 40px;
  padding: 6px 18px 6px 14px;
  border: none;
  border-radius: 30px;
  background: #f67819;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0px 1px 3px 2px rgb(0 0 0 / 35%);
  transition: transform 0.2s ease;
}

#ai-assistant-button:hover,
#ai-assistant-button:focus-visible {
  transform: scale(1.05);
}

#ai-assistant-button svg {
  display: block;
  flex: 0 0 auto;
  pointer-events: none;
}

.ai-assistant-button__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  white-space: nowrap;
  pointer-events: none;
}

.ai-assistant-button__caption {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.9;
}

/* Hint bubble above the button: not modal, nothing behind it is blocked. */
#ai-assistant-tip {
  position: fixed;
  right: 20px;
  bottom: 124px;
  z-index: 9998;
  width: 280px;
  max-width: calc(100vw - 32px);
  padding: 12px 34px 12px 14px;
  border-radius: 12px;
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 4px 16px rgb(0 0 0 / 25%);
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#ai-assistant-tip.show {
  opacity: 1;
  transform: none;
}

/* Tail pointing down at the button. */
#ai-assistant-tip::after {
  content: "";
  position: absolute;
  right: 34px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 4px rgb(0 0 0 / 10%);
}

#ai-assistant-tip-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

#ai-assistant-tip-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ai-assistant-tip-close:hover,
#ai-assistant-tip-close:focus-visible {
  background: #f0f0f0;
  color: #1a1a1a;
}

#ai-assistant-popup {
  position: fixed;
  right: 20px;
  bottom: 120px;
  z-index: 10000;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: 620px;
  max-height: calc(100vh - 160px);
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  visibility: hidden;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

#ai-assistant-popup.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

#ai-assistant-popup.resizing {
  transition: none;
  user-select: none;
}

#ai-assistant-popup.resizing #ai-assistant-frame {
  pointer-events: none;
}

/* Slim strip in the chat header's colour: it reads as one header with the
   embedded chat page, which brings its own title bar. */
#ai-assistant-popup__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: #f67819;
  color: #fff;
  flex: 0 0 auto;
}

#ai-assistant-resize {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: nwse-resize;
  opacity: 0.75;
  touch-action: none;
}

#ai-assistant-resize:hover {
  opacity: 1;
}

#ai-assistant-close {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

#ai-assistant-close:hover,
#ai-assistant-close:focus-visible {
  background: rgba(255, 255, 255, 0.35);
}

#ai-assistant-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  display: block;
}

@media (max-width: 640px) {
  #ai-assistant-popup {
    right: 10px;
    left: 10px;
    bottom: 125px;
    top: 60px;
    width: auto !important;
    max-width: none;
    height: auto !important;
    max-height: none;
  }

  #ai-assistant-resize {
    display: none;
  }

  /* Caption hidden on phones to keep the floating button small. */
  .ai-assistant-button__caption {
    display: none;
  }

  #ai-assistant-tip {
    right: 16px;
    bottom: 120px;
  }
}

/* In-content call to action (#9100), e.g. at the end of articles after the tags.
   The button opens the popup and sends its question (ai-assistant.js). */
.b-askai-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 32px 0;
  padding: 16px 20px;
  border-left: 4px solid #f67819;
  border-radius: 8px;
  background: #fff3ea;
}

.b-askai-cta__text {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.b-askai-cta__button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 24px;
  background: #f67819;
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.b-askai-cta__button:hover,
.b-askai-cta__button:focus-visible {
  background: #bd3500;
}

.b-askai-cta__button svg {
  flex: 0 0 auto;
}
