/* BeGenius floating chatbot — self-contained critical layout (no Tailwind dependency) */
#begenius-chatbot-root {
    font-family: inherit;
    z-index: 9999;
    position: relative;
}

#chatbot-bubble {
    position: fixed !important;
    bottom: 1.5rem !important;
    right: 1.5rem !important;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: #fff;
    box-shadow: 0 20px 40px rgba(67, 56, 202, 0.35);
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999 !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: chatbotPulse 2.4s ease-in-out infinite;
}

#begenius-chatbot-root.rtl #chatbot-bubble {
    right: auto !important;
    left: 1.5rem !important;
}

#chatbot-bubble:hover {
    transform: scale(1.06);
    box-shadow: 0 24px 48px rgba(67, 56, 202, 0.45);
}

#chatbot-bubble:active {
    transform: scale(0.96);
}

#chatbot-bubble.hidden {
    display: none !important;
}

#chatbot-bubble .chatbot-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 0.75rem;
    height: 0.75rem;
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 9999px;
}

#chatbot-panel {
    position: fixed !important;
    bottom: 6rem !important;
    right: 1.5rem !important;
    width: 380px;
    max-width: calc(100vw - 2rem);
    height: 500px;
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(226, 232, 240, 0.8);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999 !important;
    opacity: 0;
    transform: scale(0.94) translateY(12px);
}

#begenius-chatbot-root.rtl #chatbot-panel {
    right: auto !important;
    left: 1.5rem !important;
}

#chatbot-panel.active {
    display: flex !important;
    animation: slideUpChat 0.28s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

#chatbot-panel-header {
    background: linear-gradient(90deg, #4f46e5 0%, #4338ca 100%);
    color: #fff;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#chatbot-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: rgba(248, 250, 252, 0.7);
    font-size: 0.75rem;
}

#chatbot-messages .msg-row {
    display: flex;
    margin-bottom: 0.75rem;
}

#chatbot-messages .msg-row.user {
    justify-content: flex-end;
}

#chatbot-messages .msg-row.bot {
    justify-content: flex-start;
}

#chatbot-messages .msg-bubble {
    max-width: 80%;
    border-radius: 1rem;
    padding: 0.625rem 1rem;
    line-height: 1.5;
    font-weight: 500;
    white-space: pre-line;
}

#chatbot-messages .msg-bubble.user {
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 0;
}

#chatbot-messages .msg-bubble.bot {
    background: #fff;
    color: #1e293b;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-bottom-left-radius: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

#chatbot-messages .msg-bubble.bot a {
    color: #4f46e5;
    text-decoration: underline;
    font-weight: 700;
}

#chatbot-typing {
    display: none;
    padding: 0.5rem 1.25rem;
    font-size: 10px;
    color: #94a3b8;
    font-weight: 600;
    align-items: center;
    gap: 0.5rem;
}

#chatbot-typing.show {
    display: flex;
}

#chatbot-form {
    padding: 0.75rem;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    background: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.75rem;
    background: #f8fafc;
    resize: none;
    max-height: 4rem;
    outline: none;
    font-family: inherit;
}

#chatbot-input:focus {
    background: #fff;
    border-color: #6366f1;
}

#chatbot-send {
    width: 2.25rem;
    height: 2.25rem;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

#chatbot-send:hover {
    background: #4338ca;
    transform: scale(1.05);
}

#chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#chatbot-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    padding: 0.25rem;
}

#chatbot-close:hover {
    color: #fff;
}

@keyframes slideUpChat {
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes chatbotPulse {
    0%, 100% {
        box-shadow: 0 20px 40px rgba(67, 56, 202, 0.35);
    }
    50% {
        box-shadow: 0 20px 40px rgba(67, 56, 202, 0.55), 0 0 0 8px rgba(99, 102, 241, 0.15);
    }
}

@media (max-width: 480px) {
    #chatbot-panel {
        width: calc(100vw - 1rem);
        right: 0.5rem !important;
        left: 0.5rem !important;
        bottom: 5.5rem !important;
        height: min(70vh, 520px);
    }

    #chatbot-bubble {
        bottom: 1rem !important;
        right: 1rem !important;
    }

    #begenius-chatbot-root.rtl #chatbot-bubble {
        left: 1rem !important;
        right: auto !important;
    }
}
