.cimr-chatbot-root {
  --cimr-chat-primary: #1c7bc4;
  --cimr-chat-primary-dark: #145a91;
  --cimr-chat-bg: #ffffff;
  --cimr-chat-text: #1a2733;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cimr-chatbot-bubble {
  position: fixed;
  left: 1.25rem;
  right: auto;
  bottom: 1.25rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--cimr-chat-primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  font-size: 1.5rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.cimr-chatbot-bubble.is-dragging {
  cursor: grabbing;
  transition: none;
  transform: scale(1.08);
}

.cimr-chatbot-bubble:hover,
.cimr-chatbot-bubble:focus {
  background: var(--cimr-chat-primary-dark);
  transform: scale(1.05);
}

.cimr-chatbot-panel {
  box-sizing: border-box;
  position: fixed;
  left: 1.25rem;
  right: auto;
  bottom: 5.25rem;
  top: auto;
  width: 22.5rem;
  max-width: calc(100vw - 2rem);
  height: 32rem;
  max-height: calc(100vh - 8rem);
  background: var(--cimr-chat-bg);
  border-radius: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  color: var(--cimr-chat-text);
  transform: none;
  transition: width 0.25s ease, height 0.25s ease, right 0.25s ease,
    bottom 0.25s ease, top 0.25s ease, left 0.25s ease, border-radius 0.25s ease,
    max-width 0.25s ease, max-height 0.25s ease;
}

.cimr-chatbot-panel * {
  box-sizing: border-box;
}

/*
 * Maximized state: centered at exactly half the viewport width/height.
 * Uses the standard left/top 50% + translate(-50%, -50%) centering idiom
 * (rather than right/bottom + translate) so there is only one pair of
 * offset properties driving position — easier to reason about and avoids
 * any ambiguity with the default state's right/bottom values, which are
 * explicitly cancelled here. width/height are capped below viewport size
 * via max-width/max-height so the panel can never be clipped by an edge.
 */
.cimr-chatbot-panel--maximized {
  right: auto;
  bottom: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 50vw;
  height: 70vh;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  min-width: 20rem;
  min-height: 24rem;
}

@media (max-width: 48rem) {
  .cimr-chatbot-panel--maximized {
    width: calc(100vw - 1rem);
    height: calc(100vh - 1rem);
    max-width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
    min-width: 0;
    min-height: 0;
  }
}

.cimr-chatbot-header {
  /*
   * Defensive reset: this element intentionally is NOT a <header> tag (see
   * chatbot.js) because the site theme applies `header { position: static
   * initially, then position:fixed!important via .sticky; left:0; top:0;
   * width:100% }` to every <header> on the page via a scroll listener. Even
   * so, pin these properties explicitly so this title bar can never be
   * pulled out of the panel's normal flow by an unrelated global rule.
   */
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  width: auto;
  z-index: auto;
  flex: 0 0 auto;
  background: var(--cimr-chat-primary);
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cimr-chatbot-title {
  font-weight: 600;
  font-size: 1rem;
  margin-right: auto;
}

.cimr-chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.cimr-chatbot-lang-switch {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 1rem;
  padding: 0.125rem;
  margin-right: 0.25rem;
}

.cimr-chatbot-lang-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.75rem;
  opacity: 0.75;
}

.cimr-chatbot-lang-btn:hover,
.cimr-chatbot-lang-btn:focus {
  opacity: 1;
}

.cimr-chatbot-lang-btn.is-active {
  background: #fff;
  color: var(--cimr-chat-primary);
  opacity: 1;
}

.cimr-chatbot-close,
.cimr-chatbot-maximize {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.125rem 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cimr-chatbot-maximize {
  font-size: 1rem;
}

.cimr-chatbot-maximize svg {
  width: 1rem;
  height: 1rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.cimr-chatbot-close:hover,
.cimr-chatbot-close:focus,
.cimr-chatbot-maximize:hover,
.cimr-chatbot-maximize:focus,
.cimr-chatbot-clear:hover,
.cimr-chatbot-clear:focus {
  opacity: 0.8;
}

.cimr-chatbot-clear-wrap {
  position: relative;
  display: inline-flex;
}

.cimr-chatbot-clear {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.125rem 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cimr-chatbot-clear svg {
  width: 1rem;
  height: 1rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.cimr-chatbot-confirm-popup {
  position: absolute;
  top: calc(100% + 0.625rem);
  right: 0;
  width: 12.5rem;
  background: #fff;
  color: var(--cimr-chat-text);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  padding: 0.75rem;
  z-index: 10;
}

.cimr-chatbot-confirm-popup::before {
  content: "";
  position: absolute;
  top: -0.3125rem;
  right: 0.75rem;
  width: 0.625rem;
  height: 0.625rem;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 0.1rem;
}

.cimr-chatbot-confirm-text {
  margin: 0 0 0.625rem;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.cimr-chatbot-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.cimr-chatbot-confirm-cancel,
.cimr-chatbot-confirm-yes {
  border: none;
  border-radius: 1rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
}

.cimr-chatbot-confirm-cancel {
  background: #eef1f3;
  color: var(--cimr-chat-text);
}

.cimr-chatbot-confirm-cancel:hover,
.cimr-chatbot-confirm-cancel:focus {
  background: #e0e5e8;
}

.cimr-chatbot-confirm-yes {
  background: #d64545;
  color: #fff;
}

.cimr-chatbot-confirm-yes:hover,
.cimr-chatbot-confirm-yes:focus {
  background: #b83838;
}

.cimr-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #f4f7f9;
}

.cimr-chatbot-message {
  display: flex;
}

.cimr-chatbot-message--user {
  justify-content: flex-end;
}

.cimr-chatbot-message--bot {
  justify-content: flex-start;
}

.cimr-chatbot-message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 85%;
}

.cimr-chatbot-bubble-text {
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.cimr-chatbot-message--user .cimr-chatbot-bubble-text {
  background: var(--cimr-chat-primary);
  color: #fff;
  border-bottom-right-radius: 0.125rem;
}

.cimr-chatbot-message--bot .cimr-chatbot-bubble-text {
  background: #fff;
  border: 1px solid #e0e6ea;
  border-bottom-left-radius: 0.125rem;
}

.cimr-chatbot-bubble-text p {
  margin: 0 0 0.5rem;
}

.cimr-chatbot-bubble-text p:last-child {
  margin-bottom: 0;
}

.cimr-chatbot-bubble-text ul.cimr-chatbot-list {
  margin: 0 0 0.5rem;
  padding-left: 1.1rem;
}

.cimr-chatbot-bubble-text h4.cimr-chatbot-heading {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
}

.cimr-chatbot-source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cimr-chat-primary);
  text-decoration: none;
  background: #eef6fc;
  border: 1px solid var(--cimr-chat-primary);
  border-radius: 1rem;
  padding: 0.3rem 0.75rem;
  line-height: 1.2;
  transition: background 0.15s ease, color 0.15s ease;
}

.cimr-chatbot-source-link::after {
  content: "\2192";
}

.cimr-chatbot-source-link:hover,
.cimr-chatbot-source-link:focus {
  background: var(--cimr-chat-primary);
  color: #fff;
  text-decoration: none;
}

.cimr-chatbot-page-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.25rem 0 0.5rem;
  max-width: 85%;
}

.cimr-chatbot-page-result {
  background: #fff;
  border: 1px solid #dfe6ee;
  border-left: 3px solid var(--cimr-chat-primary);
  border-radius: 0.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.8125rem;
}

.cimr-chatbot-page-result-title {
  font-weight: 700;
  color: var(--cimr-chat-text);
  margin-bottom: 0.2rem;
}

.cimr-chatbot-page-result-snippet {
  color: #46545f;
  line-height: 1.4;
}

.cimr-chatbot-page-result-snippet p {
  margin: 0 0 0.4rem;
}

.cimr-chatbot-page-result-snippet strong {
  background: #fff3b0;
  color: #1a2733;
  font-weight: 700;
  padding: 0 0.1rem;
  border-radius: 0.15rem;
}

.cimr-chatbot-page-result-link {
  margin-top: 0.35rem;
}

.cimr-chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.25rem 0 0.5rem;
}

.cimr-chatbot-chip {
  background: #fff;
  border: 1px solid var(--cimr-chat-primary);
  color: var(--cimr-chat-primary);
  border-radius: 1rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.cimr-chatbot-chip:hover,
.cimr-chatbot-chip:focus {
  background: var(--cimr-chat-primary);
  color: #fff;
}

.cimr-chatbot-dot {
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  margin-right: 0.1875rem;
  border-radius: 50%;
  background: #9aa7b0;
  animation: cimr-chatbot-blink 1.2s infinite ease-in-out;
}

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

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

@keyframes cimr-chatbot-blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

.cimr-chatbot-form {
  display: flex;
  border-top: 1px solid #e0e6ea;
  padding: 0.5rem;
  gap: 0.5rem;
  background: #fff;
}

.cimr-chatbot-input {
  flex: 1;
  border: 1px solid #d3dce1;
  border-radius: 1.25rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
}

.cimr-chatbot-input:focus {
  outline: 2px solid var(--cimr-chat-primary);
  outline-offset: 1px;
}

.cimr-chatbot-send {
  background: var(--cimr-chat-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.cimr-chatbot-send:hover,
.cimr-chatbot-send:focus {
  background: var(--cimr-chat-primary-dark);
}

.cimr-chatbot-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/*
 * Site-wide "arrive and highlight" mark, applied by js/chatbot-highlight.js
 * when a page is opened with a ?cimrHighlight=... link from a chatbot
 * page-search result. Deliberately NOT scoped under .cimr-chatbot-root
 * since it targets content anywhere on the page, not inside the widget.
 */
mark.cimr-chatbot-highlight {
  background: #fff3b0;
  color: #1a2733;
  padding: 0.05em 0.15em;
  border-radius: 0.2em;
  box-shadow: 0 0 0 1px rgba(28, 123, 196, 0.35);
}

mark.cimr-chatbot-highlight-pulse {
  animation: cimr-chatbot-highlight-pulse 1.3s ease-in-out 0s 2;
}

@keyframes cimr-chatbot-highlight-pulse {
  0%, 100% { background: #fff3b0; }
  50% { background: #ffd93d; }
}

@media (max-width: 30rem) {
  .cimr-chatbot-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    bottom: 4.75rem;
  }

  .cimr-chatbot-bubble {
    left: 1rem;
    right: auto;
    bottom: 1rem;
  }

  /*
   * Maximized on a phone: fill the whole screen. This must come after the
   * plain mobile .cimr-chatbot-panel rule above, which otherwise wins
   * (same specificity, later in the file) and pushes the centered
   * maximized panel half off the left edge.
   */
  .cimr-chatbot-panel.cimr-chatbot-panel--maximized {
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-width: 0;
    min-height: 0;
    border-radius: 0;
    z-index: 100000;
  }
}
