.ecom-chat-toggle {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    left: auto !important;
    top: auto !important;
    width: 64px !important;
    height: 64px !important;
    border: none;
    border-radius: 50%;
    background: var(--ecom-chat-primary, #000000);
    color: var(--ecom-chat-secondary, #ffffff);
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ecom-chat-toggle.ecom-chat-left {
    right: auto !important;
    left: 30px !important;
}
.ecom-chat-toggle { transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.ecom-chat-toggle:hover { transform: scale(1.1) translateY(-4px); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); }
.ecom-chat-toggle.active { transform: rotate(180deg) scale(0.9); }

.ecom-chat-widget {
    display: flex;
    flex-direction: column;
    position: fixed !important;
    bottom: 110px !important;
    right: 30px !important;
    left: auto !important;
    top: auto !important;
    width: 400px !important;
    max-width: calc(100vw - 48px);
    height: 640px !important;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 20px;
    box-shadow: rgba(73, 104, 126, 0.16) 0px 16px 24px 0px, rgba(73, 104, 126, 0.08) 0px 0px 0px 1px;
    overflow: hidden;
    z-index: 999999;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    opacity: 0;
    transform: translateY(120px) scale(0.9);
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.ecom-chat-widget.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}
.ecom-chat-widget.ecom-chat-left {
    right: auto !important;
    left: 30px !important;
}

.ecom-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px;
    background: var(--ecom-chat-primary, #000000);
    color: var(--ecom-chat-secondary, #ffffff);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.ecom-chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    border-radius: 50%;
}
.ecom-chat-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}
.ecom-chat-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    overflow: hidden;
}
.ecom-chat-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ecom-chat-header-text { position: relative; z-index: 1; }
.ecom-chat-title { font-family: var(--ecom-chat-title-font, Manrope, sans-serif) !important; font-size: 17px; font-weight: 700; margin: 0 0 2px 0; letter-spacing: -0.2px; color: var(--ecom-chat-title-color, var(--ecom-chat-secondary, #ffffff)); }
.ecom-chat-subtitle { font-size: 11px; opacity: 0.95; font-weight: 400; line-height: 1.3; margin: 0; }
.ecom-chat-close {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    box-sizing: border-box !important;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 18px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative;
    z-index: 1;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.ecom-chat-close:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.ecom-chat-close:active { transform: scale(0.95) rotate(90deg); }

.ecom-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    background: #fafbfc;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.ecom-chat-messages::-webkit-scrollbar { display: none; }
.ecom-chat-message { margin-bottom: 16px; display: flex; }
.ecom-chat-message-content {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
}
.ecom-chat-user { justify-content: flex-end; }
.ecom-chat-user .ecom-chat-message-content {
    background: var(--ecom-chat-primary, #000000);
    color: var(--ecom-chat-secondary, #ffffff);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.ecom-chat-bot .ecom-chat-message-content {
    background: #fff;
    color: var(--ecom-chat-text-color, #28303d);
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.ecom-chat-message-content a { color: var(--ecom-chat-accent, var(--ecom-chat-primary, #000000)); }
.ecom-chat-message-content a:hover { text-decoration: underline; }

.ecom-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px 22px 18px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}
.ecom-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(0,0,0,0.08);
    border-radius: 22px;
    font-size: 14px;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ecom-chat-text-color, #28303d);
    background: #f8f9fa;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.5;
    box-sizing: border-box;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.ecom-chat-input::-webkit-scrollbar { display: none; }
.ecom-chat-input:focus { outline: none; border-color: var(--ecom-chat-accent, var(--ecom-chat-primary, #000000)); background: #fff; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08); }
.ecom-chat-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--ecom-chat-primary, #4141CE);
    color: var(--ecom-chat-secondary, #ffffff);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.ecom-chat-send:hover { transform: translateY(-4px) translateX(6px) rotate(15deg) scale(1.1); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); }

.ecom-chat-loading {
    display: none;
    gap: 4px;
    padding: 12px 16px;
    align-items: center;
}
.ecom-chat-loading.active { display: flex; }
.ecom-chat-loading-dot {
    width: 8px;
    height: 8px;
    background: var(--ecom-chat-accent, var(--ecom-chat-primary, #000000));
    border-radius: 50%;
    animation: ecom-chat-loading-wave 0.9s infinite ease-in-out;
}
.ecom-chat-loading-dot:nth-child(1) { animation-delay: 0s; }
.ecom-chat-loading-dot:nth-child(2) { animation-delay: 0.3s; }
.ecom-chat-loading-dot:nth-child(3) { animation-delay: 0.6s; }
.ecom-chat-loading-row .ecom-chat-loading { display: flex !important; }
@keyframes ecom-chat-loading-wave {
    0%, 100% { transform: translateY(0); }
    33.33% { transform: translateY(-12px); }
}

.ecom-chat-product-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}
.ecom-chat-product-card {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    max-width: 100%;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.ecom-chat-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.12);
}
.ecom-chat-product-img-wrap {
    display: block;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: #f1f5f9;
}
.ecom-chat-product-img-wrap:focus {
    outline: 2px solid var(--ecom-chat-accent, var(--ecom-chat-primary, #000000));
    outline-offset: 2px;
}
.ecom-chat-product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ecom-chat-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.ecom-chat-product-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: #28303d;
    margin: 0 0 6px 0;
}
.ecom-chat-product-price {
    font-size: 13px;
    color: var(--ecom-chat-accent, var(--ecom-chat-primary, #000000));
    font-weight: 500;
    margin-bottom: 6px;
}
.ecom-chat-product-price del { color: #94a3b8; font-weight: 400; }
.ecom-chat-product-link {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    color: var(--ecom-chat-accent, var(--ecom-chat-primary, #000000));
}
.ecom-chat-product-link:hover { text-decoration: underline; }

/* Image preview lightbox */
.ecom-chat-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.ecom-chat-preview-overlay .ecom-chat-preview-inner {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}
.ecom-chat-preview-overlay .ecom-chat-preview-img {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.ecom-chat-preview-overlay .ecom-chat-preview-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: none;
    color: #28303d;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.ecom-chat-preview-overlay .ecom-chat-preview-close:hover {
    background: #f1f5f9;
}

@media (max-width: 768px) {
    .ecom-chat-widget,
    #ecomChatWidget.ecom-chat-widget {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding-top: env(safe-area-inset-top);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    .ecom-chat-widget.ecom-chat-left,
    #ecomChatWidget.ecom-chat-widget.ecom-chat-left {
        left: 0 !important;
        right: 0 !important;
    }
    .ecom-chat-widget .ecom-chat-header,
    .ecom-chat-widget .ecom-chat-input-wrap {
        min-width: 0 !important;
        overflow-x: hidden !important;
    }
    #ecomChatWidget .ecom-chat-messages,
    .ecom-chat-widget .ecom-chat-messages {
        flex: 1 1 0 !important;
        min-height: 0 !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .ecom-chat-toggle {
        right: 20px !important;
        left: auto !important;
        bottom: 20px !important;
    }
    .ecom-chat-toggle.ecom-chat-left {
        right: auto !important;
        left: 20px !important;
    }
    html.ecom-chat-modal-open,
    body.ecom-chat-modal-open {
        overflow: hidden !important;
        height: 100% !important;
        position: fixed !important;
        width: 100% !important;
        touch-action: none !important;
    }
}
