/* PBMares brand (DEF-01): teal dominant, Dark Gray for supporting text and dividers, Accent Dark Blue for links
   and focus rings, Accent Orange once as a thin decorative rule, Light Tan only as a pale background. White text
   sits on teal (5.12:1) or dark blue (9.40:1) only: orange fails with white (2.80:1), so it never carries text.
   Fonts: Lato first, the font pbmares.com itself loads, so the widget matches the site; then the brand document's
   faces (Proxima Nova or Malgun Gothic for headings, Calibri for body) and common system fallbacks. The plugin loads
   no web fonts: the host page already loads Lato. */
.pbmares-chatbot-widget {
  --pbmares-teal: #00798a;
  --pbmares-dark-blue: #004c68;
  --pbmares-gray: #545859;
  --pbmares-orange: #dc8633;
  /* Light Tan #d9c89e at 25% on white: the bot's bubbles. */
  --pbmares-tan-tint: #f6f1e7;
  /* Dark Gray at 25% on white: dividers and disabled controls. */
  --pbmares-divider: #d4d5d6;
  /* The text field's outline: 3.48:1 on white, so the field is visible (WCAG 1.4.11). */
  --pbmares-field-border: #878a8b;
  --pbmares-font-heading:
    Lato, "Proxima Nova", "Malgun Gothic", "Segoe UI", Arial, sans-serif;
  --pbmares-font-body: Lato, Calibri, Carlito, "Segoe UI", Arial, sans-serif;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--pbmares-font-body);
  color: #000;
}

/* Form controls don't inherit the font by default; the host theme's own button rules are reset here too. */
.pbmares-chatbot-widget button,
.pbmares-chatbot-widget input {
  font-family: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.pbmares-chatbot-button {
  background: var(--pbmares-teal);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.pbmares-chatbot-button:hover {
  background: var(--pbmares-dark-blue);
}

/* A white ring then a dark blue one, so focus shows on light and dark pages alike. */
.pbmares-chatbot-button:focus-visible {
  outline: 3px solid var(--pbmares-dark-blue);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff;
}

.pbmares-chatbot-button__label {
  font-family: var(--pbmares-font-heading);
  font-size: 15px;
  font-weight: 700;
}

/* The "Online" line under the label went in 0.5.1 (UAT DEF-20); hidden here too for a page still on the 0.5.0 script. */
.pbmares-chatbot-button__status {
  display: none;
}

.pbmares-chatbot-panel {
  width: 320px;
  /* Fits a 320px-wide phone: 20px from each edge, like the launcher. */
  width: min(320px, calc(100vw - 40px));
  box-sizing: border-box;
  max-height: 70vh;
  background: #fff;
  border: 1px solid var(--pbmares-divider);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pbmares-chatbot-panel__header {
  background: var(--pbmares-teal);
  color: #fff;
  border-bottom: 3px solid var(--pbmares-orange);
  padding: 14px 16px;
  display: flex;
  /* Wraps: the title and the buttons on the first line, the subtitle on its own line under them (0.5.1). On the
     narrowest phones the buttons take a line of their own. */
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px 8px;
}

.pbmares-chatbot-panel__header > .pbmares-chatbot-panel__title {
  flex: 1 1 auto;
  align-self: center;
  min-width: 0;
}

/* The full width of the header (UAT DEF-44): two lines at phone width, never cut short. */
.pbmares-chatbot-panel__header > .pbmares-chatbot-panel__subtitle {
  flex: 1 1 100%;
}

.pbmares-chatbot-panel__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

/* The 0.5.0 script's wrapper around the title and subtitle. */
.pbmares-chatbot-panel__heading {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pbmares-chatbot-panel__title {
  font-family: var(--pbmares-font-heading);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.2;
}

.pbmares-chatbot-panel__subtitle {
  font-size: 13px;
  line-height: 1.3;
}

.pbmares-chatbot-panel__header .pbmares-chatbot-new-chat {
  flex-shrink: 0;
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
}

.pbmares-chatbot-panel__header .pbmares-chatbot-new-chat:hover {
  background: #fff;
  color: var(--pbmares-teal);
}

.pbmares-chatbot-panel__header .pbmares-chatbot-new-chat:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Download (UAT DEF-40) and the bigger window (UAT DEF-37): round icon buttons in New chat's style. */
.pbmares-chatbot-panel__header .pbmares-chatbot-header-button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 50%;
  cursor: pointer;
}

.pbmares-chatbot-panel__header .pbmares-chatbot-header-button:hover,
.pbmares-chatbot-panel__header .pbmares-chatbot-header-button[aria-pressed="true"] {
  background: #fff;
  color: var(--pbmares-teal);
}

.pbmares-chatbot-panel__header .pbmares-chatbot-header-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.pbmares-chatbot-panel__header .pbmares-chatbot-header-button svg {
  display: block;
  flex-shrink: 0;
}

.pbmares-chatbot-panel__body {
  padding: 0 16px 12px;
  color: #000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow: hidden;
}

.pbmares-chatbot-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 8px;
  overflow-y: auto;
}

.pbmares-chatbot-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 85%;
}

.pbmares-chatbot-message--user {
  align-self: flex-end;
  text-align: right;
}

.pbmares-chatbot-message--bot {
  align-self: flex-start;
}

.pbmares-chatbot-message__bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
}

.pbmares-chatbot-message--user .pbmares-chatbot-message__bubble {
  background: var(--pbmares-teal);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.pbmares-chatbot-message--bot .pbmares-chatbot-message__bubble {
  background: var(--pbmares-tan-tint);
  color: #000;
  border-bottom-left-radius: 4px;
}

.pbmares-chatbot-message__bubble a {
  color: var(--pbmares-dark-blue);
  text-decoration: underline;
}

/* The bot's light Markdown: paragraphs and lists inside a bubble. The widget renders inside the page, so the
   theme's own p/ul/li rules are reset here. */
.pbmares-chatbot-message__bubble .pbmares-chatbot-text,
.pbmares-chatbot-message__bubble .pbmares-chatbot-list,
.pbmares-chatbot-message__bubble .pbmares-chatbot-list li {
  font: inherit;
  line-height: inherit;
  color: inherit;
  text-align: left;
}

.pbmares-chatbot-message__bubble .pbmares-chatbot-text,
.pbmares-chatbot-message__bubble .pbmares-chatbot-list {
  margin: 0 0 8px;
}

.pbmares-chatbot-message__bubble ul.pbmares-chatbot-list {
  list-style: disc outside;
}

.pbmares-chatbot-message__bubble ol.pbmares-chatbot-list {
  list-style: decimal outside;
}

.pbmares-chatbot-message__bubble .pbmares-chatbot-list li::before,
.pbmares-chatbot-message__bubble .pbmares-chatbot-list li::after {
  content: none;
}

.pbmares-chatbot-message__bubble .pbmares-chatbot-list .pbmares-chatbot-list {
  margin: 2px 0 0;
}

.pbmares-chatbot-message__bubble .pbmares-chatbot-text:last-child,
.pbmares-chatbot-message__bubble .pbmares-chatbot-list:last-child {
  margin-bottom: 0;
}

.pbmares-chatbot-message__bubble .pbmares-chatbot-list {
  padding-left: 18px;
}

.pbmares-chatbot-message__bubble .pbmares-chatbot-list li {
  margin: 2px 0;
  padding: 0;
  display: list-item;
}

.pbmares-chatbot-message__bubble a:hover {
  text-decoration: none;
}

.pbmares-chatbot-message__bubble a:focus-visible {
  outline: 2px solid var(--pbmares-dark-blue);
  outline-offset: 1px;
}

.pbmares-chatbot-message--user .pbmares-chatbot-message__bubble a {
  color: #fff;
}

.pbmares-chatbot-message--user .pbmares-chatbot-message__bubble a:focus-visible {
  outline-color: #fff;
}

.pbmares-chatbot-message__meta {
  font-size: 11px;
  color: var(--pbmares-gray);
}

.pbmares-chatbot-message__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pbmares-chatbot-message__typing .dot {
  width: 6px;
  height: 6px;
  background: var(--pbmares-gray);
  border-radius: 50%;
  animation: pbmares-chatbot-bounce 1.2s infinite ease-in-out;
}

.pbmares-chatbot-message__typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.pbmares-chatbot-message__typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}

.pbmares-chatbot-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pbmares-chatbot-quick-reply {
  border: 1px solid var(--pbmares-teal);
  background: #fff;
  color: var(--pbmares-teal);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}

.pbmares-chatbot-quick-reply:hover:not(:disabled) {
  background: var(--pbmares-teal);
  color: #fff;
}

.pbmares-chatbot-quick-reply:disabled {
  border-color: var(--pbmares-divider);
  color: var(--pbmares-gray);
  cursor: not-allowed;
}

.pbmares-chatbot-quick-reply:focus-visible,
.pbmares-chatbot-panel__input button:focus-visible {
  outline: 2px solid var(--pbmares-dark-blue);
  outline-offset: 2px;
}

.pbmares-chatbot-panel__input {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--pbmares-divider);
}

.pbmares-chatbot-panel__input input {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid var(--pbmares-field-border);
  padding: 8px 12px;
  /* 16px: iPhone Safari zooms the page into a field with smaller text when it gets focus (RTS, 10-19). */
  font-size: 16px;
  color: #000;
  background: #fff;
}

.pbmares-chatbot-panel__input input::placeholder {
  color: var(--pbmares-gray);
  opacity: 1;
}

.pbmares-chatbot-panel__input input:focus {
  border-color: var(--pbmares-teal);
  outline: 2px solid var(--pbmares-teal);
  outline-offset: 0;
}

.pbmares-chatbot-panel__input button {
  border: none;
  background: var(--pbmares-teal);
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.pbmares-chatbot-panel__input button:hover:not(:disabled) {
  background: var(--pbmares-dark-blue);
}

.pbmares-chatbot-panel__input button:disabled {
  background: var(--pbmares-divider);
  color: var(--pbmares-gray);
  cursor: not-allowed;
}

/* "Was this chat helpful?" (UAT DEF-46): a quiet line at the end of the conversation, not a message bubble. */
.pbmares-chatbot-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--pbmares-gray);
}

.pbmares-chatbot-feedback:focus {
  outline: none;
}

.pbmares-chatbot-feedback__button {
  border: 1px solid var(--pbmares-teal);
  background: #fff;
  color: var(--pbmares-teal);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}

.pbmares-chatbot-feedback__button:hover {
  background: var(--pbmares-teal);
  color: #fff;
}

.pbmares-chatbot-feedback__button:focus-visible {
  outline: 2px solid var(--pbmares-dark-blue);
  outline-offset: 2px;
}

/* The bigger window and text (UAT DEF-37): wider, as tall as the screen allows above the launcher, larger text. */
.pbmares-chatbot-panel--expanded {
  width: min(560px, calc(100vw - 40px));
  height: min(900px, calc(100vh - 110px));
  height: min(900px, calc(100dvh - 110px));
  max-height: none;
}

.pbmares-chatbot-panel--expanded .pbmares-chatbot-messages {
  flex: 1 1 auto;
}

.pbmares-chatbot-panel--expanded .pbmares-chatbot-message__bubble {
  font-size: 17px;
  line-height: 1.5;
}

.pbmares-chatbot-panel--expanded .pbmares-chatbot-message__meta {
  font-size: 13px;
}

.pbmares-chatbot-panel--expanded .pbmares-chatbot-panel__subtitle,
.pbmares-chatbot-panel--expanded .pbmares-chatbot-quick-reply,
.pbmares-chatbot-panel--expanded .pbmares-chatbot-feedback,
.pbmares-chatbot-panel--expanded .pbmares-chatbot-feedback__button,
.pbmares-chatbot-panel--expanded .pbmares-chatbot-panel__input button {
  font-size: 15px;
}

@keyframes pbmares-chatbot-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pbmares-chatbot-message__typing .dot {
    animation: none;
  }
}
