/* =====================================================================
   TripMate "Ask TripMate" — static chat widget (popup window) + the
   chat bubbles shared with the homepage promo. Loaded site-wide.
   The floating launcher itself (.assistant-fab) lives in layout.css.
   ===================================================================== */

/* ---- Popup window ------------------------------------------------- */
.assistant-widget {
  position: fixed; z-index: 140;
  /* Anchored where the launcher sits, so the window grows up from that spot. */
  right: var(--sp-4); bottom: var(--sp-4);
  width: 360px; max-width: calc(100vw - var(--sp-4) * 2);
  max-height: min(78vh, 580px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-200);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  transform-origin: bottom right;
  animation: assistant-pop 200ms cubic-bezier(.2, .8, .25, 1);
}
@keyframes assistant-pop {
  from { opacity: 0; transform: translateY(10px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

/* Header uses the same navy field as the site's heroes, so the assistant
   reads as part of TripMate rather than a bolted-on chatbot. */
.assistant-widget__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4); color: #fff;
  background:
    radial-gradient(ellipse 90% 140% at 88% 0%, rgba(86, 156, 250, .42), transparent 62%),
    linear-gradient(135deg, #081A38, #0F2D5B);
}
.assistant-widget__head strong { display: block; font-size: var(--fs-base); color: #fff; letter-spacing: -0.01em; }
.assistant-widget__head small { color: rgba(255, 255, 255, .75); font-size: var(--fs-xs); }
.assistant-widget__close {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; padding: 0;
  background: rgba(255, 255, 255, .14); border: 0; border-radius: 50%;
  color: #fff; cursor: pointer;
  transition: background var(--transition);
}
.assistant-widget__close:hover { background: rgba(255, 255, 255, .3); }
.assistant-widget__close svg { display: block; }

.assistant-widget__body {
  flex: 1; overflow-y: auto; padding: var(--sp-4);
  background: var(--surface-2); min-height: 120px;
}

/* Suggestions live inside the chat, as soft quick-replies under the greeting.
   The bottom margin keeps the first sent message from touching the chips. */
.assistant-suggest { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); margin: var(--sp-3) 0 var(--sp-4); }
.assistant-chip {
  max-width: 100%; text-align: left;
  border: 1px solid var(--sky-100); background: var(--surface);
  border-radius: var(--r-md); padding: .5rem .8rem; cursor: pointer;
  font-family: inherit; font-size: var(--fs-sm); font-weight: 500; color: var(--teal-700);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.assistant-chip:hover { border-color: var(--teal-600); background: var(--sky-100); }

.assistant-ticket {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-1); padding: .5rem .8rem;
  border-radius: var(--r-md); background: var(--coral-100); color: var(--tm-accent-text);
  font-size: var(--fs-sm); font-weight: 600;
  transition: background var(--transition), color var(--transition);
}
.assistant-ticket:hover { background: var(--tm-accent); color: var(--tm-on-accent); }
.assistant-ticket svg { flex-shrink: 0; }

/* Quick actions shown under each answer. */
.assistant-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.assistant-action {
  border: 1px solid var(--line-300); background: var(--surface);
  border-radius: var(--r-pill); padding: .3rem .75rem; cursor: pointer;
  font-family: inherit; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-700);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.assistant-action:hover { border-color: var(--teal-600); background: var(--sky-100); color: var(--teal-700); }
.assistant-action--end { color: var(--danger-600); }
.assistant-action--end:hover { border-color: var(--danger-600); background: var(--danger-100); color: var(--danger-600); }

.assistant-widget__form {
  display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line-200);
}
.assistant-widget__input { flex: 1; min-width: 0; }
.assistant-widget__form .btn { flex-shrink: 0; }

/* ---- Chat bubbles (also used by the homepage promo) --------------- */
.msg { max-width: 88%; margin-bottom: var(--sp-3); }
.msg:last-child { margin-bottom: 0; }
.msg--user { margin-left: auto; }
.msg__body {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg);
  font-size: var(--fs-sm); line-height: 1.5;
}
.msg--user .msg__body {
  background: var(--teal-700); color: #fff; border-bottom-right-radius: var(--r-sm);
}
.msg--user .msg__body strong { color: #fff; }
.msg--assistant .msg__body {
  background: var(--surface); color: var(--ink-700);
  border: 1px solid var(--line-200); border-bottom-left-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
}

/* Typing indicator shown briefly before each answer. */
.msg--typing .msg__body { display: inline-flex; align-items: center; gap: 5px; }
.msg--typing .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink-400);
  animation: assistant-blink 1s infinite ease-in-out both;
}
.msg--typing .dot:nth-child(2) { animation-delay: .15s; }
.msg--typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes assistant-blink {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40%           { opacity: 1;  transform: translateY(-3px); }
}

@media (max-width: 560px) {
  .assistant-widget {
    right: var(--sp-3); left: var(--sp-3); bottom: var(--sp-3);
    width: auto; max-height: 78vh;
  }
}
@media (prefers-reduced-motion: reduce) {
  .assistant-widget { animation: none; }
  .msg--typing .dot { animation: none; }
}
