/* ============================================================
   AI search drawer for the Landing search UX demo.
   Self contained, no dependencies, no edits to other files.
   Wire up with:
     <link rel="stylesheet" href="ai-search.css">
     <script src="ai-search.js"></script>
   ============================================================ */

.ai-root {
  --ai-top: 45px;
  --ai-accent: var(--accent, #3557F0);
  --ai-accent-soft: var(--accent-soft, #E8EDFE);
  --ai-blue: var(--landing-blue, #15192D);
  --ai-line: var(--line, #e5e7ee);
  --ai-ink: var(--ink, #1c2030);
  --ai-ink-soft: var(--ink-soft, #5b6172);
  --ai-radius: var(--radius, 14px);
}

/* ---------- launcher pill ---------- */
.ai-launch {
  position: fixed; right: 20px; bottom: 20px; z-index: 1300;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; font-weight: 700; color: #fff; letter-spacing: -.01em;
  background: var(--ai-blue); border: none; border-radius: 999px;
  padding: 12px 20px 12px 16px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(21,25,45,.24), 0 12px 32px rgba(21,25,45,.22);
  transition: transform .16s, box-shadow .16s, opacity .2s;
}
.ai-launch:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(21,25,45,.28), 0 16px 40px rgba(21,25,45,.26); }
.ai-launch:active { transform: translateY(0); }
.ai-launch:focus-visible { outline: 3px solid var(--ai-accent-soft); outline-offset: 2px; }
.ai-launch .ai-spark { width: 17px; height: 17px; flex: none; color: #9fb4ff; }
.ai-launch.ai-hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* ---------- drawer ---------- */
.ai-drawer {
  position: fixed; top: var(--ai-top); right: 0; bottom: 0; width: 380px; max-width: 100%;
  z-index: 1400; background: #fff; border-left: 1px solid var(--ai-line);
  box-shadow: -2px 0 6px rgba(21,25,45,.10), -18px 0 50px rgba(21,25,45,.14);
  display: flex; flex-direction: column; min-height: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ai-ink);
  transform: translateX(100%); visibility: hidden;
  transition: transform .26s cubic-bezier(.4,0,.2,1), visibility 0s linear .26s;
}
.ai-drawer.ai-open { transform: translateX(0); visibility: visible; transition: transform .26s cubic-bezier(.4,0,.2,1), visibility 0s; }

.ai-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; border-bottom: 1px solid var(--ai-line); flex: none;
}
.ai-head .ai-spark { width: 17px; height: 17px; color: var(--ai-accent); flex: none; }
.ai-head-title { font-size: 15px; font-weight: 800; letter-spacing: -.01em; flex: 1; min-width: 0; }
.ai-reset {
  border: none; background: none; padding: 4px 6px; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--ai-accent); border-radius: 6px;
}
.ai-reset:hover { background: var(--ai-accent-soft); }
.ai-close {
  border: none; background: #f3f4f8; color: var(--ai-ink-soft); cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%; font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.ai-close:hover { background: #e6e8f0; color: var(--ai-ink); }

/* ---------- message list ---------- */
.ai-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 6px; background: #fafafc; }
.ai-msg { margin-bottom: 12px; display: flex; }
.ai-msg.ai-user { justify-content: flex-end; }
.ai-bubble {
  max-width: 88%; font-size: 13.5px; line-height: 1.45;
  padding: 10px 13px; border-radius: var(--ai-radius);
}
.ai-msg.ai-bot .ai-bubble { background: #fff; border: 1px solid var(--ai-line); border-top-left-radius: 5px; }
.ai-msg.ai-user .ai-bubble { background: var(--ai-accent); color: #fff; font-weight: 600; border-top-right-radius: 5px; }
.ai-bubble p + p { margin-top: 7px; }
.ai-bubble .ai-note { display: block; margin-top: 7px; font-size: 12px; color: var(--ai-ink-soft); }
.ai-msg.ai-bot .ai-bubble strong { font-weight: 800; }

/* typing indicator */
.ai-dots { display: inline-flex; gap: 4px; align-items: center; height: 12px; }
.ai-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: #c3c8d6; display: block;
  animation: ai-bounce 1s infinite ease-in-out;
}
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-bounce { 0%,60%,100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- result mini cards ---------- */
.ai-results { margin: 2px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.ai-card {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--ai-line); border-radius: 12px; padding: 9px 10px;
  box-shadow: 0 1px 2px rgba(21,25,45,.05);
}
.ai-card:hover { border-color: #ccd3ea; box-shadow: 0 2px 8px rgba(21,25,45,.10); }
.ai-thumb { width: 56px; height: 56px; border-radius: 9px; object-fit: cover; background: #eceef4; display: block; }
.ai-card-body { min-width: 0; }
.ai-card-name {
  font-size: 13.5px; font-weight: 800; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-card-line { font-size: 12px; color: var(--ai-ink-soft); margin-top: 2px; }
.ai-card-line .ai-star { color: var(--star, #f5a623); font-weight: 700; }
.ai-card-line .ai-rate { color: var(--ai-ink); font-weight: 700; }
.ai-card-line .ai-amt { color: var(--ai-ink); font-weight: 800; }
.ai-card-line.ai-dist { color: var(--ai-accent); font-weight: 700; }
.ai-show {
  border: 1px solid var(--ai-line); background: #fff; color: var(--ai-ink);
  font-size: 12px; font-weight: 800; padding: 7px 12px; border-radius: 999px; cursor: pointer;
}
.ai-show:hover { background: var(--ai-accent-soft); border-color: var(--ai-accent-soft); color: var(--ai-accent); }

/* ---------- input ---------- */
.ai-form { flex: none; display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--ai-line); background: #fff; }
.ai-input {
  flex: 1; min-width: 0; resize: none; font: inherit; font-size: 13.5px; line-height: 1.4;
  color: var(--ai-ink); background: #f7f8fb; border: 1px solid var(--ai-line);
  border-radius: 12px; padding: 9px 12px; max-height: 96px; outline: none;
}
.ai-input:focus { border-color: var(--ai-accent); background: #fff; box-shadow: 0 0 0 3px var(--ai-accent-soft); }
.ai-input::placeholder { color: #9aa1b4; }
.ai-send {
  flex: none; width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--ai-accent); color: #fff; display: flex; align-items: center; justify-content: center;
}
.ai-send:hover { background: #2647dc; }
.ai-send:disabled { background: #c3c8d6; cursor: default; }
.ai-send svg { width: 17px; height: 17px; }

.ai-foot {
  flex: none; padding: 8px 14px 11px; font-size: 10.5px; line-height: 1.4;
  color: var(--ai-ink-soft); background: #fff; border-top: 1px solid var(--ai-line);
}

@media (max-width: 900px) {
  .ai-drawer { width: 100%; border-left: none; }
  .ai-launch { right: 14px; bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-drawer, .ai-launch { transition: none; }
  .ai-dots i { animation: none; }
}
