/* ═══════════════════════════════════════════════
   Art4Ever Chatbot — Widget Flottant
   ═══════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────── */
:root {
    --a4e-primary:    #1a1a2e;
    --a4e-accent:     #c9a84c;
    --a4e-accent-hover: #b8932f;
    --a4e-bg-window:  #f8f7f4;
    --a4e-bg-bot:     #ffffff;
    --a4e-bg-user:    #1a1a2e;
    --a4e-text:       #2d2d2d;
    --a4e-text-light: #ffffff;
    --a4e-border:     #e5e2da;
    --a4e-shadow:     0 8px 32px rgba(0, 0, 0, 0.18);
    --a4e-radius:     12px;
    --a4e-radius-sm:  8px;
    --a4e-font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Widget container ──────────────────────── */
#a4e-chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--a4e-font);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Bouton flottant ───────────────────────── */
#a4e-chatbot-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--a4e-primary);
    color: var(--a4e-text-light);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: var(--a4e-shadow);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--a4e-font);
    transition: transform 0.2s, background 0.2s;
    white-space: nowrap;
}

#a4e-chatbot-toggle:hover {
    transform: scale(1.05);
    background: #2a2a4e;
}

.a4e-toggle-icon {
    font-size: 18px;
}

/* Quand le chat est ouvert, on cache le bouton */
#a4e-chatbot-widget.a4e-chatbot-open #a4e-chatbot-toggle {
    display: none;
}

/* ── Fenêtre de chat ───────────────────────── */
#a4e-chatbot-window {
    display: none;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 100px);
    background: var(--a4e-bg-window);
    border-radius: var(--a4e-radius);
    box-shadow: var(--a4e-shadow);
    overflow: hidden;
    border: 1px solid var(--a4e-border);
}

#a4e-chatbot-widget.a4e-chatbot-open #a4e-chatbot-window {
    display: flex;
    animation: a4e-slideUp 0.3s ease;
}

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

/* ── Header ────────────────────────────────── */
.a4e-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--a4e-primary);
    color: var(--a4e-text-light);
    flex-shrink: 0;
}

.a4e-chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.a4e-chat-header-icon {
    font-size: 20px;
}

.a4e-chat-header-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
}

#a4e-chatbot-close {
    background: none;
    border: none;
    color: var(--a4e-text-light);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#a4e-chatbot-close:hover {
    opacity: 1;
}

/* ── Zone de messages ──────────────────────── */
#a4e-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#a4e-chat-messages::-webkit-scrollbar {
    width: 4px;
}

#a4e-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* ── Bulles de messages ────────────────────── */
.a4e-msg {
    display: flex;
    max-width: 85%;
}

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

.a4e-msg-user {
    align-self: flex-end;
}

.a4e-msg-bubble {
    padding: 10px 14px;
    border-radius: var(--a4e-radius-sm);
    word-wrap: break-word;
    font-size: 13.5px;
    line-height: 1.55;
}

.a4e-msg-bot .a4e-msg-bubble {
    background: var(--a4e-bg-bot);
    color: var(--a4e-text);
    border: 1px solid var(--a4e-border);
    border-bottom-left-radius: 2px;
}

.a4e-msg-user .a4e-msg-bubble {
    background: var(--a4e-bg-user);
    color: var(--a4e-text-light);
    border-bottom-right-radius: 2px;
}

/* ── Indicateur de frappe ──────────────────── */
.a4e-typing .a4e-msg-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
}

.a4e-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: a4e-bounce 1.2s infinite;
}

.a4e-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.a4e-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Cartes produits ───────────────────────── */
.a4e-products {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 8px 0;
    scrollbar-width: thin;
}

.a4e-products::-webkit-scrollbar {
    height: 4px;
}

.a4e-products::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.a4e-product-card {
    flex: 0 0 140px;
    background: #fff;
    border-radius: var(--a4e-radius-sm);
    border: 1px solid var(--a4e-border);
    overflow: hidden;
    text-decoration: none;
    color: var(--a4e-text);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.a4e-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.a4e-product-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    background: #f0ede6;
}

.a4e-product-card-body {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.a4e-product-name {
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.a4e-product-artist {
    font-size: 10.5px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.a4e-product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-top: 1px solid var(--a4e-border);
    margin-top: auto;
}

.a4e-product-price {
    font-weight: 700;
    font-size: 13px;
    color: var(--a4e-accent-hover);
}

.a4e-product-link {
    font-size: 11px;
    color: var(--a4e-accent);
    font-weight: 600;
    text-decoration: none;
}

.a4e-product-link:hover {
    text-decoration: underline;
}

/* ── Formulaire de saisie ──────────────────── */
#a4e-chat-form {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid var(--a4e-border);
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

#a4e-chat-input {
    flex: 1;
    border: 1px solid var(--a4e-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: var(--a4e-font);
    outline: none;
    transition: border-color 0.2s;
    background: var(--a4e-bg-window);
}

#a4e-chat-input:focus {
    border-color: var(--a4e-accent);
}

#a4e-chat-input::placeholder {
    color: #aaa;
}

#a4e-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--a4e-accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#a4e-chat-send:hover {
    background: var(--a4e-accent-hover);
}

#a4e-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 480px) {
    #a4e-chatbot-widget {
        bottom: 12px;
        right: 12px;
    }

    #a4e-chatbot-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
    }

    .a4e-toggle-label {
        display: none;
    }

    #a4e-chatbot-toggle {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        padding: 0;
        justify-content: center;
    }

    .a4e-toggle-icon {
        font-size: 22px;
    }
}
