/**
 * Floating Chat Container Styles
 * Positions the floating chat widget in the bottom left corner
 */

/* Floating chat container */
#coai_chat_floating_chat_container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    max-width: 25%;
    /* 1/3 of screen on wide screens */
    width: 100%;
    box-sizing: border-box;
}

/* Small screens - 1/2 width */
@media (max-width: 1480px) {
    #coai_chat_floating_chat_container {
        max-width: 40%;
        right: 15px;
        bottom: 15px;
    }
}

/* Medium screens (tablets) - 1/2 width */
@media (max-width: 1024px) {
    #coai_chat_floating_chat_container {
        max-width: 50%;
        right: 15px;
        bottom: 15px;
    }
}

/* Mobile screens - full width with margins */
@media (max-width: 768px) {
    #coai_chat_floating_chat_container {
        max-width: calc(100% - 30px);
        left: 15px;
        right: 15px;
        bottom: 15px;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {
    #coai_chat_floating_chat_container {
        max-width: calc(100% - 20px);
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
}

/* Ensure widgets inside don't break the layout */
#coai_chat_floating_chat_container .widget {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Add subtle shadow for better visibility */
#coai_chat_floating_chat_container {
    box-shadow: 0 4px 20px var(--coai-chat-container-shadow-color, rgba(0, 0, 0, 0.15));
    border-radius: var(--coai-chat-container-border-radius, 8px);
    overflow: hidden;
    background-color: var(--coai-chat-container-bg-color, #f8f9fa);
    border: var(--coai-chat-container-border-width, 1px) solid var(--coai-chat-container-custom-border-color, #dee2e6);
    max-height: 90vh;
}

/* Ensure proper stacking context */
#coai_chat_floating_chat_container * {
    box-sizing: border-box;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #coai_chat_floating_chat_container {
        border: 2px solid var(--coai-chat-container-border-color, #000);
        box-shadow: 0 4px 20px var(--coai-chat-container-shadow-color, rgba(0, 0, 0, 0.5));
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #coai_chat_floating_chat_container {
        transition: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #coai_chat_floating_chat_container {
        box-shadow: 0 4px 20px var(--coai-chat-container-shadow-color, rgba(0, 0, 0, 0.3));
    }
}

/* Floating Action Button Styles */
.floating-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 4rem;
    height: 4rem;
    background: var(--coai-floating-button-bg-color, #6c757d);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 999998;
    box-shadow: 0 4px 20px var(--coai-floating-button-shadow-color, rgba(108, 117, 125, 0.3));
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.floating-chat-toggle:hover {
    background: var(--coai-floating-button-hover-bg-color, #5a6268);
    transform: scale(1.1);
    box-shadow: 0 6px 25px var(--coai-floating-button-hover-shadow-color, rgba(90, 98, 104, 0.4));
}

.floating-chat-toggle:active {
    transform: scale(0.95);
}

/* Chat Icon */
.chat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 100%;
    height: 100%;
    font-size: inherit;
}

/* Floating Chat Container Styles */
#coai_chat_floating_chat_container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    display: block;
}

/* Chat Header */
.floating-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--coai-chat-header-bg-color, #6c757d);
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.floating-chat-header h3 {
    color: var(--coai-chat-header-text-color, #ffffff);
    margin: 0;
}

.close-chat-btn {
    background: none;
    border: none;
    color: var(--coai-close-button-color, #495057);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.close-chat-btn:hover {
    background: var(--coai-close-button-hover-bg-color, rgba(0, 0, 0, 0.1));
}

/* Chat Content */
.floating-chat-content {
    display: block;
    background-color: var(--coai-chat-container-bg-color, #f8f9fa);
}


/* Responsive adjustments for floating button */
@media (max-width: 768px) {
    .floating-chat-toggle {
        bottom: 15px;
        right: 15px;
        width: 5rem;
        height: 5rem;
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .floating-chat-toggle {
        bottom: 10px;
        right: 10px;
        width: 6rem;
        height: 6rem;
        font-size: 3rem;
    }

}

/* Dark mode support for floating elements */
@media (prefers-color-scheme: dark) {
    .floating-chat-toggle {
        background: var(--coai-floating-button-bg-color, #495057);
        box-shadow: 0 4px 20px var(--coai-floating-button-shadow-color, rgba(73, 80, 87, 0.4));
    }

    .floating-chat-toggle:hover {
        background: var(--coai-floating-button-hover-bg-color, #343a40);
        box-shadow: 0 6px 25px var(--coai-floating-button-hover-shadow-color, rgba(52, 58, 64, 0.5));
    }

}

/* Reduced motion support for animations */
@media (prefers-reduced-motion: reduce) {
    .floating-chat-toggle {
        transition: none;
    }

}