/* ============================================================
   KL Travel Concierge Chatbot — assets/css/chatbot.css
   ============================================================ */

/* ── Floating trigger button ── */
#kltg-chat-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    width: 68px;
    height: 68px;
    touch-action: none;
}

#kltg-chat-btn {
    width: 68px;
    height: 68px;
    border-radius: 0;
    overflow: visible;
    cursor: grab;
    border: none;
    padding: 0;
    background: none;
    display: block;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    -webkit-user-drag: none;
    user-select: none;
}

#kltg-chat-btn:active { cursor: grabbing; }

#kltg-chat-btn img,
#kltg-chat-btn canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: block;
    filter: drop-shadow(0 6px 18px rgba(0,0,0,0.4));
    -webkit-user-drag: none;
    user-select: none;
    transition: filter 0.2s;
}

#kltg-chat-btn:hover img,
#kltg-chat-btn:hover canvas {
    filter: drop-shadow(0 8px 22px rgba(14,162,189,0.55));
}

/* Idle bob — paused while dragging (.dragging) or open */
#kltg-chat-btn {
    animation: kltg-bob 3.5s ease-in-out infinite;
}
#kltg-chat-widget.open #kltg-chat-btn,
#kltg-chat-widget.dragging #kltg-chat-btn {
    animation: none;
}

@keyframes kltg-bob {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-6px); }
}

/* ── Unread badge ── */
#kltg-chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 18px;
    height: 18px;
    background: #e53935;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    pointer-events: none;
}

/* ── Chat popup — position set dynamically by JS ── */
#kltg-chat-popup {
    position: fixed;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 60px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1), opacity 0.22s ease;
}

#kltg-chat-popup.visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ── */
#kltg-chat-header {
    background: linear-gradient(135deg, #0d2137 0%, #0ea2bd 100%);
    color: #fff;
    padding: 14px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#kltg-chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
}

#kltg-chat-header-info {
    flex: 1;
    min-width: 0;
}

#kltg-chat-header-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.2px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#kltg-chat-header-info span {
    font-size: 11px;
    opacity: 0.8;
    color: #c8f0f7;
}

#kltg-chat-header-status {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    margin-right: -2px;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(76,175,80,0.3);
}

#kltg-chat-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    line-height: 1;
}
#kltg-chat-close:hover { background: rgba(255,255,255,0.28); }

/* ── Messages area ── */
#kltg-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: #f7f9fb;
}

#kltg-chat-messages::-webkit-scrollbar { width: 4px; }
#kltg-chat-messages::-webkit-scrollbar-track { background: transparent; }
#kltg-chat-messages::-webkit-scrollbar-thumb { background: #cdd8e0; border-radius: 4px; }

/* ── Persistent quick-actions bar ── */
#kltg-quick-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: #f0f7f9;
    border-top: 1px solid #dde8ec;
    border-bottom: 1px solid #dde8ec;
    flex-shrink: 0;
}

.kltg-quick-btn {  
    background: #fff;
    border: 1.5px solid #0ea2bd;
    color: #0ea2bd;
    font-size: 11.5px;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    transition: background 0.18s, color 0.18s, transform 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.kltg-quick-btn:hover {
    background: #0ea2bd;
    color: #fff;
    transform: translateY(-1px);
}

/* ── Message bubbles ── */
.kltg-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

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

.kltg-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    align-self: flex-end;
}

.kltg-msg-bubble {
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    font-family: 'Open Sans', sans-serif;
    word-break: break-word;
}

.kltg-msg.bot .kltg-msg-bubble {
    background: #fff;
    color: #1a1f24;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.kltg-msg.user .kltg-msg-bubble {
    background: linear-gradient(135deg, #0ea2bd, #0189a1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Markdown-style formatting in bot messages */
.kltg-msg-bubble p        { margin: 0 0 6px; }
.kltg-msg-bubble p:last-child { margin-bottom: 0; }
.kltg-msg-bubble ul, .kltg-msg-bubble ol { margin: 4px 0 6px; padding-left: 18px; }
.kltg-msg-bubble li       { margin-bottom: 3px; }
.kltg-msg-bubble strong   { font-weight: 700; }
.kltg-msg-bubble a        { color: #0ea2bd; text-decoration: underline; }
.kltg-msg-bubble h3, .kltg-msg-bubble h4 { font-size: 13.5px; font-weight: 700; margin: 6px 0 3px; }

/* ── Typing indicator ── */
.kltg-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    width: fit-content;
}
.kltg-typing span {
    width: 7px;
    height: 7px;
    background: #0ea2bd;
    border-radius: 50%;
    animation: kltg-blink 1.2s ease-in-out infinite;
}
.kltg-typing span:nth-child(2) { animation-delay: 0.2s; }
.kltg-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes kltg-blink {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
    40%            { opacity: 1;    transform: scale(1); }
}

/* ── Input bar ── */
#kltg-chat-input-area {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e8edf0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#kltg-chat-input {
    flex: 1;
    border: 1.5px solid #dde3e8;
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-family: 'Open Sans', sans-serif;
    outline: none;
    resize: none;
    background: #f7f9fb;
    color: #1a1f24;
    transition: border-color 0.2s;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.45;
}
#kltg-chat-input:focus { border-color: #0ea2bd; background: #fff; }
#kltg-chat-input::placeholder { color: #aab4bc; }

#kltg-chat-send {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #0ea2bd, #0189a1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(14,162,189,0.4);
}
#kltg-chat-send:hover { transform: scale(1.08); box-shadow: 0 4px 14px rgba(14,162,189,0.5); }
#kltg-chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
#kltg-chat-send svg { width: 17px; height: 17px; fill: #fff; }

/* ── Powered-by footer ── */
#kltg-chat-powered {
    text-align: center;
    font-size: 10.5px;
    color: #aab4bc;
    padding: 5px 0 7px;
    font-family: 'Open Sans', sans-serif;
    background: #fff;
    flex-shrink: 0;
}
#kltg-chat-powered a { color: #0ea2bd; text-decoration: none; }

/* ── Mobile ── */
@media (max-width: 480px) {
    #kltg-chat-popup {
        right: 12px;
        bottom: 98px;
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
        max-height: none;
    }
    #kltg-chat-widget { right: 16px; bottom: 20px; }
}
