/* M&S contact assistant. The WordPress theme owns this component only. */
#ms-contact-widget,
.ms-contact-dialog {
  --ms-chat-paper: var(--paper, #f8f7f3);
  --ms-chat-sand: var(--sand, #eeece6);
  --ms-chat-ink: var(--ink, #232b2c);
  --ms-chat-muted: var(--muted, #626860);
  --ms-chat-line: var(--line, #d8d9d2);
  --ms-chat-red: var(--button-red, #c62d32);
  font-family: var(--font, Manrope, Arial, sans-serif);
}

#ms-contact-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
}

#ms-contact-widget .ms-contact-launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  max-width: calc(100vw - 48px);
  padding: 13px 18px;
  border: 1px solid var(--ms-chat-ink);
  border-radius: 28px;
  background: var(--ms-chat-ink);
  color: #fff;
  box-shadow: 0 5px 20px #17201d26;
  font: 600 14px/1.5 var(--font, Manrope, Arial, sans-serif);
  text-align: center;
  cursor: pointer;
  transition: background .16s ease, box-shadow .16s ease;
}

#ms-contact-widget .ms-contact-launcher:hover {
  background: #35413f;
  box-shadow: 0 7px 24px #17201d30;
}

#ms-contact-widget .ms-contact-launcher svg {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
}

body.ms-contact-open {
  overflow: hidden;
}

body.ms-contact-open #ms-contact-widget .ms-contact-launcher,
body:has(.ms-consent:not([hidden])) #ms-contact-widget .ms-contact-launcher,
body.ms-contact-open .mobile-contact {
  visibility: hidden;
  pointer-events: none;
}

/* A native modal keeps one clear focus and interaction boundary. */
.ms-contact-dialog {
  position: fixed;
  inset: auto 24px 24px auto;
  width: min(420px, calc(100vw - 48px));
  height: min(640px, calc(100vh - 48px));
  height: min(640px, calc(var(--ms-contact-viewport-height, 100dvh) - 48px));
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ms-chat-line);
  border-radius: 16px;
  background: var(--ms-chat-paper);
  color: var(--ms-chat-ink);
  box-shadow: 0 18px 65px #17201d38;
  font-size: 14px;
  line-height: 1.65;
  text-align: left;
}

.ms-contact-dialog[open] {
  display: flex;
  flex-direction: column;
}

.ms-contact-dialog::backdrop {
  background: #17201d52;
  backdrop-filter: blur(2px);
}

.ms-contact-dialog *,
.ms-contact-dialog *::before,
.ms-contact-dialog *::after {
  box-sizing: border-box;
}

.ms-contact-dialog [hidden] {
  display: none !important;
}

#ms-contact-widget :focus-visible,
.ms-contact-dialog :focus-visible {
  outline: 3px solid var(--ms-chat-red);
  outline-offset: 3px;
}

.ms-contact-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--ms-chat-line);
  background: var(--ms-chat-paper);
}

.ms-contact-avatar {
  display: grid;
  flex: 0 0 40px;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--ms-chat-line);
  border-radius: 10px;
  background: #fff;
  color: var(--ms-chat-red);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.ms-contact-identity {
  flex: 1 1 auto;
  min-width: 0;
}

.ms-contact-dialog .ms-contact-identity h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.4px;
  overflow-wrap: anywhere;
}

.ms-contact-dialog .ms-contact-identity p {
  margin: 3px 0 0;
  color: var(--ms-chat-muted);
  font-size: 12px;
  line-height: 1.5;
}

.ms-contact-dialog .ms-contact-close {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ms-chat-ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.ms-contact-dialog .ms-contact-close:hover {
  border-color: var(--ms-chat-line);
  background: var(--ms-chat-sand);
}

.ms-contact-dialog .ms-contact-close svg {
  width: 20px;
  height: 20px;
}

/* The transcript scrolls; controls stay in the dialog's flex layout. */
.ms-contact-conversation {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ms-contact-log {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 0;
  padding: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b6bcb2 transparent;
  scroll-padding-block: 18px;
  background: var(--ms-chat-paper);
}

.ms-contact-message {
  flex: 0 0 auto;
  max-width: 94%;
  padding: 11px 13px;
  border: 1px solid var(--ms-chat-line);
  border-radius: 12px 12px 12px 3px;
  background: #fff;
  color: var(--ms-chat-ink);
  overflow-wrap: anywhere;
}

.ms-contact-dialog .ms-contact-message p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.ms-contact-message.is-user {
  align-self: flex-end;
  max-width: 88%;
  border-color: var(--ms-chat-ink);
  border-radius: 12px 12px 3px 12px;
  background: var(--ms-chat-ink);
  color: #fff;
}

.ms-contact-message.is-assistant {
  align-self: flex-start;
}

.ms-contact-dialog .ms-contact-message a {
  color: var(--ms-chat-red);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ms-contact-dialog .ms-contact-message > a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 4px;
}

.ms-contact-reply-source {
  display: block;
  margin-top: 8px;
  color: var(--ms-chat-muted);
  font-size: 11px;
  line-height: 1.5;
}

.ms-contact-dialog .ms-whatsapp-open[aria-disabled="true"] {
  opacity: .45;
  cursor: default;
}

.ms-contact-dialog .ms-contact-error {
  padding: 11px 13px;
  border: 1px solid #d6b3ac;
  border-radius: 10px;
  background: #fff4f0;
  color: #8c282c;
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.ms-contact-suggestions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 18px 12px;
  background: var(--ms-chat-paper);
}

.ms-contact-suggestions button {
  min-height: 44px;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--ms-chat-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ms-chat-ink);
  font: 500 12px/1.5 var(--font, Manrope, Arial, sans-serif);
  text-align: left;
  cursor: pointer;
}

.ms-contact-suggestions button:hover {
  border-color: #9ca497;
  background: var(--ms-chat-sand);
}

.ms-contact-form {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--ms-chat-line);
  background: var(--ms-chat-paper);
}

.ms-contact-dialog textarea {
  display: block;
  min-width: 0;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #b7beb1;
  border-radius: 9px;
  background: #fff;
  color: var(--ms-chat-ink);
  font: 400 16px/1.5 var(--font, Manrope, Arial, sans-serif);
  resize: none;
}

.ms-contact-dialog textarea::placeholder {
  color: var(--ms-chat-muted);
  opacity: 1;
}

.ms-contact-dialog textarea:focus {
  border-color: var(--ms-chat-red);
}

.ms-contact-form textarea {
  flex: 1 1 auto;
  height: 48px;
  min-height: 48px;
  max-height: 112px;
  overflow-y: auto;
}

.ms-contact-dialog .ms-contact-send {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--ms-chat-red);
  border-radius: 9px;
  background: var(--ms-chat-red);
  color: #fff;
  font: 600 13px/1.5 var(--font, Manrope, Arial, sans-serif);
  cursor: pointer;
}

.ms-contact-dialog .ms-contact-send:hover:not(:disabled) {
  border-color: #a92328;
  background: #a92328;
}

.ms-contact-dialog button:disabled {
  opacity: .6;
  cursor: wait;
}

.ms-contact-direct-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  padding: 0 18px 8px;
}

.ms-contact-dialog .ms-contact-call {
  display: flex;
  flex: 1 0 100%;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--ms-chat-red);
  border-radius: 8px;
  background: var(--ms-chat-red);
  color: #fff;
  font: 600 14px/1.5 var(--font, Manrope, Arial, sans-serif);
  text-decoration: none;
}

.ms-contact-dialog .ms-contact-call:hover {
  background: #a92328;
  border-color: #a92328;
}

.ms-contact-call-number {
  white-space: nowrap;
}

.ms-contact-dialog .ms-contact-whatsapp,
.ms-contact-dialog .ms-contact-link {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--ms-chat-line);
  border-radius: 8px;
  background: transparent;
  color: var(--ms-chat-ink);
  font: 600 12px/1.5 var(--font, Manrope, Arial, sans-serif);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.ms-contact-dialog .ms-contact-whatsapp:hover,
.ms-contact-dialog .ms-contact-link:hover {
  border-color: #9ca497;
  background: var(--ms-chat-sand);
}

.ms-contact-dialog .ms-contact-note {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 18px 15px;
  color: var(--ms-chat-muted);
  font-size: 12px;
  line-height: 1.55;
}

.ms-contact-note a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Handoff is a separate, editable review step, with room for long messages. */
.ms-contact-handoff {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 13px;
  min-height: 0;
  padding: 20px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ms-contact-dialog .ms-contact-handoff h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.5px;
}

.ms-contact-dialog .ms-contact-handoff p {
  margin: 0;
  color: var(--ms-chat-muted);
  font-size: 14px;
  line-height: 1.65;
}

.ms-contact-handoff textarea {
  flex: 1 0 160px;
  min-height: 140px;
  max-height: 320px;
}

.ms-contact-handoff-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
}

.ms-contact-dialog .ms-whatsapp-open,
.ms-contact-dialog .ms-handoff-back {
  display: inline-flex;
  flex: 1 1 145px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--ms-chat-ink);
  border-radius: 8px;
  background: var(--ms-chat-ink);
  color: #fff;
  font: 600 13px/1.5 var(--font, Manrope, Arial, sans-serif);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.ms-contact-dialog .ms-whatsapp-open:hover {
  background: #35413f;
}

.ms-contact-dialog .ms-handoff-back {
  border-color: var(--ms-chat-line);
  background: transparent;
  color: var(--ms-chat-ink);
}

.ms-contact-dialog .ms-handoff-back:hover {
  border-color: #9ca497;
  background: var(--ms-chat-sand);
}

@media (max-width: 700px) {
  #ms-contact-widget {
    right: 16px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }

  #ms-contact-widget .ms-contact-launcher {
    max-width: calc(100vw - 32px);
    min-height: 52px;
    padding: 12px 16px;
    font-size: 13px;
  }

  .ms-contact-dialog {
    inset: var(--ms-contact-viewport-top, 0px) 0 auto;
    width: 100%;
    height: 100vh;
    height: var(--ms-contact-viewport-height, 100dvh);
    max-width: 100%;
    margin: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .ms-contact-header {
    min-height: 76px;
    gap: 10px;
    padding: 12px 16px;
  }

  .ms-contact-dialog .ms-contact-identity h2 {
    font-size: 16px;
  }

  .ms-contact-log {
    padding: 16px;
  }

  .ms-contact-suggestions {
    padding-inline: 16px;
  }

  .ms-contact-form {
    padding: 11px 16px;
  }

  .ms-contact-direct-actions {
    padding-inline: 16px;
  }

  .ms-contact-dialog .ms-contact-note {
    padding: 0 16px 12px;
  }

  .ms-contact-handoff {
    padding: 18px 16px;
  }

  /* JS may set this when the software keyboard reduces the visible viewport. */
  .ms-contact-dialog.is-compact .ms-contact-header {
    min-height: 62px;
    padding-block: 8px;
  }

  .ms-contact-dialog.is-compact .ms-contact-suggestions,
  .ms-contact-dialog.is-compact .ms-contact-note {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #ms-contact-widget *,
  .ms-contact-dialog * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  #ms-contact-widget,
  .ms-contact-dialog {
    display: none !important;
  }
}
