/* BUILDER BEE CHAT WIDGET - FIXED VERSION */
/* This CSS ensures the input field NEVER disappears and provides proper scrolling */

/* Chat Widget Container */
.intercom-namespace {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chat Frame */
.intercom-frame {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: #1a202c;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    overflow: hidden;
}

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

/* Messenger Frame */
.intercom-messenger-frame {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Messenger Container */
.intercom-messenger {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #1a202c;
    border-radius: 12px;
    overflow: hidden;
}

/* Header */
.intercom-messenger-header {
    background: linear-gradient(135deg, #f97316, #ea580c);
    padding: 20px;
    flex-shrink: 0;
    border-radius: 12px 12px 0 0;
}

.intercom-messenger-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.intercom-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bee-icon {
    font-size: 20px;
}

.intercom-header-text {
    flex: 1;
    color: white;
}

.intercom-header-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.intercom-header-subtitle {
    margin: 4px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.2;
}

.intercom-close-button {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.intercom-close-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messenger Body - CRITICAL LAYOUT */
.intercom-messenger-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for proper flex behavior */
    height: calc(100% - 84px); /* Account for header height */
}

/* Conversation Area - WITH PROPER SCROLLING */
.intercom-conversation {
    flex: 1;
    padding: 20px;
    overflow-y: scroll !important; /* Force scrolling to always be available */
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0; /* Critical for flex item */
    max-height: calc(100% - 140px); /* Reserve space for composer */
    background: #1a202c;
    
    /* Force scroll bar to always be visible */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.4) rgba(255, 255, 255, 0.1);
}

/* Webkit scrollbar styling - Make it more visible */
.intercom-conversation::-webkit-scrollbar {
    width: 8px;
    background: rgba(255, 255, 255, 0.1);
}

.intercom-conversation::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.intercom-conversation::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.intercom-conversation::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6);
}

.intercom-conversation::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.8);
}

/* Message Styling */
.intercom-comment {
    display: flex;
    margin-bottom: 15px;
    animation: messageSlideIn 0.3s ease-out;
}

.intercom-comment-from-admin {
    justify-content: flex-start;
}

.intercom-comment-from-user {
    justify-content: flex-end;
}

.intercom-comment-body {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.intercom-comment-from-admin .intercom-comment-body {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: white;
    border-bottom-left-radius: 6px;
}

.intercom-comment-from-user .intercom-comment-body {
    background: #374151;
    color: #e5e7eb;
    border-bottom-right-radius: 6px;
}

.intercom-comment-text {
    margin: 0;
    line-height: 1.4;
    font-size: 14px;
}

/* Composer - FIXED AT BOTTOM */
.intercom-composer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: #1a202c;
    flex-shrink: 0; /* NEVER shrink */
    position: sticky; /* Stay at bottom */
    bottom: 0;
    z-index: 10;
}

.intercom-composer-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #374151;
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.intercom-composer-input-wrapper:focus-within {
    border-color: #f97316;
}

.intercom-composer-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e5e7eb;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    padding: 8px 0;
    font-family: inherit;
}

.intercom-composer-textarea::placeholder {
    color: #9ca3af;
}

.intercom-composer-send-button {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.intercom-composer-send-button:hover {
    transform: scale(1.05);
}

.intercom-composer-send-button:active {
    transform: scale(0.95);
}

/* Launcher Button */
.intercom-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.4);
    transition: all 0.3s ease;
    z-index: 9999;
}

.intercom-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(249, 115, 22, 0.6);
}

.intercom-launcher-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc2626;
    color: white;
    font-size: 12px;
    font-weight: 600;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.intercom-launcher-icon {
    font-size: 24px;
    color: white;
}

/* Animations */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .intercom-frame {
        width: calc(100vw - 40px);
        height: 500px;
        right: 20px;
        left: 20px;
        bottom: 80px;
    }
    
    .intercom-launcher {
        width: 55px;
        height: 55px;
        bottom: 15px;
        right: 15px;
    }
    
    .intercom-launcher-icon {
        font-size: 22px;
    }
    
    .intercom-conversation {
        padding: 15px;
    }
    
    .intercom-composer {
        padding: 15px;
    }
    
    .intercom-messenger-header {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .intercom-frame {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
    }
    
    .intercom-comment-body {
        max-width: 90%;
    }
}

