/**
 * Vintajj AI Chat - v25 Design System
 * v6.7 - Full styles with snake-fill progress indicator
 */

/* ================================ */
/* Chat Container                   */
/* ================================ */
.v25-ai-chat {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: 70vh;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ================================ */
/* Chat Header                      */
/* ================================ */
.v25-ai-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #A65A3C 0%, #8B4A32 100%);
    color: #fff;
}

.v25-ai-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.v25-ai-chat-avatar svg {
    width: 24px;
    height: 24px;
}

.v25-ai-chat-title {
    flex: 1;
}

.v25-ai-chat-name {
    display: block;
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 1.25rem;
    font-weight: 600;
}

.v25-ai-chat-status {
    display: block;
    font-family: "Inter", sans-serif;
    font-size: 0.75rem;
    opacity: 0.8;
}

.v25-ai-chat-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.v25-ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ================================ */
/* Messages Container               */
/* ================================ */
.v25-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #F5EFE7;
}

/* ================================ */
/* Message Bubbles                  */
/* ================================ */
.v25-ai-message {
    max-width: 85%;
    animation: v25-message-appear 0.3s ease;
}

@keyframes v25-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.v25-ai-message-user {
    align-self: flex-end;
}

.v25-ai-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-family: "Inter", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.v25-ai-message-assistant .v25-ai-message-content {
    background: #fff;
    color: #1c1917;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.v25-ai-message-user .v25-ai-message-content {
    background: #A65A3C;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ================================ */
/* Typing Indicator Dots            */
/* ================================ */
.v25-ai-typing-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background: #A65A3C;
    border-radius: 50%;
    animation: v25-typing-bounce 1.4s infinite ease-in-out both;
}

.v25-ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.v25-ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.v25-ai-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes v25-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ================================ */
/* Progress Indicator (Snake-fill)  */
/* Pure CSS animation               */
/* ================================ */
.v25-ai-typing .v25-ai-message-content {
    position: relative;
    overflow: visible;
    background: transparent !important;
    box-shadow: none !important;
    isolation: isolate;
}

/* Lighter terracotta filling border - CSS animated */
.v25-ai-typing .v25-ai-message-content::before {
    content: "";
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 20px;
    background: conic-gradient(from -90deg, #C4A68A 0deg, #E8E2DA 0deg);
    animation: v25-snake-progress 20s ease-out forwards;
    z-index: -2;
}

/* Inner white background */
.v25-ai-typing .v25-ai-message-content::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px;
    background: #fff;
    z-index: -1;
}

.v25-ai-typing .v25-ai-typing-dot {
    position: relative;
    z-index: 1;
}

/* Snake progress animation - logarithmic curve */
@keyframes v25-snake-progress {
    0%   { background: conic-gradient(from -90deg, #C4A68A 0deg, #E8E2DA 0deg); }
    2%   { background: conic-gradient(from -90deg, #C4A68A 25deg, #E8E2DA 25deg); }
    5%   { background: conic-gradient(from -90deg, #C4A68A 50deg, #E8E2DA 50deg); }
    10%  { background: conic-gradient(from -90deg, #C4A68A 90deg, #E8E2DA 90deg); }
    15%  { background: conic-gradient(from -90deg, #C4A68A 120deg, #E8E2DA 120deg); }
    20%  { background: conic-gradient(from -90deg, #C4A68A 145deg, #E8E2DA 145deg); }
    30%  { background: conic-gradient(from -90deg, #C4A68A 180deg, #E8E2DA 180deg); }
    40%  { background: conic-gradient(from -90deg, #C4A68A 210deg, #E8E2DA 210deg); }
    50%  { background: conic-gradient(from -90deg, #C4A68A 235deg, #E8E2DA 235deg); }
    60%  { background: conic-gradient(from -90deg, #C4A68A 260deg, #E8E2DA 260deg); }
    70%  { background: conic-gradient(from -90deg, #C4A68A 280deg, #E8E2DA 280deg); }
    80%  { background: conic-gradient(from -90deg, #C4A68A 300deg, #E8E2DA 300deg); }
    90%  { background: conic-gradient(from -90deg, #C4A68A 320deg, #E8E2DA 320deg); }
    100% { background: conic-gradient(from -90deg, #C4A68A 340deg, #E8E2DA 340deg); }
}


/* Input Area                       */
/* ================================ */
.v25-ai-chat-input-area {
    padding: 0;
    background: #fff;
    border-top: 1px solid #E8E2DA;
}

.v25-ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px 8px;
}

.v25-ai-suggestion {
    padding: 6px 12px;
    background: #F5EFE7;
    border: 1px solid #E8E2DA;
    border-radius: 16px;
    font-family: "Inter", sans-serif;
    font-size: 12px;
    color: #57534e;
    cursor: pointer;
    transition: all 0.2s;
}

.v25-ai-suggestion:hover {
    background: #A65A3C;
    border-color: #A65A3C;
    color: #fff;
}

.v25-ai-chat-form {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    gap: 12px;
}

.v25-ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    background: #F5EFE7;
    border: 1px solid #E8E2DA;
    border-radius: 20px;
    font-family: "Inter", sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.v25-ai-chat-input:focus {
    border-color: #A65A3C;
}

.v25-ai-chat-input::placeholder {
    color: #a8a29e;
}

.v25-ai-chat-send {
    width: 40px;
    height: 40px;
    background: #A65A3C;
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.v25-ai-chat-send:hover {
    background: #8B4A32;
    transform: scale(1.05);
}

.v25-ai-chat-send:disabled {
    background: #d6d3d1;
    cursor: not-allowed;
    transform: none;
}

/* ================================ */
/* Product Cards in Chat            */
/* ================================ */
.v25-ai-products {
    margin-top: 12px;
}

.v25-ai-products-title {
    font-family: "Inter", sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #78716c;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.v25-ai-products-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.v25-ai-product-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #F5EFE7;
    border: 1px solid #E8E2DA;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.v25-ai-product-card:hover {
    border-color: #A65A3C;
    box-shadow: 0 2px 8px rgba(166, 90, 60, 0.15);
}

.v25-ai-product-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    display: block;
}

.v25-ai-product-card img,
.v25-ai-product-image img {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.v25-ai-product-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.v25-ai-product-name {
    font-family: "Inter", sans-serif;
    font-size: 13px;
    color: #1c1917;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-decoration: none;
    word-break: break-word;
}

.v25-ai-product-name:hover {
    color: #A65A3C;
}

.v25-ai-product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.v25-ai-product-sku {
    font-family: "Inter", sans-serif;
    font-size: 11px;
    color: #78716c;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v25-ai-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 1px solid #E8E2DA;
    border-radius: 4px;
    color: #78716c;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.v25-ai-copy-btn:hover {
    background: #fff;
    border-color: #A65A3C;
    color: #A65A3C;
}

.v25-ai-copy-btn.v25-ai-copy-success {
    background: #f0fdf4;
    border-color: #86efac;
    color: #16a34a;
}

.v25-ai-product-price {
    font-family: "Inter", sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #A65A3C;
    white-space: nowrap;
    flex-shrink: 0;
}


/* Broken image fallback */
.v25-ai-product-image img[alt]::after,
.v25-ai-product-card img[alt]::after {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #F5EFE7 url('/wa-data/public/shop/themes/vintajj-2025/img/placeholder.svg') center/cover no-repeat;
    border-radius: 8px;
}

.v25-ai-product-image {
    position: relative;
    background: #F5EFE7;
}

.v25-ai-product-image img,
.v25-ai-product-card > a > img {
    background: #F5EFE7;
}

/* ================================ */
/* Mobile Responsive                */
/* ================================ */
@media (max-width: 480px) {
    .v25-ai-chat {
        bottom: 70px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        max-height: 80vh;
        border-radius: 16px;
    }

    .v25-ai-chat-header {
        padding: 12px 16px;
    }

    .v25-ai-chat-name {
        font-size: 1.1rem;
    }

    .v25-ai-chat-messages {
        padding: 12px;
    }

    .v25-ai-message {
        max-width: 90%;
    }

    .v25-ai-message-content {
        padding: 10px 14px;
        font-size: 13px;
    }

    .v25-ai-chat-suggestions {
        padding: 8px 12px 4px;
    }

    .v25-ai-suggestion {
        font-size: 11px;
        padding: 5px 10px;
    }

    .v25-ai-chat-form {
        padding: 8px 10px;
    }

    .v25-ai-chat-input {
        padding: 8px 12px;
        font-size: 13px;
    }

    .v25-ai-chat-send {
        width: 36px;
        height: 36px;
    }
}
