/* eHolidayer AI Assistant
 *
 * A full block of its own in the main content area, sitting directly beneath
 * the search hero. The hero above is untouched: the traditional booking form
 * stays visible, and this stylesheet contains no rule that can hide it.
 *
 * Colour and type are the site's own, lifted from modules/mod_tabsearch so
 * the block reads as part of eHolidayer rather than a foreign widget:
 *   #4285F4  the accent the site's own tabs already use
 *   #0F1B2D  the navy the hero overlay is built from
 *   Inter    the site's family
 * Two rules decide the whole look:
 *   - the block is centred at the same 880px measure as the hero, so the two
 *     objects read as one column rather than two competing layouts;
 *   - the assistant's replies are left-aligned text and the visitor's are a
 *     raised block on the right. That asymmetry alone makes the conversation
 *     readable, so there are no avatars, no coloured bubbles and no icons.
 * No gradients, no drop shadows, no icon soup.
 *
 * Every colour is declared in :root and redeclared under
 * @media (prefers-color-scheme: dark), so the block follows the operating
 * system when the rest of the theme does.
 */

:root {
  --ai-blue: #4285F4;
  --ai-blue-deep: #1a5fd0;
  --ai-ink: #0F1B2D;
  --ai-text: #17233a;
  --ai-muted: #5b6b83;
  --ai-line: #dbe3ee;
  --ai-surface: #ffffff;
  --ai-raised: #f2f5fa;
  --ai-radius: 12px;
  --ai-font: 'Inter', 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ai-blue: #6ba2ff;
    --ai-blue-deep: #4285F4;
    --ai-ink: #0b1424;
    --ai-text: #e8eef7;
    --ai-muted: #9aabc2;
    --ai-line: #27344a;
    --ai-surface: #101a2b;
    --ai-raised: #18243a;
  }
}

/* --------------------------------------------------------------- the block */

.aichat-block {
  box-sizing: border-box;
  font-family: var(--ai-font);
  width: 100%;
  max-width: 880px;
  margin: 44px auto 56px;
  padding: 28px 30px 30px;
  background: var(--ai-surface);
  border: 1px solid var(--ai-line);
  border-radius: 16px;
}

.aichat-block *,
.aichat-block *::before,
.aichat-block *::after { box-sizing: border-box; }

/* The heading is set in the site's ink at a size that reads as a page
   section, not as a widget title. It is the one place the block borrows the
   hero's weight, so the visitor's eye arrives here from the tagline above. */
.aichat-heading {
  margin: 0;
  font: 700 26px/1.25 var(--ai-font);
  letter-spacing: -0.3px;
  color: var(--ai-ink);
}

@media (prefers-color-scheme: dark) {
  .aichat-heading { color: var(--ai-text); }
}

.aichat-lede {
  margin: 8px 0 22px;
  font: 400 15px/1.55 var(--ai-font);
  color: var(--ai-muted);
  max-width: 62ch;
}

/* ---------------------------------------------------------------- head bar */

.aichat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--ai-line);
}

.aichat-title {
  font: 600 15px/1 var(--ai-font);
  color: var(--ai-ink);
}

@media (prefers-color-scheme: dark) {
  .aichat-title { color: var(--ai-text); }
}

.aichat-clear {
  flex: 0 0 auto;
  padding: 8px 10px;
  font: 500 13px/1 var(--ai-font);
  color: var(--ai-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.aichat-clear:hover { color: var(--ai-text); background: var(--ai-raised); }

/* ------------------------------------------------------------- transcript */

.aichat-log {
  min-height: 260px;
  max-height: min(56vh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font: 400 15px/1.6 var(--ai-font);
  scrollbar-width: thin;
}

.aichat-row { max-width: 68ch; }

.aichat-bubble { color: var(--ai-text); overflow-wrap: break-word; }

/* Only the visitor's message is a single run of text, so only it needs its
   line breaks preserved. The assistant's reply is built from real paragraphs
   and lists, and pre-wrap on those would double every gap. */
.aichat-row.me .aichat-bubble { white-space: pre-wrap; overflow-wrap: anywhere; }

/* -------------------------------------------------------------- reply type
 *
 * The assistant answers in light Markdown, which is rendered into real
 * elements. This is the typography that makes the answer scannable: a hotel
 * name or a price carries weight, a list of details is a list, and nothing
 * relies on the reader recognising asterisks as a formatting instruction.
 */

.aichat-p {
  margin: 0 0 10px;
  line-height: 1.6;
}

.aichat-p:last-child { margin-bottom: 0; }

.aichat-list {
  margin: 0 0 10px;
  padding-inline-start: 22px;
  line-height: 1.55;
}

.aichat-list li { margin: 0 0 5px; padding-inline-start: 2px; }
.aichat-list li:last-child { margin-bottom: 0; }

.aichat-bubble strong { font-weight: 700; color: var(--ai-ink); }

@media (prefers-color-scheme: dark) {
  .aichat-bubble strong { color: #ffffff; }
}

/* A heading the model used - a hotel name on its own line. Set apart by its
   own rule rather than by a bigger font, so a run of them still reads as a
   list of properties and not as a stack of shouts. */
.aichat-h {
  display: block;
  margin: 14px 0 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--ai-line);
  font-size: 15px;
  letter-spacing: 0.1px;
}

.aichat-bubble > .aichat-h:first-child { margin-top: 0; }

.aichat-url { color: var(--ai-muted); overflow-wrap: anywhere; }

/* A gallery URL the model wrote into its own prose, which addImages() has
   already pulled out and rendered as a photo directly above. Left in the text
   it would be the bare link we are trying to get rid of, so it is removed
   from the flow - not the DOM, so the reply still reads correctly to a
   screen reader and to select-and-copy. */
.aichat-url-hidden { display: none; }

/* The visitor's own words get a raised block; the assistant's are plain text
   on the surface. That asymmetry is enough to read the conversation without a
   single coloured bubble, and it means a long AI reply reads as an answer
   rather than as a message. */
.aichat-row.me { align-self: flex-end; }

.aichat-row.me .aichat-bubble {
  background: var(--ai-raised);
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-radius);
  padding: 9px 14px;
  max-width: 58ch;
}

.aichat-row.err .aichat-bubble { color: #b3261e; }

@media (prefers-color-scheme: dark) {
  .aichat-row.err .aichat-bubble { color: #ffb4ab; }
}

/* ---------------------------------------------------------------- photos
 *
 * A row of the actual hotel photographs, at the size a guest scans for a
 * property rather than the size they inspect one. One photo on its own takes
 * the full width; two or more sit side by side. Clicking opens the full-size
 * file, which is the only reason the frame is an anchor at all.
 */

.aichat-shots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  max-width: 68ch;
  align-self: flex-start;
}

.aichat-shot {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  background: var(--ai-raised);
  line-height: 0;
}

.aichat-shot img {
  display: block;
  width: 100%;
  height: 152px;
  object-fit: cover;
  transition: transform 0.25s ease;
}

/* Motion answers the pointer here - it is the one hover effect in the block,
   and it exists to signal that the photo is bigger than it looks. */
.aichat-shot:hover img { transform: scale(1.04); }

.aichat-shot:focus-visible {
  outline: 2px solid var(--ai-blue);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- offers */

.aichat-card {
  display: flex;
  gap: 14px;
  align-items: center;
  max-width: 68ch;
  padding: 12px;
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-radius);
  background: var(--ai-raised);
}

.aichat-card img {
  width: 78px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}

.aichat-card-body { min-width: 0; }

.aichat-card-name {
  font: 600 15px/1.35 var(--ai-font);
  color: var(--ai-text);
  overflow-wrap: anywhere;
}

.aichat-card-total {
  margin-top: 3px;
  font: 500 14px/1.4 var(--ai-font);
  color: var(--ai-muted);
}

.aichat-book {
  display: inline-block;
  margin-top: 8px;
  font: 600 14px/1 var(--ai-font);
  color: var(--ai-blue-deep);
  text-decoration: none;
  border-bottom: 2px solid currentColor;
  padding-bottom: 2px;
  transition: opacity 0.15s ease;
}

.aichat-book:hover { opacity: 0.75; }

/* ---------------------------------------------------------- suggestions */

.aichat-suggest-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.aichat-suggest {
  font: 500 13px/1 var(--ai-font);
  color: var(--ai-text);
  background: var(--ai-surface);
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.aichat-suggest:hover { border-color: var(--ai-blue); background: var(--ai-raised); }

/* ---------------------------------------------------------------- typing */

.aichat-typing {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
  color: var(--ai-muted);
}

.aichat-typing.on { display: flex; }

.aichat-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  animation: aichat-pulse 1.15s ease-in-out infinite;
}

.aichat-typing i:nth-child(2) { animation-delay: 0.15s; }
.aichat-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes aichat-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 0.9; transform: translateY(-2px); }
}

/* -------------------------------------------------------------- composer */

.aichat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-top: 16px;
  margin-top: 12px;
  border-top: 1px solid var(--ai-line);
}

.aichat-input {
  flex: 1 1 auto;
  min-height: 48px;
  max-height: 150px;
  padding: 13px 14px;
  font: 400 15px/1.45 var(--ai-font);
  color: var(--ai-text);
  background: var(--ai-surface);
  border: 1px solid var(--ai-line);
  border-radius: 10px;
  resize: none;
}

.aichat-input::placeholder { color: var(--ai-muted); }

.aichat-send {
  flex: 0 0 auto;
  height: 48px;
  padding: 0 22px;
  font: 600 14px/1 var(--ai-font);
  color: #ffffff;
  background: var(--ai-blue-deep);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.aichat-send:hover { background: var(--ai-blue); }
.aichat-send:disabled { opacity: 0.5; cursor: default; }

/* Keyboard users get a real focus ring, never a removed outline. */
.aichat-clear:focus-visible,
.aichat-send:focus-visible,
.aichat-suggest:focus-visible,
.aichat-input:focus-visible {
  outline: 2px solid var(--ai-blue);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 640px) {
  .aichat-block {
    margin: 28px auto 36px;
    padding: 20px 16px 18px;
  }

  .aichat-heading { font-size: 21px; }

  .aichat-lede { font-size: 14px; margin-bottom: 16px; }

  .aichat-log {
    padding: 16px 2px 6px;
    min-height: 220px;
    max-height: 54vh;
  }

  .aichat-row { max-width: 100%; }

  .aichat-row.me .aichat-bubble { max-width: 88%; }

  .aichat-shots { max-width: 100%; }

  .aichat-shot img { height: 124px; }

  .aichat-form { gap: 8px; }

  .aichat-send { padding: 0 16px; }

  .aichat-clear { font-size: 12px; }
}

/* -------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .aichat-block *,
  .aichat-block *::before,
  .aichat-block *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
