/* =========================================================================
   HotelBuddy AI Search — Chat UI
   Design language: editorial glass · pastel gradient · refined conversation
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── Reset + tokens ─────────────────────────────────────────────────── */
.hbai-wrap *,
.hbai-wrap *::before,
.hbai-wrap *::after { box-sizing: border-box; margin: 0; padding: 0; }

.hbai-wrap {
    --hb-purple:    #7c5cff;
    --hb-pink:      #ff7eb8;
    --hb-teal:      #2bb892;
    --hb-gold:      #ffb347;
    --hb-ink:       #1a1635;
    --hb-ink2:      #3d3660;
    --hb-mute:      #7b729e;
    --hb-glass:     rgba(255, 255, 255, 0.72);
    --hb-glass2:    rgba(255, 255, 255, 0.90);
    --hb-border:    rgba(124, 92, 255, 0.14);
    --hb-shadow:    0 8px 40px -10px rgba(124, 92, 255, 0.18);
    --hb-radius:    20px;
    --hb-radius-sm: 12px;

    font-family: 'DM Sans', system-ui, sans-serif;
    color: var(--hb-ink);
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 80vh;
    background: linear-gradient(145deg,
        rgba(255,210,230,0.35) 0%,
        rgba(210,210,255,0.30) 35%,
        rgba(200,240,255,0.30) 70%,
        rgba(200,255,235,0.25) 100%);
    border-radius: var(--hb-radius);
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        var(--hb-shadow);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.6);
}

/* ── Header ─────────────────────────────────────────────────────────── */
.hbai-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 24px 20px;
    border-bottom: 1px solid var(--hb-border);
    background: var(--hb-glass2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.hbai-header__icon svg {
    width: 42px; height: 42px;
    filter: drop-shadow(0 4px 12px rgba(124,92,255,0.35));
}
.hbai-header__text { flex: 1; }
.hbai-header__text h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 18px; font-weight: 600;
    color: var(--hb-ink);
    line-height: 1.2;
}
.hbai-header__text p {
    font-size: 13px; color: var(--hb-mute);
    margin-top: 2px;
}
.hbai-header__clear {
    background: transparent; border: 0;
    color: var(--hb-mute); cursor: pointer;
    padding: 8px; border-radius: 10px;
    transition: all .15s ease;
    display: flex; align-items: center;
}
.hbai-header__clear:hover { background: rgba(124,92,255,.1); color: var(--hb-purple); }

/* ── Suggestions ────────────────────────────────────────────────────── */
.hbai-suggestions {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--hb-border);
    transition: opacity .3s ease, max-height .3s ease;
    overflow: hidden;
}
.hbai-suggestions.is-hidden {
    opacity: 0; max-height: 0;
    padding-top: 0; padding-bottom: 0;
    pointer-events: none;
}
.hbai-suggestion {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--hb-glass2); border: 1px solid var(--hb-border);
    border-radius: 30px; padding: 8px 14px;
    font-family: inherit; font-size: 13px; font-weight: 500;
    color: var(--hb-ink2); cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
}
.hbai-suggestion:hover {
    background: var(--hb-purple); color: #fff;
    border-color: var(--hb-purple);
    box-shadow: 0 4px 14px -3px rgba(124,92,255,0.4);
    transform: translateY(-1px);
}
.hbai-suggestion__icon { font-size: 15px; }

/* ── Thread ─────────────────────────────────────────────────────────── */
.hbai-thread {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
    min-height: 200px;
}
.hbai-thread:empty::after {
    content: '';
    display: none;
}

/* ── Messages ───────────────────────────────────────────────────────── */
.hbai-msg {
    display: flex;
    gap: 12px;
    animation: hbai-slide-in .25s ease both;
}
@keyframes hbai-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hbai-msg--user { flex-direction: row-reverse; }

.hbai-msg__avatar {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.hbai-msg--user   .hbai-msg__avatar {
    background: linear-gradient(135deg, var(--hb-purple), var(--hb-pink));
    color: #fff; font-weight: 700; font-size: 13px;
    box-shadow: 0 4px 12px -3px rgba(124,92,255,0.4);
}
.hbai-msg--ai .hbai-msg__avatar {
    background: rgba(255,255,255,0.85);
    border: 1px solid var(--hb-border);
}

.hbai-msg__body { max-width: 78%; display: flex; flex-direction: column; gap: 10px; }

.hbai-msg__bubble {
    padding: 14px 18px;
    border-radius: var(--hb-radius-sm);
    font-size: 14.5px; line-height: 1.65;
    word-break: break-word;
}
.hbai-msg--user .hbai-msg__bubble {
    background: linear-gradient(135deg, var(--hb-purple), var(--hb-pink));
    color: #fff;
    border-radius: var(--hb-radius-sm) var(--hb-radius-sm) 4px var(--hb-radius-sm);
    box-shadow: 0 4px 16px -4px rgba(124,92,255,0.4);
}
.hbai-msg--ai .hbai-msg__bubble {
    background: var(--hb-glass2);
    border: 1px solid var(--hb-border);
    border-radius: 4px var(--hb-radius-sm) var(--hb-radius-sm) var(--hb-radius-sm);
    box-shadow: 0 2px 12px -4px rgba(124,92,255,0.1);
    color: var(--hb-ink);
}

/* Markdown-like inside AI bubbles */
.hbai-msg--ai .hbai-msg__bubble strong { font-weight: 600; color: var(--hb-purple); }
.hbai-msg--ai .hbai-msg__bubble a { color: var(--hb-purple); text-decoration: underline; }
.hbai-msg--ai .hbai-msg__bubble p + p { margin-top: 8px; }

/* ── Result cards ───────────────────────────────────────────────────── */
.hbai-cards {
    display: flex; flex-direction: column; gap: 10px;
    width: 100%;
}
.hbai-card {
    background: var(--hb-glass2);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-sm);
    overflow: hidden;
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 0;
    transition: all .18s ease;
    text-decoration: none; color: inherit;
    animation: hbai-card-in .3s ease both;
}
@keyframes hbai-card-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
.hbai-card:hover {
    border-color: rgba(124,92,255,0.35);
    box-shadow: 0 6px 24px -6px rgba(124,92,255,0.2);
    transform: translateY(-1px);
}
.hbai-card--featured { border-color: rgba(255,179,71,0.5); }
.hbai-card__img {
    width: 90px; height: 90px;
    object-fit: cover;
    display: block;
    background: linear-gradient(135deg, #e8eaff, #fef3f0);
}
.hbai-card__img-placeholder {
    width: 90px; height: 90px;
    background: linear-gradient(135deg, #e8eaff, #fef3f0);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
}
.hbai-card__body {
    padding: 10px 14px;
    display: flex; flex-direction: column; gap: 4px;
}
.hbai-card__top {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.hbai-card__name {
    font-family: 'Playfair Display', serif;
    font-size: 14px; font-weight: 500;
    color: var(--hb-ink); line-height: 1.25;
}
.hbai-card__price {
    font-size: 13px; font-weight: 700;
    color: var(--hb-purple); white-space: nowrap;
}
.hbai-card__price--save {
    color: var(--hb-teal);
    font-size: 11px; font-weight: 600;
    background: rgba(43,184,146,0.1);
    padding: 1px 6px; border-radius: 8px;
}
.hbai-card__sub {
    font-size: 12px; color: var(--hb-mute);
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.hbai-card__pill {
    font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: 10px;
    letter-spacing: 0.03em; text-transform: uppercase;
}
.hbai-card__pill--deal    { background: linear-gradient(135deg, var(--hb-teal), #2ee8b5); color: #fff; }
.hbai-card__pill--offer   { background: linear-gradient(135deg, var(--hb-pink), #ff5eab); color: #fff; }
.hbai-card__pill--feat    { background: linear-gradient(135deg, var(--hb-gold), #ff8c00); color: #fff; }
.hbai-card__cta {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 600; color: var(--hb-purple);
    margin-top: 4px; text-decoration: none;
}
.hbai-card__cta:hover { text-decoration: underline; }

/* ── Thinking indicator ─────────────────────────────────────────────── */
.hbai-thinking {
    display: flex; align-items: center; gap: 10px;
    padding: 0 24px 12px;
}
.hbai-thinking[hidden] { display: none; }
.hbai-thinking__dots {
    display: flex; gap: 4px;
}
.hbai-thinking__dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--hb-purple);
    opacity: 0.35;
    animation: hbai-blink 1.2s infinite;
}
.hbai-thinking__dots span:nth-child(2) { animation-delay: .2s; }
.hbai-thinking__dots span:nth-child(3) { animation-delay: .4s; }
@keyframes hbai-blink {
    0%, 80%, 100% { opacity: 0.25; transform: scale(1); }
    40% { opacity: 1; transform: scale(1.3); }
}
.hbai-thinking__label {
    font-size: 12px; color: var(--hb-mute); font-style: italic;
}

/* ── Input form ─────────────────────────────────────────────────────── */
.hbai-form {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--hb-border);
    background: var(--hb-glass2);
}
.hbai-input-wrap {
    display: flex; gap: 10px; align-items: flex-end;
    background: rgba(255,255,255,0.85);
    border: 1.5px solid var(--hb-border);
    border-radius: 16px;
    padding: 10px 10px 10px 16px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.hbai-input-wrap:focus-within {
    border-color: var(--hb-purple);
    box-shadow: 0 0 0 3px rgba(124,92,255,0.12);
}
.hbai-input {
    flex: 1; border: 0; background: transparent;
    font-family: inherit; font-size: 14px; color: var(--hb-ink);
    resize: none; outline: none; max-height: 120px;
    overflow-y: auto; line-height: 1.55;
}
.hbai-input::placeholder { color: var(--hb-mute); }
.hbai-send {
    width: 40px; height: 40px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--hb-purple), var(--hb-pink));
    border: 0; border-radius: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    transition: all .15s ease;
    box-shadow: 0 4px 14px -4px rgba(124,92,255,0.5);
}
.hbai-send:hover { transform: scale(1.07); box-shadow: 0 6px 20px -4px rgba(124,92,255,0.55); }
.hbai-send:active { transform: scale(0.97); }
.hbai-send:disabled { opacity: 0.5; cursor: default; transform: none; }
.hbai-form__hint {
    font-size: 11px; color: var(--hb-mute);
    text-align: center; margin-top: 10px;
}

/* ── Error state ─────────────────────────────────────────────────────── */
.hbai-msg__bubble--error {
    background: rgba(220,50,50,0.08);
    border-color: rgba(220,50,50,0.2);
    color: #b91c1c;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .hbai-wrap { border-radius: 16px; }
    .hbai-header { padding: 16px; }
    .hbai-thread { padding: 14px 14px; }
    .hbai-suggestions { padding: 14px; gap: 6px; }
    .hbai-suggestion { font-size: 12px; padding: 6px 11px; }
    .hbai-form { padding: 12px 14px 16px; }
    .hbai-card { grid-template-columns: 72px 1fr; }
    .hbai-card__img,
    .hbai-card__img-placeholder { width: 72px; height: 72px; }
    .hbai-msg__body { max-width: 90%; }
}
