/**
 * Zolaa Chatbot IA — Widget CSS
 * @author Zolaa
 */

/* =========================================================================
   CSS Custom Properties (set via inline style from config)
   ========================================================================= */
#zolaa-chatbot {
    --zolaa-primary: #4F46E5;
    --zolaa-secondary: #F9FAFB;
    --zolaa-text-bot: #1F2937;
    --zolaa-text-user: #FFFFFF;
    --zolaa-bubble-user: #4F46E5;
    --zolaa-radius: 12px;
    --zolaa-font: Inter, system-ui, sans-serif;
    --zolaa-offset-x: 20px;
    --zolaa-offset-y: 20px;
    --zolaa-trigger-size: 60px;
    --zolaa-width: 400px;
    --zolaa-height: 600px;
    --zolaa-shadow: 0 8px 30px rgba(0,0,0,0.12);
    --zolaa-shadow-hover: 0 12px 40px rgba(0,0,0,0.18);
    font-family: var(--zolaa-font);
    z-index: 99999;
}

/* =========================================================================
   Position
   ========================================================================= */
.zolaa-widget {
    position: fixed;
    z-index: 99999;
}

.zolaa-bottom-right {
    right: var(--zolaa-offset-x);
    bottom: var(--zolaa-offset-y);
}

.zolaa-bottom-left {
    left: var(--zolaa-offset-x);
    bottom: var(--zolaa-offset-y);
}

/* =========================================================================
   Trigger Button
   ========================================================================= */
.zolaa-trigger {
    width: var(--zolaa-trigger-size);
    height: var(--zolaa-trigger-size);
    border-radius: 50%;
    background: var(--zolaa-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--zolaa-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 2;
}

.zolaa-trigger:hover {
    transform: scale(1.08);
    box-shadow: var(--zolaa-shadow-hover);
}

.zolaa-trigger:active {
    transform: scale(0.95);
}

.zolaa-trigger-icon {
    transition: opacity 0.2s ease, transform 0.3s ease;
}

.zolaa-trigger.is-open .zolaa-icon-chat { display: none; }
.zolaa-trigger.is-open .zolaa-icon-close { display: block; }

/* =========================================================================
   Chat Window
   ========================================================================= */
.zolaa-window {
    position: absolute;
    bottom: calc(var(--zolaa-trigger-size) + 16px);
    width: var(--zolaa-width);
    max-height: var(--zolaa-height);
    background: #fff;
    border-radius: var(--zolaa-radius);
    box-shadow: var(--zolaa-shadow-hover);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: zolaaSlideUp 0.3s ease;
    z-index: 1;
}

.zolaa-bottom-right .zolaa-window { right: 0; }
.zolaa-bottom-left .zolaa-window { left: 0; }

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

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

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

.zolaa-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.zolaa-avatar-default {
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.zolaa-header-name {
    display: block;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.zolaa-header-status {
    display: block;
    font-size: 12px;
    opacity: 0.85;
}

.zolaa-header-actions button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.zolaa-header-actions button:hover { opacity: 1; }

/* =========================================================================
   Messages Area
   ========================================================================= */
.zolaa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--zolaa-secondary);
    min-height: 200px;
    scroll-behavior: smooth;
}

.zolaa-messages::-webkit-scrollbar { width: 4px; }
.zolaa-messages::-webkit-scrollbar-track { background: transparent; }
.zolaa-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Message Bubbles */
.zolaa-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--zolaa-radius);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: zolaaFadeIn 0.3s ease;
}

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

.zolaa-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: var(--zolaa-text-bot);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.zolaa-msg-user {
    align-self: flex-end;
    background: var(--zolaa-bubble-user);
    color: var(--zolaa-text-user);
    border-bottom-right-radius: 4px;
}

.zolaa-msg a {
    color: var(--zolaa-primary);
    text-decoration: underline;
}

.zolaa-msg-user a {
    color: inherit;
}

/* Timestamp */
.zolaa-timestamp {
    text-align: center;
    font-size: 11px;
    color: #9CA3AF;
    margin: 8px 0;
}

/* =========================================================================
   Typing Indicator
   ========================================================================= */
.zolaa-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: var(--zolaa-radius);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.zolaa-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9CA3AF;
    animation: zolaaBounce 1.4s infinite ease-in-out both;
}

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

@keyframes zolaaBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* =========================================================================
   Product Cards
   ========================================================================= */
.zolaa-products-wrapper {
    width: 100%;
    align-self: flex-start;
}

.zolaa-products {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
    width: 100%;
}

.zolaa-product-card {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #E5E7EB;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    animation: zolaaFadeInUp 0.3s ease both;
}

.zolaa-product-card:hover {
    border-color: var(--zolaa-primary);
    box-shadow: 0 2px 12px rgba(79,70,229,0.10);
}

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

.zolaa-product-card:nth-child(2) { animation-delay: 0.06s; }
.zolaa-product-card:nth-child(3) { animation-delay: 0.12s; }
.zolaa-product-card:nth-child(4) { animation-delay: 0.18s; }

.zolaa-product-img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    background: #f9fafb;
    display: block;
    flex-shrink: 0;
    border-radius: 8px;
    margin: 6px;
}

.zolaa-product-body {
    padding: 6px 8px 6px 2px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
    gap: 2px;
}

.zolaa-product-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--zolaa-text-bot);
    line-height: 1.25;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.zolaa-product-price {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.zolaa-price-current {
    font-size: 13px;
    font-weight: 700;
    color: var(--zolaa-primary);
}

.zolaa-price-old {
    font-size: 10px;
    color: #9CA3AF;
    text-decoration: line-through;
}

.zolaa-price-badge {
    font-size: 9px;
    background: #EF4444;
    color: #fff;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 700;
}

.zolaa-stock-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 500;
    display: inline-block;
}

.zolaa-stock-in { background: #D1FAE5; color: #065F46; }
.zolaa-stock-low { background: #FEF3C7; color: #92400E; }
.zolaa-stock-out { background: #FEE2E2; color: #991B1B; }

.zolaa-product-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 1px;
}

.zolaa-product-cta {
    display: inline;
    background: none;
    color: var(--zolaa-primary);
    border: none;
    padding: 0;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.zolaa-product-cta:hover { opacity: 0.7; text-decoration: underline; }

.zolaa-product-cart-btn {
    display: inline;
    background: none;
    color: #6B7280;
    border: none;
    padding: 0;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
    white-space: nowrap;
    margin: 0;
}

.zolaa-product-cart-btn:hover {
    color: var(--zolaa-primary);
}

/* Separator dot between action links */
.zolaa-product-actions-sep {
    color: #D1D5DB;
    font-size: 10px;
    line-height: 1;
}

/* Voir plus button */
.zolaa-see-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 6px 12px;
    margin-top: 4px;
    background: #F9FAFB;
    color: var(--zolaa-primary);
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    font-family: var(--zolaa-font);
}

.zolaa-see-more:hover {
    background: #EEF2FF;
    border-color: var(--zolaa-primary);
}

.zolaa-see-more svg {
    transition: transform 0.2s;
}

.zolaa-see-more:hover svg {
    transform: translateY(1px);
}

/* =========================================================================
   Quick Replies
   ========================================================================= */
.zolaa-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 8px;
    background: var(--zolaa-secondary);
}

.zolaa-quick-reply {
    padding: 6px 14px;
    border: 1.5px solid var(--zolaa-primary);
    border-radius: 20px;
    background: #fff;
    color: var(--zolaa-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.zolaa-quick-reply:hover {
    background: var(--zolaa-primary);
    color: #fff;
}

/* =========================================================================
   Input Area
   ========================================================================= */
.zolaa-input-area {
    background: #fff;
    border-top: 1px solid #E5E7EB;
    flex-shrink: 0;
}

.zolaa-form {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
}

.zolaa-input {
    flex: 1;
    border: 1.5px solid #E5E7EB;
    border-radius: calc(var(--zolaa-radius) - 2px);
    padding: 9px 14px;
    font-size: 14px;
    font-family: var(--zolaa-font);
    outline: none;
    transition: border-color 0.2s;
    background: var(--zolaa-secondary);
}

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

.zolaa-input::placeholder {
    color: #9CA3AF;
}

.zolaa-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--zolaa-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.15s;
}

.zolaa-send-btn:hover { opacity: 0.9; }
.zolaa-send-btn:active { transform: scale(0.92); }
.zolaa-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.zolaa-powered {
    text-align: center;
    font-size: 10px;
    color: #9CA3AF;
    padding: 0 12px 8px;
}

.zolaa-powered strong { color: var(--zolaa-primary); }

/* =========================================================================
   GDPR Banner
   ========================================================================= */
.zolaa-gdpr {
    position: absolute;
    bottom: calc(var(--zolaa-trigger-size) + 16px);
    width: 320px;
    background: #fff;
    border-radius: var(--zolaa-radius);
    box-shadow: var(--zolaa-shadow-hover);
    padding: 16px;
    z-index: 3;
    animation: zolaaSlideUp 0.3s ease;
}

.zolaa-bottom-right .zolaa-gdpr { right: 0; }
.zolaa-bottom-left .zolaa-gdpr { left: 0; }

.zolaa-gdpr p {
    font-size: 13px;
    line-height: 1.5;
    color: #374151;
    margin: 0 0 12px;
}

.zolaa-gdpr-actions {
    display: flex;
    gap: 8px;
}

.zolaa-gdpr-accept {
    flex: 1;
    padding: 8px;
    background: var(--zolaa-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.zolaa-gdpr-decline {
    flex: 1;
    padding: 8px;
    background: #F3F4F6;
    color: #6B7280;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

/* =========================================================================
   Satisfaction Rating
   ========================================================================= */
.zolaa-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
}

.zolaa-rating-star {
    font-size: 22px;
    cursor: pointer;
    transition: transform 0.15s;
    color: #D1D5DB;
}

.zolaa-rating-star:hover,
.zolaa-rating-star.active {
    color: #F59E0B;
    transform: scale(1.15);
}

/* =========================================================================
   Skeleton Loading
   ========================================================================= */
.zolaa-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: zolaaShimmer 1.5s infinite;
    border-radius: 6px;
}

@keyframes zolaaShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.zolaa-skeleton-card {
    width: 240px;
    height: 200px;
    flex-shrink: 0;
}

/* =========================================================================
   Mobile Responsive
   ========================================================================= */
@media (max-width: 480px) {
    .zolaa-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100%;
        border-radius: 0;
        z-index: 100000;
    }

    .zolaa-messages {
        max-height: none;
        flex: 1;
    }

    .zolaa-product-card {
        flex: 0 0 200px;
    }

    .zolaa-product-img {
        height: 100px;
    }

    .zolaa-header {
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .zolaa-input-area {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* =========================================================================
   Reduced Motion
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    .zolaa-trigger,
    .zolaa-window,
    .zolaa-msg,
    .zolaa-product-card,
    .zolaa-typing-dot {
        animation: none !important;
        transition: none !important;
    }
}
