/* ========================================
   Ellis AI Chatbot Styles - Optimized for Performance
   Load Once, Show/Hide with CSS
   ======================================== */

/* Ellis Chatbot Floating Action Button (FAB) - Custom Button */
.ellis-chatbot-fab {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 10000 !important;
    box-shadow: 0 4px 12px rgba(0, 63, 45, 0.3) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

/* Custom FAB button styling */
.ellis-custom-fab {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    outline: none;
}

    .ellis-custom-fab:focus {
        outline: 2px solid #003F2D;
        outline-offset: 2px;
    }

    .ellis-custom-fab img {
        width: 48px;
        height: 48px;
        display: block;
        pointer-events: none;
    }

    .ellis-chatbot-fab:hover {
        transform: scale(1.05) !important;
        box-shadow: 0 6px 16px rgba(0, 63, 45, 0.4) !important;
    }

    .ellis-chatbot-fab:active {
        transform: scale(0.95) !important;
    }

/* Ellis Assistant Window - Always in DOM, controlled by CSS */
.ellis-assistant-window {
    /*position: fixed;
    top: clamp(20px, calc(100vh - 840px), calc(100vh - 520px));*/ /* Smart positioning: minimum 20px from top, but ensure at least 400px height */
    /*bottom: 90px;
    right: 30px;
    width: 800px;
    height: auto;*/ /* Let height be calculated by top/bottom constraints */
    /*min-height: 400px;
    max-height: calc(100vh - 120px);*/ /* Account for positioning + padding */
    /*background: white;
    border: 1px solid var(--divider-grey, #e0e0e0);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    z-index: 10001;*/ /* Ensure it's above everything including mobile menu */
    /*display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    will-change: opacity, transform;
    backface-visibility: hidden;
    overflow: hidden;*/

    position: fixed;
    top: 0;
    right: 5px;
    bottom: 0px;
    width: 60%; /* Adjust width as needed */
    height: 100%;
    background-color: #fff;
    box-shadow: -2px 0 8px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;

}

/* Visible state - smooth fade in and slide up */
.ellis-assistant-window.ellis-visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
}

/* Hidden state - fade out and slide down, but keep in DOM for instant re-show */
.ellis-assistant-window.ellis-hidden {
    opacity: 0;
    transform: translateY(20px);
    visibility: hidden;
    pointer-events: none;
}

/* Container */
.ellis-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: linear-gradient(180deg, #FAFAFA 0%, #FFFFFF 100%);
    max-height: 100%;
    min-height: 0; /* Allow flex item to shrink below content size */
}

/* Specific constraints for Native Federation container */
#ellis-native-federation-container.ellis-container {
    height: 100%;
    max-height: 100%;
    overflow: hidden; /* Prevent Ellis component from overflowing */
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Ensure the main Ellis window properly constrains Native Federation content */
.ellis-assistant-window:has(#ellis-native-federation-container) {
    overflow: hidden !important;
}

/* Additional safety for Native Federation content */
.ellis-assistant-window #ellis-native-federation-container {
    flex: 1;
    min-height: 0;
    contain: layout size style;
}

.ellis-assistant-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #FFFFFF;
}

/* Loading state */
.ellis-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 48px 32px;
    text-align: center;
    background: linear-gradient(180deg, #FAFAFA 0%, #FFFFFF 100%);
}

    .ellis-loading-container p {
        margin: 16px 0 8px 0;
        color: var(--light-grey, #5E6A6C);
        font-size: 18px;
        line-height: 1.6;
    }

    .ellis-loading-container .ellis-loading-hint {
        margin: 0;
        color: var(--light-grey, #5E6A6C);
        font-size: 15px;
        font-style: italic;
    }

.ellis-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--dark-green, #003F2D);
    border-radius: 50%;
    animation: ellis-spin 1s linear infinite;
}

@keyframes ellis-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error state */
.ellis-error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 48px 32px;
    text-align: center;
    background: linear-gradient(180deg, #FAFAFA 0%, #FFFFFF 100%);
}

    .ellis-error-container svg {
        margin-bottom: 16px;
    }

.ellis-error-message {
    margin: 16px 0;
    color: var(--light-grey, #5E6A6C);
    font-size: 18px;
    line-height: 1.6;
}

.ellis-retry-button {
    background: var(--dark-green, #003F2D);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s;
}

    .ellis-retry-button:hover {
        background: #002a1f;
    }

    .ellis-retry-button:active {
        transform: scale(0.98);
    }


/* Mobile responsive */
@media (max-width: 768px) {
    .ellis-assistant-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        /*max-height: 100vh;*/
        border-radius: 0;
        border: none;
        z-index: 10000; /* Ensure it's above everything on mobile */
    }    

    .ellis-chatbot-fab {
        bottom: 80px !important;
        /* Add safe area padding */
        bottom: max(80px, calc(80px + env(safe-area-inset-bottom))) !important;
    }

    /* Mobile-specific sizing for custom FAB */
    .ellis-custom-fab {
        width: 56px;
        height: 56px;
    }

    .ellis-custom-fab img {
        width: 48px;
        height: 48px;
    }

    /* Ensure container doesn't overlap with header */
    .ellis-container {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        /* Add safe area padding at bottom */
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    .ellis-loading-container,
    .ellis-error-container {
        padding: 32px 20px;
        /* Add safe area padding */
        padding-bottom: max(32px, calc(32px + env(safe-area-inset-bottom)));
    }

    .ellis-loading-container p,
    .ellis-error-message {
        font-size: 16px;
    }

    .ellis-loading-container .ellis-loading-hint {
        font-size: 14px;
    }
}

/* Small desktop screens - prevent clipping */
@media (min-height: 600px) and (max-height: 900px) and (min-width: 769px) {
    .ellis-assistant-window {
        top: 0px;
        height: 100%;
        min-height: 400px;
        width:100%;
        /*max-height: calc(100vh - 120px);*/
        max-height: 100%;
    }
}

/* Tablet responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    .ellis-assistant-window {
        width: 80%;
        top: 0px;
        height: 100%;
        min-height: 400px;
        /*max-height: calc(100vh - 120px);*/
        max-height:100%;
        right: 0px;
        bottom: 0px;
    }
}

/* Large screens */
@media (min-width: 1440px) {
    .ellis-assistant-window {
        width: 60%;
        top: 0px;
        right:0px;
        bottom:0px;
        height: 100%;
        min-height: 500px;
        max-height: 100%;
    }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    .ellis-assistant-window {
        width: 60%;
        top: 0px;
        bottom:0px;
        right:0px;
        height: 100%;
        min-height: 600px;
        max-height: 100%;
    }
}

/* Performance optimizations */
.ellis-assistant-window,
.ellis-container {
    contain: layout style paint;
}

/* Smooth scrolling for container */
.ellis-container {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

    .ellis-container::-webkit-scrollbar {
        width: 6px;
    }

    .ellis-container::-webkit-scrollbar-track {
        background: transparent;
    }

    .ellis-container::-webkit-scrollbar-thumb {
        background: #cbd5e0;
        border-radius: 3px;
    }

        .ellis-container::-webkit-scrollbar-thumb:hover {
            background: #a0aec0;
        }

/* Animation performance optimizations */
@media (prefers-reduced-motion: reduce) {
    .ellis-assistant-window,
    .ellis-chatbot-fab,
    .ellis-prompt-card,
    .ellis-close-button,
    .ellis-retry-button {
        transition: none !important;
        animation: none !important;
    }
}

/* Ensure proper z-index layering */
.ellis-chatbot-fab,
.ellis-assistant-window {
    isolation: isolate;
}

/* Print styles - hide chatbot when printing */
@media print {
    .ellis-chatbot-fab,
    .ellis-assistant-window {
        display: none !important;
    }
}

/* Dark mode support (optional - if application supports dark mode) */
@media (prefers-color-scheme: dark) {
    .ellis-assistant-window {
        background: #1f2937;
        box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
        border-color: #374151;
    }

    .ellis-container {
        background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    }

    .ellis-loading-container,
    .ellis-error-container {
        background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    }

    .ellis-loading-container p,
    .ellis-error-message {
        color: #d1d5db;
    }

    .ellis-loading-container .ellis-loading-hint {
        color: #9ca3af;
    }

    .ellis-spinner {
        border-color: #4b5563;
        border-top-color: #17E88F;
    }    
}
.header-title-section mat-icon, .answer-text mat-icon {
    font-size: 6px !important
}