/* ====================================================
   EGE AI CHATBOT WIDGET
   ==================================================== */

/* --- Toggle Button --- */
#chatbot-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0061f2 0%, #6610f2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0, 97, 242, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 9998;
    transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), box-shadow 0.3s;
}
#chatbot-toggle-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 10px 32px rgba(0, 97, 242, 0.55);
}
#chatbot-toggle-btn .cb-icon-chat,
#chatbot-toggle-btn .cb-icon-close {
    position: absolute;
    transition: opacity 0.25s, transform 0.25s;
}
#chatbot-toggle-btn .cb-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}
#chatbot-toggle-btn.is-open .cb-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}
#chatbot-toggle-btn.is-open .cb-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Notification badge */
#chatbot-toggle-btn .cb-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: cb-pulse 1.8s infinite;
}
@keyframes cb-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.25); }
}

/* --- Chat Window --- */
#chatbot-window {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 130px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transform: scale(0.85) translateY(30px);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: opacity 0.3s cubic-bezier(.4,0,.2,1),
                transform 0.3s cubic-bezier(.34,1.4,.64,1);
}
#chatbot-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* --- Header --- */
#chatbot-header {
    background: linear-gradient(135deg, #0061f2 0%, #6610f2 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
#chatbot-header .cb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
#chatbot-header .cb-info h6 {
    margin: 0;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
}
#chatbot-header .cb-info span {
    font-size: 0.75rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}
#chatbot-header .cb-status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}
#chatbot-clear-btn {
    margin-left: auto;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s;
    flex-shrink: 0;
}
#chatbot-clear-btn:hover {
    background: rgba(255,255,255,0.28);
}

/* --- Messages Area --- */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f7f8fc;
    scroll-behavior: smooth;
}
#chatbot-messages::-webkit-scrollbar { width: 5px; }
#chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#chatbot-messages::-webkit-scrollbar-thumb { background: #cdd0e0; border-radius: 10px; }

/* Message bubbles */
.cb-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: cb-slide-in 0.3s cubic-bezier(.4,0,.2,1);
}
@keyframes cb-slide-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cb-msg.cb-user {
    flex-direction: row-reverse;
}
.cb-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.cb-msg.cb-bot .cb-bubble {
    background: #ffffff;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.cb-msg.cb-user .cb-bubble {
    background: linear-gradient(135deg, #0061f2, #6610f2);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cb-msg-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.cb-msg.cb-bot .cb-msg-icon  { background: #e8edff; color: #0061f2; }
.cb-msg.cb-user .cb-msg-icon { background: #6610f2; color: #fff; }

/* Typing indicator */
.cb-typing .cb-bubble {
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}
.cb-typing-dot {
    width: 7px;
    height: 7px;
    background: #a0aec0;
    border-radius: 50%;
    animation: cb-bounce 1.3s infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes cb-bounce {
    0%, 80%, 100% { transform: translateY(0);    opacity: 0.5; }
    40%            { transform: translateY(-6px); opacity: 1;   }
}

/* Welcome message */
.cb-welcome {
    text-align: center;
    padding: 12px;
    color: #718096;
    font-size: 0.8rem;
}
.cb-welcome strong {
    display: block;
    font-size: 1rem;
    color: #2d3748;
    margin-bottom: 4px;
}

/* --- Input Area --- */
#chatbot-input-area {
    padding: 14px 16px;
    background: #ffffff;
    border-top: 1px solid #edf0f7;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}
#chatbot-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 0.875rem;
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.5;
    transition: border-color 0.2s;
    font-family: inherit;
}
#chatbot-input:focus { border-color: #0061f2; }
#chatbot-input::placeholder { color: #a0aec0; }
#chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0061f2 0%, #6610f2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
    box-shadow: 0 4px 12px rgba(0,97,242,0.35);
}
#chatbot-send-btn:hover:not(:disabled) { transform: scale(1.1); }
#chatbot-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* --- Error message --- */
.cb-error .cb-bubble {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    #chatbot-window {
        right: 10px;
        bottom: 90px;
        width: calc(100vw - 20px);
    }
    #chatbot-toggle-btn {
        right: 16px;
        bottom: 20px;
    }
}
