/* 
 * Responsive chat modal styles
 * This CSS ensures the chat works properly across all devices
 */

/* Prevent body scrolling when chat modal is open */
body.modal-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Chat Modal Container */
.chat-modal-container {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 400px;
    height: 600px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 30px 100px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

.chat-modal-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Modal Header */
.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background-color: var(--color-primary, #4f46e5);
    color: white;
    border-radius: 12px 12px 0 0;
}

.chat-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

.chat-modal-header button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.chat-modal-header button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Modal Body */
.chat-modal-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#n8n-chat-container {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Customize n8n chat appearance inside our modal */
#n8n-chat-container .n8n-chat-window {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    position: relative !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Ensure chat messages area expands properly */
#n8n-chat-container .n8n-chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    min-height: 0 !important; /* Fix for flexbox on Safari */
}

/* Make sure input area stays at the bottom */
#n8n-chat-container .n8n-chat-input-container {
    margin-top: auto !important;
}

/* Chat Window Overlay */
.chat-window-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-window-overlay.active {
    display: block;
    opacity: 1;
}

/* Floating Chat Button */
.floating-chat-button {
    background-color: var(--color-primary, #4f46e5) !important;
    color: white !important;
    border: none !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    cursor: pointer !important;
    z-index: 1000 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.2s ease-in-out !important;
}

.floating-chat-button i {
    font-size: 24px !important;
}

.floating-chat-button:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2) !important;
}

/* Container for the floating button */
.floating-chat-widget {
    position: fixed !important;
    bottom: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .floating-chat-button {
        width: 50px !important;
        height: 50px !important;
        bottom: 20px !important;
        right: 20px !important;
        z-index: 2500 !important;
    }
    
    /* Full screen modal on mobile */
    .chat-modal-container {
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
    }
    
    .chat-modal-container.active {
        bottom: 0;
        right: 0;
    }
    
    /* Adjust modal header for mobile */
    .chat-modal-header {
        border-radius: 0;
    }
    
    /* Hide n8n chat toggle when in our modal */
    #n8n-chat-container .n8n-chat-toggle {
        display: none !important;
    }
    
    /* Ensure n8n chat window is full size in our modal */
    #n8n-chat-container .n8n-chat-window {
        border-radius: 0 !important;
        box-shadow: none !important;
        height: 100% !important;
    }
    
    /* Position the error notification better on mobile */
    .chat-error-notification {
        bottom: 80px;
        right: 20px;
        width: calc(100% - 40px);
    }
}
