/* ==========================================================================
   CKB AI CHATBOT FLOATING WIDGET & MODAL
   ========================================================================== */

/* Floating FAB Trigger */
.btn-chatbot-fab {
    display: none !important;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 1060;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 8px 24px rgba(0, 79, 55, 0.35);
}

.btn-chatbot-fab img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
}

.btn-chatbot-fab:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 79, 55, 0.45);
}

.btn-chatbot-fab:active {
    transform: scale(0.95);
}

.chatbot-fab-pulse {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background-color: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulseChatbotFab 2s infinite;
    z-index: 2;
}

@keyframes pulseChatbotFab {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

body.modal-open .btn-chatbot-fab {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.8);
}

/* Modal Chatbot Portal Styles (Anchored to Bottom-Right) */
.modal-chatbot-portal {
    padding-right: 0 !important;
}

@media (min-width: 768px) {
    .modal-chatbot-portal .modal-dialog {
        position: fixed;
        right: 24px;
        bottom: 24px;
        margin: 0;
        width: 450px;
        max-width: calc(100vw - 48px);
        height: 570px;
        max-height: calc(100vh - 48px);
        transform: translateY(24px) scale(0.96) !important;
        transform-origin: bottom right;
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease-out;
    }

    .modal-chatbot-portal.show .modal-dialog {
        transform: translateY(0) scale(1) !important;
    }
}

@media (max-width: 767.98px) {
    .modal-chatbot-portal .modal-dialog {
        position: fixed;
        right: 12px;
        left: 12px;
        bottom: 12px;
        margin: 0;
        width: auto;
        max-width: 100%;
        height: 85vh;
        max-height: 600px;
        transform: translateY(24px) !important;
    }

    .modal-chatbot-portal.show .modal-dialog {
        transform: translateY(0) !important;
    }
}

.modal-chatbot-portal .modal-content {
    border-radius: 28px !important;
    border: none;
    box-shadow: -10px 15px 40px rgba(0, 0, 0, 0.14);
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.chatbot-modal-header {
    padding: 1.6rem 1.8rem 0.8rem 1.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    background: #ffffff;
}

.chatbot-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 4px 0;
    letter-spacing: -0.01em;
}

.chatbot-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
}

.chatbot-status-text {
    font-size: 0.82rem;
    color: #64748b;
    font-weight: 500;
}

.btn-chatbot-dash {
    width: 36px;
    height: 36px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-chatbot-dash:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.chatbot-modal-body {
    padding: 0.5rem 1.8rem 1rem 1.8rem;
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-bubble-bot {
    background-color: #f1f5f3;
    color: #334155;
    padding: 1rem 1.2rem;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.55;
    max-width: 95%;
    word-break: break-word;
}

.chat-bubble-user {
    background-color: #004F37;
    color: #ffffff;
    padding: 0.85rem 1.15rem;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 85%;
    margin-left: auto;
    word-break: break-word;
}

.chatbot-modal-footer {
    padding: 0.8rem 1.8rem 1.6rem 1.8rem;
    border: none;
    background: #ffffff;
}

.chatbot-input-wrapper {
    border: 2px solid #79d2a6;
    box-shadow: 0 0 0 4px rgba(121, 210, 166, 0.25);
    border-radius: 20px;
    background: #ffffff;
    padding: 6px 8px 6px 18px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.chatbot-input-wrapper:focus-within {
    border-color: #004F37;
    box-shadow: 0 0 0 4px rgba(0, 79, 55, 0.15);
}

.chatbot-input-field {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.92rem;
    color: #1e293b;
    flex-grow: 1;
    padding: 6px 0;
}

.chatbot-input-field::placeholder {
    color: #94a3b8;
    font-size: 0.9rem;
}

.btn-chatbot-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 12px;
    background-color: #004F37;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
    padding: 0;
}

.btn-chatbot-send:hover {
    background-color: #074332;
    transform: scale(1.05);
}

.modal-backdrop.show {
    opacity: 0.25 !important;
}
