@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Mobile-first Floating Chat (modern, animated) */

:root {
    --accent-1: #6366f1;
    --accent-2: #4f46e5;
    --bg: #ffffff;
    --muted: #9ca3af;
    --text: #0f172a;
    --border: #e5e7eb;
}

/* Chat window */
#mwai-chat-window {
    position: fixed;
    bottom: 80px; /* Position above the new chat bar */
    left: 50%;
    transform: translateX(-50%); /* Center horizontally */
    width: calc(100% - 32px); /* 100% minus 16px margin on each side */
    max-width: 600px; /* Max width for desktop */
    max-height: 76vh;
    background: var(--bg);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: hidden;
    /* Enhanced shadow for elevation */
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1), 0 20px 60px rgba(15, 23, 42, 0.15);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    transition: transform 0.22s cubic-bezier(.2,.9,.2,1), opacity 0.18s ease;
    z-index: 9998;
}
#mwai-chat-window.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(50px) scale(0.9); /* Animate from below and slightly scaled */
    pointer-events: none;
}

#mwai-chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
#mwai-chat-header {
    background: linear-gradient(135deg, var(--accent-2), #4338ca);
    color: #fff;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 14px; /* Match window border-radius */
    border-top-right-radius: 14px; /* Match window border-radius */
}
#mwai-chat-header img { 
    width: 20px; 
    height: 20px; 
    cursor: pointer; 
    filter: invert(100%); 
}

/* Body */
#mwai-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8fafc;
}

/* New Chat Bar */
#mwai-chat-bar {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px); /* 100% minus 16px margin on each side */
    max-width: 600px; /* Max width for desktop */
    height: 48px; /* Fixed height for the bar */


    /* ✨ Dynamic Animated Gradient Background */
    background: linear-gradient(120deg,
        #00FF48,
        #00FFA1,
        #00FF48,
        #00FFC4
    );
    background-size: 300% 300%;


    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);

    /* Modern glowing border */
    border: 1px solid rgba(0, 255, 72, 0.7);
    box-shadow: 0 0 10px rgba(0, 255, 72, 0.4), 0 6px 20px rgba(0, 255, 72, 0.15), 0 12px 40px rgba(0, 255, 72, 0.2);
    border-radius: 18px;


    /* Animate the border color */
    animation: mwaiGradient 10s ease infinite, borderGradientFlow 5s ease-in-out infinite;

    
    display: flex;
    align-items: center;
    padding: 0 6px;
    

    z-index: 9999;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}


/* 🎨 Smooth Dynamic Gradient Animation */
@keyframes mwaiGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes borderGradientFlow {
    0%   { border-color: #00FF48; box-shadow: 0 0 10px #00FF48; }
    25%  { border-color: #00FFA1; box-shadow: 0 0 12px #00FFA1; }
    50%  { border-color: #00FFC4; box-shadow: 0 0 14px #00FFC4; }
    75%  { border-color: #00FF48; box-shadow: 0 0 12px #00FF48; }
    100% { border-color: #00FFA1; box-shadow: 0 0 10px #00FFA1; }
}


#mwai-chat-bar:hover {
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.15), 0 16px 50px rgba(79, 70, 229, 0.2);
}

#mwai-user-input {
    flex: 1;
    padding: 12px;
    height: 47px;
    outline: none;
    font-size: 14px;
    background: #fff;
    margin-right: 6px; /* Space between input and button */
    border: none;
    border-radius: 12px;
    color: #111;
    transition: all 0.2s ease;
}
#mwai-user-input:focus { 
    box-shadow: 0 4px 12px rgba(79,70,229,0.08); 
    border-color: rgba(79,70,229,0.2); 
}

#mwai-toggle-send-btn {
    padding: 8px 10px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    border: none;
    cursor: pointer;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease; /* Add box-shadow to transition */
}
#mwai-toggle-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.25); /* Enhanced hover shadow */
}
#mwai-toggle-send-btn img { 
    width: 24px; 
    height: 24px; 
    filter: drop-shadow(0 1px 0 rgba(0,0,0,0.05));
}

/* Messages */
.mwai-msg { 
    margin-bottom: 16px; 
    display: block; 
    max-width: 100%;
    word-wrap: break-word; 
}
.mwai-msg p { 
    margin: 0; 
    display: inline-block; 
    padding: 12px 16px; 
    border-radius: 18px; 
    font-size: 14px; 
    line-height: 1.5; 
    animation: fadeInUp .25s ease; 
    white-space: pre-wrap;
    word-break: break-word;
}
.mwai-msg.user { 
    margin-left: auto; 
    text-align: right; 
}
.mwai-msg.user p { 
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); 
    color: #fff; 
    border-bottom-right-radius: 6px; 
    box-shadow: 0 4px 12px rgba(79,70,229,0.15); /* Adjusted shadow */
}
.mwai-msg.ai p { 
    background: transparent;
    color: var(--text); 
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    font-size: 15px;
    text-transform: none;
}

/* Typing indicator */
.mwai-msg.typing { 
    display: inline-flex; 
    gap: 8px; 
    align-items: center; 
}
.mwai-msg.typing span { 
    display: block; 
    width: 6px; 
    height: 6px; 
    background: var(--muted); 
    border-radius: 50%; 
    animation: blink 1.2s infinite both; 
}
.mwai-msg.typing span:nth-child(2) { 
    animation-delay: .15s; 
}
.mwai-msg.typing span:nth-child(3) { 
    animation-delay: .3s; 
}

/* Quick buttons */
.mwai-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    margin-bottom: 16px;
}
.mwai-quick-buttons button {
    padding: 8px 16px;
    border-radius: 20px;
    background: #eef2ff;
    color: var(--accent-2);
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: background 0.2s ease, box-shadow 0.2s ease; /* Add box-shadow to transition */
    box-shadow: 0 2px 6px rgba(0,0,0,0.05); /* Subtle shadow */
}
.mwai-quick-buttons button:hover {
    background: #e0e7ff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); /* Enhanced hover shadow */
}

/* Product Carousel Wrapper (for scroll buttons and blur effect) */
.mwai-products-carousel-wrapper {
    position: relative;
    margin-top: 24px;
    margin-bottom: 16px;
    background: #f8fafc;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    padding: 0 10px; /* Padding for blur effect and buttons */
}

/* Product Carousel Container */
.mwai-products-carousel {
    display: flex;
    overflow-x: auto; /* Enable horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* For smooth scrolling on iOS */
    padding: 10px 0; /* Adjust padding to account for wrapper padding */
    /* Hide scrollbar for all devices, buttons will handle scrolling */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

.mwai-products-carousel::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Scroll Buttons for Carousel */
.mwai-products-carousel-wrapper .mwai-scroll-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    color: var(--text);
    font-size: 16px;
    font-weight: bold;
}

.mwai-products-carousel-wrapper .mwai-scroll-button:hover {
    background: var(--accent-1);
    color: #fff;
    border-color: var(--accent-1);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.mwai-products-carousel-wrapper .mwai-scroll-button.left {
    left: 0;
}

.mwai-products-carousel-wrapper .mwai-scroll-button.right {
    right: 0;
}

.mwai-products-carousel-wrapper .mwai-scroll-button.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Responsive adjustments for buttons */
@media (max-width: 768px) {
    .mwai-products-carousel-wrapper .mwai-scroll-button {
        display: none; /* Hide buttons on mobile, rely on touch scroll */
    }
    .mwai-products-carousel-wrapper {
        padding: 0; /* Remove padding on mobile if buttons are hidden */
    }
}

/* Product grid container (for when products are displayed in a grid) */
.mwai-products-grid-container {
    margin-top: 24px;
    margin-bottom: 16px;
    padding: 6px 10px; /* Consistent padding with carousel */
    background: #f8fafc;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

/* Product grid / unified card (now inside carousel or grid) */
.mwai-products { 
    display: flex; /* Default to flex for carousel */
    flex-wrap: nowrap; /* Default to no wrap for carousel */
    gap: 10px; /* Spacing between cards */
    padding: 0; /* Padding handled by parent container */
    width: fit-content; /* Ensure content takes natural width in carousel */
}

/* Specific styles for when .mwai-products is used as a grid */
.mwai-products.mwai-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* Grid layout */
    flex-wrap: wrap; /* Allow wrapping in grid */
    width: 100%; /* Take full width in grid */
}

.mwai-product-card {
    flex-shrink: 0; /* Prevent cards from shrinking in carousel */
    width: 140px; /* Fixed width for cards in carousel */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 6px;
    background: #fff;
    transition: transform .18s ease, box-shadow .18s ease;
    text-align: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(15,23,42,0.04); /* Subtle initial shadow */
}

/* Override fixed width for grid items to allow them to fill space */
.mwai-products.mwai-products-grid .mwai-product-card {
    width: auto; /* Allow grid items to adjust width */
}

.mwai-product-card:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 8px 20px rgba(15,23,42,0.1); /* More pronounced shadow on hover */
}

/* Product image - square, responsive */
.mwai-product-card img { 
    width: 100%;       
    max-width: 100%;  
    height: auto; 
    aspect-ratio: 1/1; 
    border-radius: 6px; 
    object-fit: cover; 
    margin-bottom: 8px;
}

/* Product meta */
.mwai-product-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.mwai-product-meta h4 { 
    margin: 0; 
    font-size: 10px; 
    font-weight: 600; 
    line-height: 1.3;
    color: #111827;
    text-transform: none;
    display: -webkit-box;
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mwai-product-price { 
    font-size: 10px; 
    color: var(--accent-2); 
    font-weight: 700; 
}

/* CTA button */
.mwai-product-cta {
    margin-top: 6px;
    padding: 4px 8px;
    background-color: var(--accent-1);
    color: #fff;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

/* Badge on top-right */
.mwai-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: none;
    line-height: 1.2;
    z-index: 1;
}

/* Product checkbox */
.mwai-product-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 18px;
    height: 18px;
    cursor: pointer;
    appearance: none;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mwai-product-checkbox:checked {
    background-color: var(--accent-1);
    border-color: var(--accent-1);
}

.mwai-product-checkbox:checked::after {
    content: '✔';
    color: #fff;
    font-size: 12px;
    line-height: 1;
}

.mwai-product-checkbox:hover {
    border-color: var(--accent-1);
}

.mwai-badge.local {
    background: #eef2ff;
    color: var(--accent-2);
}

.mwai-badge.global {
    background: #fff7ed;
    color: #d97706;
}

/* Tablet (768px–1023px) adjustments */
@media (max-width: 1023px) and (min-width: 768px) {
    .mwai-product-card img {
        max-width: 100%;
    }
    .mwai-product-meta h4,
    .mwai-product-price,
    .mwai-product-cta {
        font-size: 9px;
    }
    .mwai-badge {
        font-size: 8px;
        padding: 2px 4px;
    }
}

/* Mobile (<768px) adjustments */
@media (max-width: 767px) {
    .mwai-products {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .mwai-product-card img {
        max-width: 100%;
    }
    .mwai-product-meta h4,
    .mwai-product-price,
    .mwai-product-cta {
        font-size: 10px;
    }
    .mwai-badge {
        font-size: 9px;
        padding: 1px 3px;
    }
}

/* Small animations */
@keyframes blink { 
    0%, 80%, 100% { opacity: .25 } 
    40% { opacity: 1 } 
}
@keyframes fadeInUp { 
    from { opacity: 0; transform: translateY(8px) } 
    to { opacity: 1; transform: translateY(0) } 
}

/* Desktop tweaks */
@media(min-width: 768px) {
    #mwai-chat-window { 
        bottom: 96px; /* Adjust for desktop chat bar height */
    }
}
