/* ==========================================================================
   Trip assistant — floating widget
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chat-widget {
    position: fixed;
    right: 18px;
    bottom: 78px;
    z-index: 90;
    font-family: var(--font-body);
}

.chat-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 54px;
    padding: 12px 20px 12px 16px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    background: linear-gradient(135deg, var(--gold-soft), var(--gold));
    color: #1A1408;
    font: inherit;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .01em;
    cursor: pointer;
    box-shadow: var(--shadow-gold), 0 10px 30px rgba(0, 0, 0, .35);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}

.chat-toggle:hover { transform: translateY(-2px); box-shadow: 0 22px 48px rgba(216, 180, 91, .28), 0 14px 34px rgba(0, 0, 0, .4); }
.chat-toggle:focus-visible { outline: 2px solid var(--ivory); outline-offset: 3px; }
.chat-toggle .icon { flex: none; }

.chat-widget.is-open .chat-toggle {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.chat-toggle__ping {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #1E7B45;
    border: 2px solid var(--gold-soft);
}

.chat-panel {
    position: fixed;
    right: 18px;
    bottom: 146px;
    display: flex;
    flex-direction: column;
    width: min(384px, calc(100vw - 36px));
    max-height: min(640px, calc(100dvh - 180px));
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    background: rgba(10, 16, 23, .96);
    color: var(--ivory);
    box-shadow: 0 34px 90px rgba(0, 0, 0, .62);
    overflow: hidden;
    opacity: 0;
    transform: translateY(14px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .22s var(--ease), transform .22s var(--ease);
    backdrop-filter: blur(18px);
}

.chat-panel[hidden] { display: none; }
.chat-panel.is-open { opacity: 1; transform: none; }

.chat-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    border-bottom: 1px solid var(--line);
    background:
        radial-gradient(120% 160% at 0% 0%, rgba(216, 180, 91, .16), transparent 55%),
        var(--raised);
}

.chat-panel__identity { display: flex; align-items: center; gap: 11px; min-width: 0; }

.chat-panel__avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 12px;
    background: linear-gradient(140deg, var(--gold-soft), var(--gold-deep));
    color: #171105;
    font-family: var(--font-display);
    font-size: .86rem;
    font-weight: 800;
}

.chat-panel__who { display: grid; gap: 2px; min-width: 0; }
.chat-panel__who strong { font-size: .88rem; line-height: 1.2; }
.chat-panel__who span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: .67rem;
    letter-spacing: .02em;
}

.chat-panel__online {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(83, 212, 131, .14);
}

.chat-panel__close {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, .03);
    color: var(--muted);
    cursor: pointer;
    transition: color .18s, border-color .18s;
}
.chat-panel__close:hover { color: var(--ivory); border-color: var(--line-strong); }

.chat-log {
    flex: 1;
    min-height: 180px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(216, 180, 91, .35) transparent;
}
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: rgba(216, 180, 91, .28); border-radius: 99px; }

.chat-msg { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.chat-msg--bot { justify-content: flex-start; }
.chat-msg--user { justify-content: flex-end; align-items: flex-end; }

.chat-msg__bubble {
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 15px;
    font-size: .8rem;
    line-height: 1.62;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.chat-msg--bot .chat-msg__bubble {
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom-left-radius: 5px;
    color: #E8EDF3;
}

.chat-msg--user .chat-msg__bubble {
    background: linear-gradient(135deg, rgba(216, 180, 91, .94), rgba(169, 134, 52, .95));
    border-bottom-right-radius: 5px;
    color: #191305;
    font-weight: 600;
}

.chat-msg__links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 88%;
}

.chat-msg__link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border: 1px solid rgba(216, 180, 91, .32);
    border-radius: 999px;
    background: rgba(216, 180, 91, .08);
    color: var(--gold-soft);
    font-size: .69rem;
    font-weight: 700;
    text-decoration: none;
    transition: background .18s, border-color .18s;
}
.chat-msg__link:hover { background: rgba(216, 180, 91, .16); border-color: rgba(216, 180, 91, .55); }

.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0 4px;
}

.chat-chip {
    padding: 7px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, .035);
    color: var(--ivory);
    font: inherit;
    font-size: .7rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color .18s, background .18s, color .18s;
}
.chat-chip:hover { border-color: rgba(216, 180, 91, .5); background: rgba(216, 180, 91, .1); color: var(--gold-soft); }

.chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 15px;
    border-bottom-left-radius: 5px;
    background: var(--surface);
}
.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    animation: chat-blink 1.1s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .16s; }
.chat-typing span:nth-child(3) { animation-delay: .32s; }

@keyframes chat-blink {
    0%, 70%, 100% { opacity: .28; transform: translateY(0); }
    35% { opacity: 1; transform: translateY(-3px); }
}

.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .018);
}

.chat-form__input {
    flex: 1;
    min-height: 40px;
    max-height: 104px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--night);
    color: var(--ivory);
    font: inherit;
    font-size: .8rem;
    line-height: 1.45;
    resize: none;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}
.chat-form__input::placeholder { color: var(--muted-2); }
.chat-form__input:focus { border-color: rgba(216, 180, 91, .55); box-shadow: 0 0 0 3px rgba(216, 180, 91, .12); }

.chat-form__send {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--gold-soft), var(--gold));
    color: #191305;
    cursor: pointer;
    transition: transform .18s var(--ease), filter .18s;
}
.chat-form__send:hover { transform: translateY(-1px); filter: brightness(1.04); }
.chat-form__send:disabled { opacity: .5; cursor: wait; transform: none; }

.chat-panel__note {
    margin: 0;
    padding: 0 14px 12px;
    color: var(--muted-2);
    font-size: .62rem;
    line-height: 1.5;
    background: rgba(255, 255, 255, .018);
}

@media (max-width: 640px) {
    .chat-widget { right: 14px; bottom: calc(64px + env(safe-area-inset-bottom)); }

    .chat-toggle { min-height: 50px; padding: 11px 15px; }
    .chat-toggle__label { font-size: .76rem; }

    .chat-panel {
        right: 8px;
        left: 8px;
        top: 10px;
        bottom: calc(74px + env(safe-area-inset-bottom));
        width: auto;
        max-height: none;
        border-radius: 18px;
        transform-origin: bottom center;
    }

    .chat-log { min-height: 0; }

    .to-top { bottom: calc(132px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    .chat-panel, .chat-toggle, .chat-chip, .chat-form__send { transition: none; }
    .chat-typing span { animation: none; opacity: .7; }
}
