/* AI Assistant UI Styles */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');

#ecom-ai-wrapper {
    font-family: 'Outfit', sans-serif;
    position: fixed;
    z-index: 99999;
    bottom: 0;
    right: 0;
    pointer-events: none;
    /* Let clicks pass through empty space */
}

/* Floating Toggle Button */
.ecom-ai-toggle-btn {
    pointer-events: auto;
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f2f5 100%);
    border-radius: 50%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 2px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
}

.ecom-ai-toggle-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.ecom-ai-toggle-btn i {
    font-size: 32px;
    color: #444;
    background: -webkit-linear-gradient(45deg, #22a7f0, #6c5ce7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Chat Container */
#ecom-ai-container {
    pointer-events: auto;
    position: fixed;
    bottom: 100px;
    right: 90px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.85);
    /* Glassmorphism */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
    opacity: 1;
    transform: scale(1);
}

#ecom-ai-container.ecom-ai-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(20px);
    visibility: hidden;
}

/* Header */
.ecom-ai-header {
    flex-shrink: 0;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    color: white;
    background: #22a7f0;
    /* Fallback */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.ecom-ai-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
}

.ecom-ai-avatar i {
    font-size: 24px;
    color: white;
}

.ecom-ai-title {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ecom-ai-name {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.ecom-ai-status {
    font-size: 10px;
    opacity: 0.9;
    font-weight: 300;
    display: flex;
    align-items: center;
}

.ecom-ai-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #00ff88;
    border-radius: 50%;
    margin-right: 5px;
}

.ecom-ai-close-btn,
.ecom-ai-action-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    margin-left: 5px;
    padding: 8px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ecom-ai-close-btn:hover,
.ecom-ai-action-btn:hover {
    opacity: 1;
}

/* Messages Area */
.ecom-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(245, 247, 250, 0.5);
    scroll-behavior: smooth;
    /* Smooth scrolling */
}

.ecom-ai-message {
    display: flex;
    max-width: 85%;
    animation: slideIn 0.3s ease-out;
}

.ecom-ai-message.assistant {
    align-self: flex-start;
}

.ecom-ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ecom-ai-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.ecom-ai-message.assistant .ecom-ai-bubble {
    background: white;
    color: #444;
    border-bottom-left-radius: 4px;
}

.ecom-ai-message.user .ecom-ai-bubble {
    background: #22a7f0;
    /* Gets overridden by style usually */
    background: var(--efs-primary, #22a7f0);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.ecom-ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.ecom-ai-typing span {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.ecom-ai-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

.ecom-ai-typing span:nth-child(2) {
    animation-delay: -0.16s;
}

/* Product Cards within Chat */
.ecom-ai-product-card {
    background: white;
    border-radius: 12px;
    padding: 10px;
    margin-top: 5px;
    display: flex;
    gap: 10px;
    border: 1px solid #eee;
    transition: transform 0.2s;
    cursor: pointer;
}

.ecom-ai-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.ecom-ai-product-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.ecom-ai-product-info {
    flex: 1;
}

.ecom-ai-product-name {
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 4px;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ecom-ai-product-price {
    font-weight: 700;
    color: var(--efs-primary, #22a7f0);
    font-size: 13px;
}

/* Input Area */
.ecom-ai-input-area {
    flex-shrink: 0;
    padding: 15px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.ecom-ai-input-wrapper {
    flex: 1;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 10px 15px;
}

#ecom-ai-input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    max-height: 100px;
    padding: 0;
    margin: 0;
}

.ecom-ai-controls {
    display: flex;
    gap: 8px;
}

.ecom-ai-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f0f2f5;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ecom-ai-icon-btn:hover {
    background: #e4e6eb;
}

.ecom-ai-icon-btn.recording {
    background: #ff4757;
    color: white;
    animation: pulse 1.5s infinite;
}

.ecom-ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #22a7f0;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(34, 167, 240, 0.3);
    transition: transform 0.2s;
}

.ecom-ai-send-btn:hover {
    transform: scale(1.05);
}

/* Legal Footer */
.ecom-ai-footer {
    flex-shrink: 0;
    padding: 10px 15px;
    background: rgba(245, 247, 250, 0.8);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    text-align: center;
}

.ecom-ai-legal-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #666;
    text-decoration: none;
    transition: color 0.2s;
}

.ecom-ai-legal-link:hover {
    color: var(--efs-primary, #22a7f0);
    text-decoration: underline;
}

.ecom-ai-legal-link i {
    font-size: 14px;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(255, 71, 87, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
    }
}

@media (max-width: 480px) {
    #ecom-ai-container {
        width: 100% !important;
        height: 100% !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
        max-height: 100vh !important;
        margin: 0 !important;
        transform: none !important;
    }

    #ecom-ai-container.ecom-ai-hidden {
        transform: translateY(100%) !important;
        opacity: 0;
        pointer-events: none;
    }

    .ecom-ai-toggle-btn {
        bottom: var(--efs-mobile-bottom, 15px) !important;
        /* Default Fallback for mobile if class missing: Right side */
        right: var(--efs-mobile-side, 15px) !important;
        left: auto !important;
        z-index: 100000;
    }

    .ecom-ai-toggle-btn.ecom-ai-pos-right {
        right: var(--efs-mobile-side, 15px) !important;
        left: auto !important;
    }

    .ecom-ai-toggle-btn.ecom-ai-pos-left {
        left: var(--efs-mobile-side, 15px) !important;
        right: auto !important;
    }
}