/* ============================================================
   ONEPA CHATBOT
   GREY HEADER, BLACK VISITOR MESSAGES, GREY BUTTONS
   ============================================================ */

.onepa-chat-widget,
.onepa-chat-widget * {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

.onepa-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;

  display: flex;
  flex-direction: column;
  align-items: flex-end;

  gap: 14px;
}

/* ============================================================
   CHAT BUBBLE
   ============================================================ */

.chat-bubble {
  display: flex;
  align-items: center;
  gap: 12px;

  background: var(--white, #ffffff);
  border: none;
  border-radius: 999px;
  padding: 8px 10px 8px 8px;

  box-shadow: 0 12px 30px rgba(11, 45, 92, 0.18);

  cursor: pointer;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.chat-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(11, 45, 92, 0.24);
}

.chat-bubble:focus-visible {
  outline: 3px solid rgba(50, 102, 176, 0.2);
  outline-offset: 3px;
}

/* ============================================================
   BUBBLE ICON
   ============================================================ */

.chat-bubble-icon {
  width: 44px;
  height: 44px;

  display: flex;
  align-items: center;
  justify-content: center;

  flex: none;
  background: transparent;
  overflow: hidden;
}

.chat-bubble-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: none;
}

/* ============================================================
   BUBBLE TEXT
   ============================================================ */

.chat-bubble-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;

  line-height: 1.25;
  text-align: left;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

.chat-bubble-text strong {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  font-size: 14px;
  font-weight: 500;
  color: #000000;
}

.chat-bubble-text span {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  font-size: 12.5px;
  color: var(--muted, #667085);
}

/* ============================================================
   BUBBLE ARROW — GREY BACKGROUND, BLACK ICON
   ============================================================ */

.chat-bubble-arrow {
  width: 32px;
  height: 32px;

  border-radius: 50%;
  background: #d1d5db;

  display: flex;
  align-items: center;
  justify-content: center;

  flex: none;
  margin-left: 4px;
}

.chat-bubble-arrow svg {
  width: 16px;
  height: 16px;
  color: #000000;

  transition: transform 0.2s ease;
}

.chat-bubble.is-open .chat-bubble-arrow svg {
  transform: rotate(90deg);
}

/* ============================================================
   CHAT PANEL
   ============================================================ */

.chat-panel {
  width: 370px;
  max-width: calc(100vw - 32px);
  height: min(560px, calc(100vh - 120px));

  background: #ffffff;
  border-radius: 18px;

  box-shadow: 0 24px 60px rgba(11, 45, 92, 0.28);

  overflow: hidden;

  display: flex;
  flex-direction: column;

  /*
   * Prevent page-level section padding from creating
   * unwanted space above the chatbot header.
   */

  padding: 0 !important;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

.chat-panel[hidden] {
  display: none !important;
}

/* ============================================================
   CHAT HEADER — GREY
   ============================================================ */

.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 16px;

  background: #d1d5db;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

/* ============================================================
   HEADER ICON
   ============================================================ */

.chat-panel-icon {
  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  flex: none;
  background: transparent;
}

.chat-panel-icon img {
  width: 100%;
  height: 100%;

  object-fit: contain;
  display: block;
  filter: none;
}

/* ============================================================
   HEADER TEXT — BLACK
   ============================================================ */

.chat-panel-heading {
  display: flex;
  flex-direction: column;
  line-height: 1.3;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

.chat-panel-heading strong {
  color: #000000;
  font-size: 14px;
  font-weight: 500;
}

.chat-panel-heading span {
  color: #333333;
  font-size: 12px;
  font-weight: 400;
}

/* ============================================================
   CLOSE BUTTON — GREY WITH BLACK ICON
   ============================================================ */

.chat-panel-close {
  margin-left: auto;

  width: 34px;
  height: 34px;

  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  border: none;
  color: #000000;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  font-size: 20px;
  line-height: 1;
  cursor: pointer;

  transition: background 0.15s ease;
}

.chat-panel-close:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* ============================================================
   MESSAGE BODY
   ============================================================ */

.chat-panel-body {
  flex: 1;
  overflow-y: auto;

  padding: 18px 16px;

  background: #f6f8fc;

  display: flex;
  flex-direction: column;
  gap: 10px;

  scroll-behavior: smooth;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

/* ============================================================
   MESSAGE LAYOUT
   ============================================================ */

.chat-message {
  display: flex;
  width: 100%;
}

.chat-message--visitor {
  justify-content: flex-end;
}

.chat-message--agent {
  justify-content: flex-start;
}

.chat-message-bubble {
  max-width: 82%;
  padding: 11px 13px;
  border-radius: 15px;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  font-size: 13.5px;
  line-height: 1.5;

  word-break: break-word;
  white-space: pre-wrap;
}

/* ============================================================
   CLICKABLE LINKS IN CHAT
   ============================================================ */

.chat-message-bubble a.onepa-chat-link {
  color: #0066cc;

  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  font-weight: 500;
  cursor: pointer;

  transition:
    color 0.15s ease,
    opacity 0.15s ease;
}

.chat-message-bubble a.onepa-chat-link:hover {
  color: #004a99;
  opacity: 0.9;
}

.chat-message-bubble a.onepa-chat-link:focus-visible {
  outline: 2px solid #3266b0;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Keep links blue in agent messages. */

.chat-message--agent
.chat-message-bubble
a.onepa-chat-link:visited {
  color: #0066cc;
}

/* ============================================================
   AGENT MESSAGE — WHITE
   ============================================================ */

.chat-message--agent .chat-message-bubble {
  background: #ffffff;
  color: var(--ink, #172033);

  border: 1px solid #e3e7ee;
  border-bottom-left-radius: 4px;
}

/* ============================================================
   VISITOR MESSAGE — BLACK WITH WHITE TEXT
   ============================================================ */

.chat-message--visitor .chat-message-bubble {
  background: #d1d5db;
  color: #000000;

  border-bottom-right-radius: 4px;
}

/* LINKS INSIDE VISITOR MESSAGES */

.chat-message--visitor
.chat-message-bubble
a.onepa-chat-link {
  color: #ffffff;
  text-decoration: underline;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */

.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;

  padding: 0 16px 10px;
  background: #f6f8fc;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

.chat-typing[hidden] {
  display: none !important;
}

.chat-typing span {
  width: 6px;
  height: 6px;

  border-radius: 50%;
  background: #98a6ba;

  animation: onepa-chat-typing 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.30s;
}

.chat-typing em {
  margin-left: 6px;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  font-size: 11px;
  font-style: normal;
  color: #7a8799;
}

@keyframes onepa-chat-typing {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* ============================================================
   FOOTER
   ============================================================ */

.chat-panel-footer {
  padding: 12px;

  background: #ffffff;
  border-top: 1px solid #e5eaf1;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

/* ============================================================
   INPUT FORM
   ============================================================ */

.chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

/* ============================================================
   INPUT
   ============================================================ */

.chat-input {
  flex: 1;
  min-width: 0;
  height: 44px;

  padding: 0 13px;

  border: 1px solid #dce2eb;
  border-radius: 12px;
  outline: none;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  font-size: 13px;
  color: var(--ink, #172033);
  background: #ffffff;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.chat-input::placeholder {
  color: #98a2b3;
}

.chat-input:focus {
  border-color: var(--blue-mid, #3266b0);
  box-shadow: 0 0 0 3px rgba(50, 102, 176, 0.1);
}

.chat-input:disabled {
  background: #f4f6f9;
  cursor: not-allowed;
}

/* ============================================================
   SEND BUTTON — GREY WITH BLACK ICON
   ============================================================ */

.chat-send {
  width: 44px;
  height: 44px;
  flex: none;

  border: none;
  border-radius: 12px;

  background: #d1d5db;
  color: #000000;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  transition:
    transform 0.15s ease,
    background 0.15s ease,
    opacity 0.15s ease;
}

.chat-send:hover {
  background: #b8bec7;
}

.chat-send:active {
  transform: scale(0.96);
}

.chat-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send svg {
  width: 19px;
  height: 19px;
}

/* ============================================================
   MOBILE
   When the chat is open:
   - a solid BLACK layer sits behind the panel and extends past
     the screen edges, so the website can never show through
     (below, above or behind the keyboard)
   - the page behind is frozen (the JS adds .onepa-chat-open),
     so iOS cannot scroll it and push the header out of view
   - the panel is full screen; its height/top follow the visible
     area (keyboard open or closed) through --chat-vh / --chat-top,
     set by the JS, so the header with the logo stays visible
   - the input is 16px so iOS does not zoom when tapping it
   ============================================================ */

@media (max-width: 480px) {

  /* FREEZE THE PAGE BEHIND WHILE THE CHAT IS OPEN */
  html.onepa-chat-open,
  html:has(.chat-panel:not([hidden])) {
    overflow: hidden !important;
    overscroll-behavior: none;
    height: 100%;
  }

  html.onepa-chat-open body {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  /* SOLID BLACK LAYER BEHIND THE PANEL (hides the website completely) */
  .onepa-chat-widget:has(.chat-panel:not([hidden]))::before {
    content: "";
    position: fixed;
    top: -100vh;
    bottom: -100vh;
    left: -50vw;
    right: -50vw;
    background: #000000;
    z-index: 9998;
    pointer-events: none;
  }

  .onepa-chat-widget {
    right: 16px;
    bottom: 16px;
  }

  .chat-bubble-text {
    display: none;
  }

  .chat-bubble {
    padding: 8px;
  }

  .chat-bubble-arrow {
    display: none;
  }

  /* FULL SCREEN PANEL */
  .chat-panel {
    position: fixed;
    top: var(--chat-top, 0px);
    left: 0;
    right: 0;
    bottom: auto;
    z-index: 10000;

    width: 100%;
    max-width: 100%;
    height: 100vh;                     /* fallback */
    height: var(--chat-vh, 100dvh);    /* set by JS to the exact visible height */
    max-height: none;

    border-radius: 0;
    box-shadow: none;
    background: #ffffff;

    overscroll-behavior: none;
    touch-action: manipulation;
  }

  /* header and footer never shrink or move */
  .chat-panel-header,
  .chat-panel-footer {
    flex: none;
  }

  /* only the messages area scrolls, and it never passes the scroll to the page */
  .chat-panel-body {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    min-height: 0;
  }

  /* keep header and footer clear of notches / home indicator */
  .chat-panel-header {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }

  .chat-panel-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* 16px stops the phone from zooming in when the input is tapped */
  .chat-input {
    font-size: 16px;
  }

  .chat-message-bubble {
    max-width: 88%;
  }
}

/* ============================================================
   VERY SMALL SCREENS
   ============================================================ */

@media (max-width: 360px) {
  .onepa-chat-widget {
    right: 10px;
    bottom: 10px;
  }

  /* still full screen */
  .chat-panel {
    width: 100%;
    max-width: 100%;
  }
}

/* ============================================================
   REDUCE MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .onepa-chat-widget,
  .onepa-chat-widget *,
  .chat-bubble,
  .chat-panel,
  .chat-bubble-arrow svg,
  .chat-send,
  .chat-input {
    transition: none !important;
    animation: none !important;
  }
}