.chatbot-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
}

/* HMS-321 — the hotel-portal concierge renders the same panel inline on its
   own page instead of floating over content. */
.chatbot-widget--inline {
  position: static;
  width: 100%;
  max-width: 44rem;
}

.chatbot-widget--inline .chatbot-widget__panel {
  position: static;
  width: 100%;
  max-height: none;
}

.chatbot-widget--inline .chatbot-widget__messages {
  min-height: 16rem;
}

.chatbot-widget__toggle {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: none;
  background: var(--wa-color-brand-fill-loud);
  color: var(--wa-color-brand-on-loud);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--wa-shadow-m);
}

.chatbot-widget__panel {
  position: absolute;
  bottom: 4rem;
  right: 0;
  width: 24rem;
  max-height: 34rem;
  background: var(--wa-color-surface-raised);
  border: 1px solid var(--wa-color-neutral-border-quiet);
  border-radius: var(--wa-border-radius-l);
  box-shadow: var(--wa-shadow-l);
  display: flex;
  flex-direction: column;
}

.chatbot-widget__panel[hidden] {
  display: none;
}

.chatbot-widget__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: var(--wa-color-brand-fill-loud);
  color: var(--wa-color-brand-on-loud);
}

.chatbot-widget__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--wa-color-brand-fill-quiet);
  color: var(--wa-color-brand-on-quiet);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-widget__header-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-inline-end: auto;
}

.chatbot-widget__header-text strong {
  font-size: 0.875rem;
  line-height: 1.2;
}

.chatbot-widget__status {
  font-size: 0.7rem;
  opacity: 0.8;
  line-height: 1.2;
}

.chatbot-widget__clear {
  font-size: var(--wa-font-size-s);
  background: none;
  border: none;
  cursor: pointer;
}

.chatbot-widget__close {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--wa-border-radius-s);
  background: var(--wa-color-surface-raised);
  color: var(--wa-color-text-normal);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
}

.chatbot-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  background: var(--wa-color-surface-lowered);
}

.chatbot-widget__row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

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

.chatbot-widget__row-avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--wa-color-brand-fill-quiet);
  color: var(--wa-color-brand-on-quiet);
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.chatbot-widget__row-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  max-width: 85%;
}

.chatbot-widget__row--user .chatbot-widget__row-content {
  align-items: flex-end;
}

.chatbot-widget__row-meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--wa-color-text-quiet);
  padding-inline: 0.25rem;
}

.chatbot-widget__row-name {
  font-weight: 600;
  color: var(--wa-color-text-normal);
}

/* .chatbot-widget__row-time — plain, inherits the quiet color from row-meta. */

.chatbot-widget__message {
  margin: 0;
  padding: 0.625rem 0.75rem;
  border-radius: var(--wa-border-radius-m);
  font-size: 0.875rem;
  /* Long unbroken tokens (pasted booking refs, URLs) must wrap inside the
     bubble instead of escaping it and the panel edge. */
  overflow-wrap: break-word;
}

.chatbot-widget__message--bot {
  background: var(--wa-color-surface-raised);
  border: 1px solid var(--wa-color-neutral-border-quiet);
  color: var(--wa-color-text-normal);
}

.chatbot-widget__message--user {
  background: var(--wa-color-neutral-fill-loud);
  color: var(--wa-color-neutral-on-loud);
}

.chatbot-widget__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.chatbot-widget__chip {
  background: var(--wa-color-surface-raised);
  border: 1px solid var(--wa-color-neutral-border-quiet);
  border-radius: 999px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--wa-color-text-normal);
  cursor: pointer;
}

.chatbot-widget__chip:hover {
  border-color: var(--wa-color-brand-border-normal);
}

.chatbot-widget__cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.375rem;
}

.chatbot-widget__card {
  display: block;
  background: var(--wa-color-surface-raised);
  border: 1px solid var(--wa-color-neutral-border-quiet);
  border-radius: var(--wa-border-radius-m);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.chatbot-widget__card:hover {
  border-color: var(--wa-color-brand-border-normal);
}

.chatbot-widget__card-photo {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.chatbot-widget__card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chatbot-widget__card-badge {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  background: var(--wa-color-neutral-fill-loud);
  color: var(--wa-color-neutral-on-loud);
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  border-radius: var(--wa-border-radius-s);
}

/* Photo-less hotels still carry a distance — the badge drops inline next to
   the name instead of being lost with the missing photo. */
.chatbot-widget__card-badge--inline {
  position: static;
  display: inline-block;
  margin-left: 0.375rem;
  vertical-align: baseline;
  font-weight: 600;
}

/* Figma 516:7779 — two-row card: name+stars on row 1, rate+CTA on row 2.
   Explicit grid placement keeps cells correct when stars or rate is absent. */
.chatbot-widget__card-body {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 0.5rem;
  row-gap: 0.25rem;
  align-items: center;
  padding: 0.625rem 0.75rem;
}

.chatbot-widget__card-name {
  grid-column: 1;
  grid-row: 1;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--wa-color-text-normal);
}

.chatbot-widget__card-stars {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  color: var(--wa-color-warning);
  font-size: 0.75rem;
}

.chatbot-widget__card-rate {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--wa-color-text-normal);
}

.chatbot-widget__card-rate small {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--wa-color-text-quiet);
}

.chatbot-widget__card-cta {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--wa-color-brand-fill-normal);
  color: var(--wa-color-brand-on-normal);
  padding: 0.375rem 0.75rem;
  border-radius: var(--wa-border-radius-s);
  font-size: 0.75rem;
  font-weight: 600;
}

.chatbot-widget__form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--wa-color-neutral-border-quiet);
  background: var(--wa-color-surface-raised);
}

.chatbot-widget__input {
  flex: 1;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--wa-color-neutral-border-quiet);
  border-radius: 999px;
  background: var(--wa-color-surface-default);
  color: var(--wa-color-text-normal);
}

.chatbot-widget__send {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--wa-color-brand-fill-normal);
  color: var(--wa-color-brand-on-normal);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.chatbot-widget__escalate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.875rem;
  border-top: 1px solid var(--wa-color-neutral-border-quiet);
  background: var(--wa-color-surface-raised);
}

.chatbot-widget__escalate-prompt {
  font-size: 0.75rem;
  color: var(--wa-color-text-quiet);
}

.chatbot-widget__escalate {
  background: var(--wa-color-surface-raised);
  border: 1px solid var(--wa-color-neutral-border-quiet);
  border-radius: var(--wa-border-radius-s);
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--wa-color-text-normal);
  cursor: pointer;
}

.chatbot-widget__escalate[disabled] {
  opacity: 0.5;
  cursor: default;
}

.chatbot-widget__citations {
  display: block;
  font-size: var(--wa-font-size-s);
  color: var(--wa-color-text-quiet);
  margin-top: 0.25rem;
}

.chatbot-widget__rate-row {
  display: inline-flex;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.chatbot-widget__rate {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.125rem;
  color: var(--wa-color-text-quiet);
}

.chatbot-widget__action-link {
  display: inline-block;
  margin-top: 0.375rem;
  color: var(--wa-color-text-link);
  font-weight: 600;
}

@media (max-width: 480px) {
  .chatbot-widget__panel {
    position: fixed;
    inset: auto 0 0 0;
    width: auto;
    max-height: 75dvh;
    border-radius: var(--wa-border-radius-l) var(--wa-border-radius-l) 0 0;
  }
}

/* The FAB is fixed 1.5rem above the viewport bottom and 3.5rem tall — the last
   ~5rem of every portal page scrolls underneath it (it covered the SMS toggle
   on guest-details and the price column on compare). Scoped by :has() so only
   pages that actually render the widget pay the clearance — the admin and
   hotel-partner layouts also use #main-content but mount no FAB. */
@media (max-width: 64rem) {
  body:has(> .chatbot-widget) #main-content {
    padding-bottom: 6rem;
  }
}

/* ≤640px: the tab bar (≈3.5rem) plus the raised FAB occupy the bottom ~8rem —
   the FAB-clearance rule above is no longer enough. */
@media (max-width: 639.98px) {
  body:has(> .chatbot-widget) #main-content {
    padding-bottom: 9.5rem;
  }

  /* The view-fab's position derives from the chatbot's (0.75rem above its top
     edge). The FAB now sits at 4.5rem, so: 4.5 + 3.5 + 0.75 = 8.75rem. */
  body:has(> .chatbot-widget) .hotel-search__view-fab {
    bottom: 8.75rem;
  }
}
