/* =============================================
   AI CHATBOT — Native Chat UI
   ============================================= */

.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Poppins', sans-serif;
}

/* --- Toggle button --- */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #420177, #6f42c1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 20px rgba(66, 1, 119, 0.4);
    position: relative;
    user-select: none;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(66, 1, 119, 0.55);
}

.chatbot-toggle i {
    color: #fff;
    font-size: 24px;
    animation: pulse 2.5s infinite;
}

.chatbot-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: #1a1a2e;
    color: #fff;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
    text-transform: none;
}

.chatbot-tooltip::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1a1a2e;
}

.chatbot-toggle:hover .chatbot-tooltip {
    opacity: 1;
    visibility: visible;
}

/* --- Chat window --- */
.chatbot-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(66, 1, 119, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(16px);
    opacity: 0;
    visibility: hidden;
    transform-origin: bottom right;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.2s ease,
                visibility 0.2s ease;
}

.chatbot-window.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* --- Header --- */
.chatbot-header {
    background: linear-gradient(135deg, #420177, #6f42c1);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

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

.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bot-content-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    max-width: 78%;
}

.bot-content-col .message-bubble {
    max-width: 100%;
}

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

.chatbot-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-transform: none;
}

.chatbot-status {
    font-size: 10px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: none;
}

.chatbot-status i {
    font-size: 7px;
    color: #4dff91;
    animation: statusPulse 2.5s infinite;
}

.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Messages --- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(66, 1, 119, 0.25);
    border-radius: 4px;
}

.chat-message {
    display: flex;
    align-items: flex-end;
    max-width: 100%;
}

.chat-message.user-message {
    flex-direction: row-reverse;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 78%;
    word-break: break-word;
    text-transform: none;
}

.bot-message .message-bubble {
    background: #f1f0f6;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #420177, #6f42c1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-bubble.streaming::after {
    content: '▋';
    animation: cursorBlink 0.7s step-end infinite;
    font-size: 11px;
    margin-left: 2px;
    color: #420177;
}

.user-message .message-bubble.streaming::after {
    color: rgba(255, 255, 255, 0.7);
}

/* --- Markdown inside bot bubbles --- */
.bot-message .message-bubble h1,
.bot-message .message-bubble h2,
.bot-message .message-bubble h3 {
    font-size: 13px;
    font-weight: 700;
    margin: 8px 0 4px;
    color: #1a1a2e;
    text-transform: none;
}

.bot-message .message-bubble p {
    margin: 4px 0;
    text-transform: none;
}

.bot-message .message-bubble ul,
.bot-message .message-bubble ol {
    padding-left: 16px;
    margin: 4px 0;
}

.bot-message .message-bubble li {
    margin: 2px 0;
    text-transform: none;
}

.bot-message .message-bubble strong {
    font-weight: 600;
    color: #420177;
}

.bot-message .message-bubble a {
    color: #420177;
    text-decoration: underline;
    word-break: break-all;
    font-weight: 500;
    transition: opacity 0.2s;
}

.bot-message .message-bubble a:hover {
    opacity: 0.75;
}

.bot-message .message-bubble hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 8px 0;
}

.bot-message .message-bubble code {
    background: #e8e4f0;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 11px;
    font-family: monospace;
}

/* --- Typing indicator --- */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px 4px;
    flex-shrink: 0;
}

.chatbot-typing.hidden { display: none; }

.chatbot-typing span {
    width: 7px;
    height: 7px;
    background: #420177;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}

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

/* --- Contact CTA button --- */
.chatbot-contact-cta {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #420177, #6f42c1);
    color: #fff;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    text-transform: none;
    transition: opacity 0.2s ease, transform 0.15s ease;
    cursor: pointer;
}

.chatbot-contact-cta:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}

/* --- Suggestion chips --- */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 14px 8px;
    flex-shrink: 0;
}

.chip {
    background: #f1f0f6;
    color: #420177;
    border: 1px solid rgba(66, 1, 119, 0.2);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11px;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
    text-transform: none;
    white-space: nowrap;
}

.chip:hover {
    background: #420177;
    color: #fff;
    transform: translateY(-1px);
}

/* --- Input area --- */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    min-width: 0;
    background: #fff;
}

#chatbot-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    border: 1.5px solid #e0e0e0;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 13px;
    font-family: 'Poppins', sans-serif;
    color: #1a1a2e;
    background: #fafafa;
    transition: border-color 0.2s ease;
    text-transform: none;
}

#chatbot-input:focus {
    border-color: #420177;
    background: #fff;
    outline: none;
}

#chatbot-input::placeholder {
    color: #aaa;
    text-transform: none;
}

.chatbot-send {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    background: linear-gradient(135deg, #420177, #6f42c1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(66, 1, 119, 0.35);
}

.chatbot-send:disabled {
    opacity: 0.5;
    transform: none;
    cursor: not-allowed;
}

/* --- Animations --- */
@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.12); }
}

/* --- Mobile --- */
@media (max-width: 768px) {
    .chatbot-window {
        width: 320px;
        height: 470px;
        right: -5px;
    }
    .chatbot-tooltip { display: none; }
}

@media (max-width: 480px) {
    .chatbot-container { bottom: 16px; right: 16px; }

    .chatbot-window {
        position: fixed;
        bottom: 86px;
        left: 16px;
        right: 16px;
        width: auto;
        height: 420px;
        max-height: 65vh;
        border-radius: 16px;
        transform: scale(0.9) translateY(16px);
        transform-origin: bottom right;
    }

    .chatbot-window.active {
        transform: scale(1) translateY(0);
    }

    .chatbot-input-area {
        gap: 6px;
        padding: 10px;
    }

    #chatbot-input {
        padding: 9px 14px;
    }

    .chatbot-suggestions { display: none; }
}
