/**
 * Drive "Ask anything" chatbot widget (prototype). Loaded on top of
 * drive.css — shares its design tokens (--drive-*).
 *
 * Docks into the hero in place of the ticket CTA (Blocks/Drive.php
 * hero_cta()) rather than floating fixed over the page — the toggle
 * reuses .drive-primary-button/--hero so it's visually identical to the
 * button it replaces, and the panel drops down from it in normal flow.
 */

.drive-chatbot {
  position: relative;
  display: inline-block;
  font-family: inherit;
}

.drive-chatbot__toggle {
  cursor: pointer;
}

.drive-chatbot__panel {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  z-index: 60;
  width: min(360px, calc(100vw - 48px));
  max-height: min(520px, calc(100vh - 160px));
  display: flex;
  flex-direction: column;
  background: var(--drive-mellow-white);
  border: 1px solid var(--drive-border);
  border-radius: 12px;
  box-shadow: var(--drive-shadow);
  overflow: hidden;
}

/*
 * Docked mode (drive-chatbot.js, IntersectionObserver): once the hero CTA
 * scrolls past the top of the viewport, the launcher pops out of the hero's
 * document flow and pins to the bottom-right corner instead, shrunk to a
 * compact pill so a permanently-visible button doesn't dominate the page.
 * The panel opens upward from it (bottom-anchored) since there's no room
 * below a button sitting at the bottom of the screen.
 */
.drive-chatbot--docked {
  position: fixed;
  right: 20px;
  bottom: 20px;
  left: auto;
  z-index: 60;
}

.drive-chatbot--docked .drive-chatbot__toggle {
  min-width: 0;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--drive-shadow);
}

.drive-chatbot--docked .drive-chatbot__panel {
  top: auto;
  bottom: calc(100% + 12px);
  left: auto;
  right: 0;
}

.drive-chatbot__panel[hidden] {
  display: none;
}

.drive-chatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--drive-green-deep);
  color: var(--drive-mellow-white);
  font-weight: 600;
  font-size: 14px;
}

.drive-chatbot__close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  padding: 2px;
}

.drive-chatbot__messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
}

.drive-chatbot__message {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.drive-chatbot__message--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--drive-border);
  color: var(--drive-road-black);
}

.drive-chatbot__message--user {
  align-self: flex-end;
  background: var(--drive-green);
  color: var(--drive-road-black);
}

.drive-chatbot__message--error {
  align-self: flex-start;
  background: #fdeceb;
  border: 1px solid #f0b4ae;
  color: #7a2a22;
}

.drive-chatbot__message--pending {
  align-self: flex-start;
  color: var(--drive-forest);
  font-style: italic;
}

.drive-chatbot__form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--drive-border);
  background: #fff;
}

.drive-chatbot__form input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--drive-border);
  border-radius: 8px;
  font-size: 14px;
}

.drive-chatbot__form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--drive-green-dark);
  color: var(--drive-mellow-white);
  cursor: pointer;
  flex-shrink: 0;
}

.drive-chatbot__form button:disabled {
  opacity: 0.5;
  cursor: default;
}
