/* Sano State rTMS Guide — visitor widget. Colors follow the landing-page brand tokens. */
:root {
  --rtms-teal: #008099;
  --rtms-teal-dark: #006879;
  --rtms-teal-deep: #0b464f;
  --rtms-teal-light: #ccf2f7;
  --rtms-teal-mist: #f0fbfd;
  --rtms-ink: #1e293b;
  --rtms-muted: #64748b;
  --rtms-line: #d5e3e7;
  --rtms-surface: #ffffff;
  --rtms-crisis-bg: #f8efea;
  --rtms-crisis-border: #e4c4b4;
  --rtms-crisis-text: #6d3318;
  --rtms-chat-z: 80;
}

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

.chat-root {
  position: fixed;
  right: max(1.1rem, env(safe-area-inset-right));
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  z-index: var(--rtms-chat-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  pointer-events: none;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.chat-root > * {
  pointer-events: auto;
}

.chat-icon {
  display: block;
  flex-shrink: 0;
}

.chat-icon-lg {
  width: 1.75rem;
  height: 1.75rem;
}

.chat-icon-md {
  width: 1.25rem;
  height: 1.25rem;
}

.chat-icon-sm {
  width: 1rem;
  height: 1rem;
}

.chat-icon-xs {
  width: 0.875rem;
  height: 0.875rem;
}

.chat-launcher {
  position: relative;
  width: 3.75rem;
  height: 3.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--rtms-teal);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 28px rgba(0, 128, 153, 0.32);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.chat-launcher:hover,
.chat-launcher:focus-visible {
  background: var(--rtms-teal-dark);
  transform: translateY(-1px);
  outline: none;
}

.chat-launcher-close {
  font-size: 1.5rem;
  line-height: 1;
}

.chat-launcher-ai {
  position: absolute;
  top: -0.2rem;
  right: -0.15rem;
  background: var(--rtms-teal-deep);
  color: white;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 0.12rem 0.32rem;
  border: 2px solid white;
}

.chat-invite {
  position: relative;
  width: min(19.5rem, calc(100vw - 2.4rem));
  background: white;
  color: var(--rtms-ink);
  border: 1px solid var(--rtms-line);
  border-radius: 1.1rem;
  padding: 0.95rem 1rem 1rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  animation: rtms-invite-in 220ms ease;
}

.chat-invite[hidden],
.chat-window:not(.chat-window-open) {
  display: none;
}

.chat-invite-kicker {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rtms-teal-dark);
}

.chat-invite-title {
  margin: 0.25rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.chat-invite-body {
  margin: 0.35rem 0 0.85rem;
  color: var(--rtms-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.chat-invite-cta,
.chat-primary-btn {
  width: 100%;
  border: 0;
  border-radius: 0.7rem;
  background: var(--rtms-teal);
  color: white;
  font-weight: 650;
  padding: 0.62rem 0.8rem;
  cursor: pointer;
}

.chat-invite-cta:hover,
.chat-primary-btn:hover,
.chat-send:hover:not(:disabled) {
  background: var(--rtms-teal-dark);
}

.chat-invite-close,
.chat-icon-button {
  border: 0;
  background: transparent;
  color: var(--rtms-muted);
  cursor: pointer;
  border-radius: 0.4rem;
  padding: 0.2rem;
}

.chat-invite-close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
}

.chat-header .chat-icon-button {
  color: white;
}

.chat-window {
  display: none;
  width: min(26rem, calc(100vw - 1.5rem));
  height: min(40rem, calc(100dvh - 6.5rem));
  background: var(--rtms-surface);
  border: 1px solid var(--rtms-line);
  border-radius: 1.2rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  flex-direction: column;
}

.chat-window-open {
  display: flex;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  background: linear-gradient(180deg, var(--rtms-teal) 0%, var(--rtms-teal-dark) 100%);
  color: white;
}

.chat-header-copy {
  min-width: 0;
  flex: 1;
}

.chat-avatar {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chat-header-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.98rem;
}

.chat-header-sub {
  margin: 0.05rem 0 0;
  font-size: 0.75rem;
  opacity: 0.9;
}

.chat-window-body {
  flex: 1;
  overflow: auto;
  padding: 0.9rem 0.85rem 0.4rem;
  background: var(--rtms-teal-mist);
}

.chat-transcript {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.chat-row-user {
  display: flex;
  justify-content: flex-end;
}

.chat-row-bot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.chat-privacy {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--rtms-muted);
  background: white;
  border: 1px dashed var(--rtms-line);
  border-radius: 0.8rem;
  padding: 0.65rem 0.75rem;
}

.chat-bubble-bot,
.chat-bubble-user,
.chat-bubble-crisis {
  max-width: 92%;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border-radius: 1rem;
  font-size: 0.94rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.chat-bubble-bot {
  background: white;
  border: 1px solid var(--rtms-line);
  border-bottom-left-radius: 0.3rem;
  color: var(--rtms-ink);
}

.chat-bubble-user {
  background: var(--rtms-teal);
  color: white;
  border-bottom-right-radius: 0.3rem;
}

.chat-bubble-crisis {
  background: var(--rtms-crisis-bg);
  border: 1px solid var(--rtms-crisis-border);
  color: var(--rtms-crisis-text);
  border-bottom-left-radius: 0.3rem;
}

.chat-booking-actions {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.chat-starters:empty {
  display: none;
}

.chat-chip {
  border: 1px solid var(--rtms-line);
  background: white;
  color: var(--rtms-teal-deep);
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}

.chat-chip:hover:not(:disabled) {
  border-color: var(--rtms-teal);
  background: var(--rtms-teal-light);
}

.chat-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-composer {
  display: flex;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem 0.35rem;
  border-top: 1px solid var(--rtms-line);
  background: white;
}

.chat-input {
  flex: 1;
  border: 1px solid var(--rtms-line);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  color: var(--rtms-ink);
  background: white;
}

.chat-input:focus {
  outline: 2px solid rgba(0, 128, 153, 0.35);
  border-color: var(--rtms-teal);
}

.chat-send {
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--rtms-teal);
  color: white;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-contact-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  padding: 0.45rem 0.8rem 0.7rem;
  background: white;
  border-top: 1px solid var(--rtms-line);
}

.chat-contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--rtms-teal-dark);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.chat-contact-link:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.chat-feedback-label,
.chat-feedback-thanks {
  font-size: 0.72rem;
  color: var(--rtms-muted);
  margin: 0;
}

.chat-feedback-btn {
  border: 0;
  background: transparent;
  color: var(--rtms-muted);
  cursor: pointer;
  padding: 0.1rem;
}

.chat-reason-row {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.chat-reason-chip {
  border: 1px solid var(--rtms-line);
  background: white;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

.chat-typing {
  display: inline-flex;
  gap: 0.28rem;
  align-items: center;
  min-width: 3.4rem;
}

.chat-typing span {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 999px;
  background: var(--rtms-teal);
  animation: rtms-typing 1s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes rtms-typing {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes rtms-invite-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 767px) {
  .chat-root {
    bottom: calc(4.75rem + env(safe-area-inset-bottom));
  }

  body.sano-rtms-chat-open .chat-root {
    bottom: max(1.1rem, env(safe-area-inset-bottom));
  }

  body.sano-rtms-chat-open #mobile-conversion-bar {
    display: none;
  }

  body.sano-rtms-chat-open {
    overflow: hidden;
  }

  .chat-window {
    position: fixed;
    inset: 0.45rem 0.45rem 5.1rem;
    width: auto;
    height: auto;
    border-radius: 1rem;
  }

  .chat-launcher {
    width: 3.5rem;
    height: 3.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-invite,
  .chat-launcher,
  .chat-typing span {
    animation: none;
    transition: none;
  }
}
