/* TMC Assistant Chat — shared bubble UI */
#tmc-chat-btn {
    position: fixed;
    bottom: 28px;
    right: 22px;
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    background: #0F2D3A;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 0;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(15,45,58,.38);
    transition: transform .18s, box-shadow .18s, background .15s;
    overflow: hidden;
    font-family: var(--tmc-font-main, 'Inter', system-ui, sans-serif);
}
#tmc-chat-btn:hover {
    background: #17485A;
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 10px 32px rgba(15,45,58,.45);
}
#tmc-chat-btn .tmc-chat-pulse {
    position: absolute;
    top: -3px; right: -3px;
    width: 12px; height: 12px;
    background: #22C55E;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: tmcPulse 2s infinite;
}
@keyframes tmcPulse {
    0%,100%{ transform:scale(1);opacity:1; }
    50%     { transform:scale(1.35);opacity:.7; }
}

#tmc-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 22px;
    z-index: 8001;
    width: min(390px, calc(100vw - 32px));
    max-height: 540px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 64px rgba(15,45,58,.22);
    border: 1px solid rgba(15,45,58,.1);
    transform: translateY(18px) scale(.97);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), opacity .2s;
    font-family: var(--tmc-font-main, 'Inter', system-ui, sans-serif);
}
#tmc-chat-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.tmc-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #F1F5F9;
    background: #0F2D3A;
    border-radius: 20px 20px 0 0;
    flex-shrink: 0;
}
.tmc-chat-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 3px;
    box-sizing: border-box;
}
.tmc-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.tmc-chat-header-info { flex: 1; min-width: 0; }
.tmc-chat-header-name { font-size: .87rem; font-weight: 800; color: #fff; }
.tmc-chat-header-sub  { font-size: .71rem; color: rgba(255,255,255,.6); margin-top: 1px; }
.tmc-chat-close {
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}
.tmc-chat-close:hover { background: rgba(255,255,255,.22); }

.tmc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.tmc-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 86%;
    animation: tmcMsgIn .2s ease;
}
@keyframes tmcMsgIn { from{ opacity:0; transform:translateY(6px); } to{ opacity:1; transform:none; } }
.tmc-msg.user { margin-left: auto; flex-direction: row-reverse; }

.tmc-msg-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: .83rem;
    line-height: 1.5;
    max-width: 100%;
    word-break: break-word;
}
.tmc-msg.bot .tmc-msg-bubble {
    background: #F1F5F9;
    color: #1E293B;
    border-bottom-left-radius: 4px;
}
.tmc-msg.user .tmc-msg-bubble {
    background: #0F2D3A;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.tmc-msg-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 2px;
    box-sizing: border-box;
    border: 1px solid rgba(15, 45, 58, 0.08);
}
.tmc-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.tmc-msg-source {
    display: inline-block;
    margin-top: 5px;
    font-size: .71rem;
    color: #0E7490;
    text-decoration: none;
    font-weight: 700;
}
.tmc-msg-source:hover { text-decoration: underline; }

.tmc-chat-typing {
    display: flex; gap: 4px; padding: 10px 13px;
    background: #F1F5F9; border-radius: 16px; border-bottom-left-radius: 4px;
    align-items: center;
}
.tmc-chat-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #94A3B8; animation: tmcDot 1.2s infinite;
}
.tmc-chat-typing span:nth-child(2) { animation-delay: .2s; }
.tmc-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes tmcDot { 0%,80%,100%{ transform:scale(1);opacity:.5; } 40%{ transform:scale(1.3);opacity:1; } }

.tmc-chat-footer {
    padding: 10px 12px 12px;
    border-top: 1px solid #F1F5F9;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}
.tmc-chat-input {
    flex: 1;
    border: 1.5px solid #E2E8F0;
    border-radius: 12px;
    padding: 9px 12px;
    font-size: .83rem;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 38px;
    max-height: 100px;
    line-height: 1.45;
    transition: border-color .15s;
}
.tmc-chat-input:focus { border-color: #0F2D3A; }
.tmc-chat-send {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: #0F2D3A;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .12s;
}
.tmc-chat-send:hover { background: #17485A; transform: scale(1.07); }
.tmc-chat-send:disabled { background: #CBD5E1; cursor: not-allowed; transform: none; }
.tmc-chat-send svg { width: 16px; height: 16px; }

.tmc-chat-clear {
    background: rgba(255,255,255,.1);
    border: none;
    color: rgba(255,255,255,.6);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    flex-shrink: 0;
}
.tmc-chat-clear:hover { background: rgba(255,255,255,.22); }

.tmc-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.tmc-chat-suggestion {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border: 1.5px solid #E2E8F0;
    border-radius: 999px;
    background: #fff;
    color: #0F2D3A;
    font-size: .74rem;
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, border-color .15s, transform .12s;
}
.tmc-chat-suggestion:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
    transform: translateY(-1px);
}

/* Site pages: stay above mobile bottom nav (not camping detail .cd-page) */
@media (max-width: 768px) {
    body:not(:has(.cd-page)) #tmc-chat-btn {
        bottom: 88px;
    }
    body:not(:has(.cd-page)) #tmc-chat-panel {
        bottom: 152px;
        max-height: min(540px, calc(100vh - 168px));
    }
}
