/* Chat Container */
.aisa-chat-container {
    position: fixed;
    z-index: 9999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    pointer-events: none;
}

.aisa-chat-container.position-bottom-right {
    bottom: 30px;
    right: 30px;
}

.aisa-chat-container.position-bottom-left {
    bottom: 30px;
    left: 30px;
}

.aisa-chat-container.position-top-right {
    top: 30px;
    right: 30px;
}

.aisa-chat-container.position-top-left {
    top: 30px;
    left: 30px;
}

/* Toggle Button */
.aisa-chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a56db 0%, #7c3aed 100%);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(26, 86, 219, 0.5);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    position: relative;
}

.aisa-chat-toggle:hover {
    transform: scale(1.1);
}

.aisa-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Widget */
.aisa-chat-widget {
    position: fixed;
    z-index: 9999998;
    width: 420px;
    max-width: 92vw;
    height: 580px;
    max-height: 85vh;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.aisa-chat-widget.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

.aisa-chat-widget.position-bottom-right {
    bottom: 110px;
    right: 30px;
}

.aisa-chat-widget.position-bottom-left {
    bottom: 110px;
    left: 30px;
}

.aisa-chat-widget.position-top-right {
    top: 110px;
    right: 30px;
}

.aisa-chat-widget.position-top-left {
    top: 110px;
    left: 30px;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.aisa-chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #1a56db 0%, #7c3aed 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.aisa-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aisa-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.aisa-chat-title {
    font-weight: 600;
    font-size: 16px;
}

.aisa-chat-subtitle {
    font-size: 12px;
    opacity: 0.8;
}

.aisa-chat-close {
    cursor: pointer;
    font-size: 24px;
    background: none;
    border: none;
    color: white;
    padding: 0 5px;
}

/* Messages Container */
.aisa-chat-messages {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
}

/* Welcome Message */
.aisa-welcome {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    display: block !important;
}

.aisa-welcome-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
}

.aisa-welcome-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-top: 4px;
}

.aisa-welcome-text {
    font-size: 14px;
    color: #64748b;
    margin-top: 4px;
    line-height: 1.5;
}

.aisa-welcome-products {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 14px;
}

.aisa-welcome-product-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    background: #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    color: #475569;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.aisa-welcome-product-tag:hover {
    background: #1a56db;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.3);
    text-decoration: none;
}

/* Quick Replies */
.aisa-quick-replies {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.aisa-quick-reply {
    padding: 6px 16px;
    background: #e2e8f0;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.aisa-quick-reply:hover {
    background: #1a56db;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.3);
}

.aisa-quick-reply-icon {
    font-size: 10px;
    opacity: 0.7;
}

.aisa-quick-reply:hover .aisa-quick-reply-icon {
    opacity: 1;
}

/* Messages */
.aisa-message {
    margin-bottom: 12px;
    max-width: 90%;
    flex-shrink: 0;
}

.aisa-message-user {
    margin-left: auto;
}

.aisa-message-bot {
    margin-right: auto;
}

.aisa-message-content {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.aisa-message-user .aisa-message-content {
    background: linear-gradient(135deg, #1a56db 0%, #7c3aed 100%);
    color: white;
    border-radius: 12px 12px 4px 12px;
}

.aisa-message-bot .aisa-message-content {
    background: white;
    color: #1e293b;
    border-radius: 12px 12px 12px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Chat Links */
.aisa-message-content a {
    color: #1a56db;
    text-decoration: underline;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, text-decoration 0.2s;
}

.aisa-message-content a:hover {
    color: #7c3aed;
    text-decoration: none;
}

.aisa-message-user .aisa-message-content a {
    color: #ffffff;
    text-decoration: underline;
}

.aisa-message-user .aisa-message-content a:hover {
    color: #e2e8f0;
    text-decoration: none;
}

.aisa-message-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
}

.aisa-message-user .aisa-message-time {
    text-align: right;
}

/* ============================================
   PRODUCT CARDS - PERFECT 3 PER ROW
   ============================================ */

.aisa-product-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0;
    justify-content: flex-start;
    width: 100%;
}

.aisa-product-card {
    flex: 0 0 calc(33.333% - 10px);
    max-width: calc(33.333% - 10px);
    min-width: 90px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.aisa-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db;
}

/* Product Image */
.aisa-product-image-wrapper {
    width: 100%;
    height: 110px;
    background: #f3f4f6;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.aisa-product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.aisa-product-image-placeholder {
    font-size: 36px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #f3f4f6;
}

/* Product Info */
.aisa-product-info {
    padding: 8px 10px 10px;
}

.aisa-product-name {
    font-size: 12px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    min-height: 32px;
}

.aisa-product-price {
    font-size: 14px;
    font-weight: 700;
    color: #1a56db;
    margin-bottom: 2px;
}

.aisa-product-stock {
    font-size: 10px;
    margin-bottom: 6px;
}

.aisa-product-stock.in-stock {
    color: #16a34a;
}

.aisa-product-stock.out-of-stock {
    color: #dc2626;
}

/* Product Buttons */
.aisa-product-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.aisa-product-btn {
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    min-width: 40px;
}

.aisa-product-btn-view {
    background: #e5e7eb;
    color: #111827;
}

.aisa-product-btn-view:hover {
    background: #d1d5db;
    color: #000000;
    transform: scale(1.02);
}

.aisa-product-btn-cart {
    background: #22c55e;
    color: #ffffff;
}

.aisa-product-btn-cart:hover {
    background: #16a34a;
    transform: scale(1.02);
}

/* Typing */
.aisa-typing {
    display: none;
    padding: 10px 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    align-self: flex-start;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.aisa-typing.active {
    display: block;
}

.aisa-typing-dots {
    display: flex;
    gap: 4px;
}

.aisa-typing-dots span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.aisa-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.aisa-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input */
.aisa-chat-input-area {
    padding: 12px 16px 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    background: white;
    flex-shrink: 0;
}

.aisa-chat-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 0 12px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.aisa-chat-input-wrapper:focus-within {
    border-color: #1a56db;
}

.aisa-chat-input {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.aisa-chat-input::placeholder {
    color: #94a3b8;
}

.aisa-chat-send {
    padding: 10px 20px;
    background: linear-gradient(135deg, #1a56db 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    flex-shrink: 0;
}

.aisa-chat-send:hover {
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .aisa-chat-widget {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .aisa-chat-container {
        bottom: 20px !important;
        right: 20px !important;
    }
    
    .aisa-chat-toggle {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    
    .aisa-welcome {
        padding: 16px;
    }
    
    .aisa-welcome-icon {
        font-size: 36px;
    }
    
    .aisa-welcome-title {
        font-size: 16px;
    }
    
    .aisa-product-card {
        flex: 0 0 calc(50% - 6px);
        max-width: calc(50% - 6px);
        min-width: 70px;
    }
    
    .aisa-product-image-wrapper {
        height: 85px;
    }
    
    .aisa-product-name {
        font-size: 11px;
        min-height: 28px;
    }
    
    .aisa-product-price {
        font-size: 13px;
    }
    
    .aisa-product-btn {
        font-size: 10px;
        padding: 4px 8px;
    }
}

@media (max-width: 480px) {
    .aisa-product-card {
        flex: 0 0 calc(50% - 4px);
        max-width: calc(50% - 4px);
        min-width: 60px;
    }
    
    .aisa-product-image-wrapper {
        height: 70px;
    }
    
    .aisa-product-name {
        font-size: 10px;
        min-height: 24px;
    }
    
    .aisa-product-price {
        font-size: 12px;
    }
    
    .aisa-product-info {
        padding: 6px 8px 8px;
    }
    
    .aisa-product-btn {
        font-size: 9px;
        padding: 3px 6px;
    }
}