/* AI Shopping Assistant - Conversational Chat Widget */

/* =============================================
   CSS VARIABLES - Inherit from Odoo website theme
   ============================================= */
:root {
    --ai-assist-primary: var(--o-color-1, #2563eb);
    --ai-assist-primary-hover: var(--o-color-2, #1d4ed8);
    --ai-assist-bg: #ffffff;
    --ai-assist-bg-muted: #f8f9fa;
    --ai-assist-text: #1f2937;
    --ai-assist-text-muted: #6b7280;
    --ai-assist-border: #e5e7eb;
    --ai-assist-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --ai-assist-radius: 16px;
    --ai-assist-bubble-user: var(--o-color-1, #2563eb);
    --ai-assist-bubble-bot: #f1f3f5;
}

/* =============================================
   FLOATING TRIGGER BUBBLE
   ============================================= */
.ai-assist-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99998;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--ai-assist-primary);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
}

.ai-assist-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.25);
    background: var(--ai-assist-primary-hover);
}

.ai-assist-bubble-icon {
    font-size: 20px;
    line-height: 1;
}

.ai-assist-bubble-text {
    white-space: nowrap;
}

.ai-assist-bubble.collapsed {
    padding: 14px;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    justify-content: center;
}

.ai-assist-bubble.collapsed .ai-assist-bubble-text {
    display: none;
}

/* Pulse animation on load to draw attention */
@keyframes ai-assist-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2); }
    50% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), 0 0 0 8px rgba(37, 99, 235, 0.15); }
}

.ai-assist-bubble.pulse {
    animation: ai-assist-pulse 2s ease-in-out 3;
}

/* Hide bubble when chat is open */
.ai-assist-bubble.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* =============================================
   CHAT PANEL
   ============================================= */
.ai-assist-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    width: 400px;
    max-height: 600px;
    height: calc(100vh - 120px);
    background: var(--ai-assist-bg);
    border-radius: var(--ai-assist-radius);
    box-shadow: var(--ai-assist-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

.ai-assist-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* =============================================
   CHAT HEADER
   ============================================= */
.ai-assist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--ai-assist-primary);
    color: #fff;
    flex-shrink: 0;
}

.ai-assist-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-assist-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.ai-assist-header-name {
    font-size: 15px;
    font-weight: 600;
}

.ai-assist-header-status {
    font-size: 12px;
    opacity: 0.85;
}

.ai-assist-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
    border-radius: 6px;
}

.ai-assist-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* =============================================
   CHAT MESSAGES AREA
   ============================================= */
.ai-assist-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.ai-assist-messages::-webkit-scrollbar {
    width: 5px;
}

.ai-assist-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* =============================================
   MESSAGE BUBBLES
   ============================================= */
.ai-assist-msg {
    display: flex;
    gap: 8px;
    max-width: 92%;
    animation: ai-msg-appear 0.3s ease;
}

@keyframes ai-msg-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-assist-msg.bot {
    align-self: flex-start;
}

.ai-assist-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-assist-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ai-assist-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

.ai-assist-msg.user .ai-assist-msg-avatar {
    background: #9ca3af;
}

.ai-assist-msg-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-assist-msg-text {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ai-assist-text);
    word-wrap: break-word;
}

.ai-assist-msg.bot .ai-assist-msg-text {
    background: var(--ai-assist-bubble-bot);
    border-bottom-left-radius: 4px;
}

.ai-assist-msg.user .ai-assist-msg-text {
    background: var(--ai-assist-bubble-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* =============================================
   SUGGESTION CHIPS
   ============================================= */
.ai-assist-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px;
}

.ai-assist-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: var(--ai-assist-bg);
    border: 1.5px solid var(--ai-assist-primary);
    border-radius: 20px;
    color: var(--ai-assist-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.3;
    font-family: inherit;
}

.ai-assist-chip:hover {
    background: var(--ai-assist-primary);
    color: #fff;
}

/* =============================================
   PRODUCT CARDS (inside chat)
   ============================================= */
.ai-assist-products {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 4px 8px 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.ai-assist-products::-webkit-scrollbar {
    display: none;
}

.ai-assist-product-card {
    flex: 0 0 160px;
    scroll-snap-align: start;
    background: var(--ai-assist-bg);
    border: 1px solid var(--ai-assist-border);
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: var(--ai-assist-text);
    transition: box-shadow 0.15s, transform 0.15s;
    display: flex;
    flex-direction: column;
}

.ai-assist-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--ai-assist-text);
}

.ai-assist-product-img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    background: #f9fafb;
    padding: 8px;
}

.ai-assist-product-img-placeholder {
    width: 100%;
    height: 120px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 12px;
}

.ai-assist-product-body {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.ai-assist-product-name {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--ai-assist-text);
}

.ai-assist-product-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--ai-assist-primary);
    margin-top: auto;
}

.ai-assist-product-price-sale {
    color: #dc2626;
}

.ai-assist-product-price-original {
    font-size: 11px;
    font-weight: 400;
    color: #9ca3af;
    text-decoration: line-through;
    margin-left: 4px;
}

.ai-assist-product-stock {
    font-size: 11px;
    color: #6b7280;
}

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

.ai-assist-product-btn {
    display: block;
    text-align: center;
    padding: 6px;
    background: var(--ai-assist-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
}

.ai-assist-product-btn:hover {
    background: var(--ai-assist-primary-hover);
    color: #fff;
    text-decoration: none;
}

/* "View all X results" link */
.ai-assist-view-all {
    font-size: 13px;
    color: var(--ai-assist-primary);
    cursor: pointer;
    padding: 4px;
    text-align: center;
    font-weight: 500;
}

.ai-assist-view-all:hover {
    text-decoration: underline;
}

/* =============================================
   TYPING INDICATOR
   ============================================= */
.ai-assist-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--ai-assist-bubble-bot);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.ai-assist-typing-dot {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: ai-typing-bounce 1.4s infinite ease-in-out;
}

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

.ai-assist-typing-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes ai-typing-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* =============================================
   INPUT AREA
   ============================================= */
.ai-assist-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--ai-assist-border);
    background: var(--ai-assist-bg);
    flex-shrink: 0;
}

.ai-assist-input {
    flex: 1;
    border: 1.5px solid var(--ai-assist-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    background: var(--ai-assist-bg);
    color: var(--ai-assist-text);
}

.ai-assist-input:focus {
    border-color: var(--ai-assist-primary);
}

.ai-assist-input::placeholder {
    color: #9ca3af;
}

.ai-assist-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--ai-assist-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}

.ai-assist-send:hover {
    background: var(--ai-assist-primary-hover);
}

.ai-assist-send:active {
    transform: scale(0.95);
}

.ai-assist-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =============================================
   POWERED BY FOOTER
   ============================================= */
.ai-assist-footer {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #9ca3af;
    background: var(--ai-assist-bg-muted);
    flex-shrink: 0;
}

/* =============================================
   RESPONSIVE - Mobile full screen
   ============================================= */
@media (max-width: 480px) {
    .ai-assist-panel {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .ai-assist-bubble {
        bottom: 16px;
        right: 16px;
    }

    .ai-assist-product-card {
        flex: 0 0 140px;
    }

    .ai-assist-product-img {
        height: 100px;
    }
}

/* =============================================
   ERROR STATE
   ============================================= */
.ai-assist-error {
    padding: 10px 14px;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 12px;
    font-size: 13px;
    text-align: center;
}
