/* ==========================================================================
   Chatbot widget — floating bubble + slide-up panel
   ========================================================================== */

#chatbot-toggle {
    position: fixed;
    bottom: 62px; /* clears the 37px news ticker + 25px breathing room */
    right: 28px;
    z-index: 9999; /* always above everything including ticker, header, overlays */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.15); /* subtle ring for visibility on dark bg */
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(76, 154, 255, 0.55), 0 0 0 0 rgba(76, 154, 255, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(76, 154, 255, 0.6);
}

#chatbot-toggle svg { pointer-events: none; }

/* Window */
#chatbot-window {
    position: fixed;
    bottom: 130px; /* toggle bottom(62) + toggle height(56) + 12px gap */
    right: 28px;
    z-index: 9998;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* hidden by default */
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#chatbot-window.chatbot-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--surface-color-dark);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.chatbot-header-title h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--heading-color);
}

.chatbot-header-title p {
    margin: 0;
    font-size: 0.72rem;
    color: var(--success-color);
}

#chatbot-close {
    background: none;
    border: none;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

#chatbot-close:hover {
    color: var(--heading-color);
    background: var(--border-color);
}

/* Messages */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.chatbot-msg {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chatbot-msg--user {
    align-self: flex-end;
    background: var(--primary-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot-msg--bot {
    align-self: flex-start;
    background: var(--surface-color-dark);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.chatbot-msg--typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}

.chatbot-msg--typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--secondary-color);
    animation: chatbot-bounce 1.2s infinite ease-in-out;
}

.chatbot-msg--typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-msg--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbot-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%            { transform: scale(1);   opacity: 1;   }
}

/* Input area */
#chatbot-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color-dark);
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 0.875rem;
    font-family: inherit;
    padding: 9px 13px;
    outline: none;
    resize: none;
    transition: border-color 0.2s;
}

#chatbot-input:focus { border-color: var(--primary-color); }
#chatbot-input::placeholder { color: var(--secondary-color); }

#chatbot-send {
    background: var(--primary-color);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

#chatbot-send:hover  { background: #3a87f0; }
#chatbot-send:active { transform: scale(0.95); }
#chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Mobile */
@media (max-width: 480px) {
    #chatbot-window {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 70vh;
        border-radius: 16px 16px 0 0;
    }

    #chatbot-toggle {
        bottom: 56px; /* clears ticker on small screens */
        right: 16px;
    }

    #chatbot-window {
        bottom: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
    }
}
