﻿/* ========================================
   CHATBOT WIDGET - STYLES (VERSION CORRIGÉE)
   ======================================== */

.chatbot-widget {
    position: fixed;
    z-index: 99999; /* ⚡ Augmenté pour être au-dessus de tout */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

    /* Positionnement - CORRIGÉ */
    .chatbot-widget.bottom-right {
        bottom: 20px;
        right: 20px;
        /* ⚡ AJOUT: Force le positionnement */
        left: auto !important;
        top: auto !important;
    }

    .chatbot-widget.bottom-left {
        bottom: 20px;
        left: 20px;
        /* ⚡ AJOUT: Force le positionnement */
        right: auto !important;
        top: auto !important;
    }

/* Bouton flottant - CORRIGÉ */
.chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--dynamic-color-punch, #667eea);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative; /* ⚡ AJOUT */
    z-index: 100000; /* ⚡ AJOUT */
}

    .chatbot-toggle-btn:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    }

    .chatbot-toggle-btn:active {
        transform: scale(0.95);
    }

/* Badge de notification */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Fenêtre de chat - CORRIGÉ */
.chatbot-window {
    position: absolute; /* ⚡ Changé de absolute à fixed peut aider */
    bottom: 80px;
    right: 0; /* ⚡ AJOUT pour .bottom-right */
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatbotSlideUp 0.3s ease;
    z-index: 99998; /* ⚡ AJOUT */
}

/* ⚡ AJOUT: Position pour bottom-left */
.chatbot-widget.bottom-left .chatbot-window {
    left: 0;
    right: auto;
}

@keyframes chatbotSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chatbot-header {
    background: var(--dynamic-color-punch, #667eea);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* ⚡ AJOUT */
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

    .chatbot-header-info i {
        font-size: 20px;
    }

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.chatbot-action-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

    .chatbot-action-btn:hover {
        background: rgba(255,255,255,0.3);
    }

/* Zone de messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

    /* Scrollbar custom */
    .chatbot-messages::-webkit-scrollbar {
        width: 6px;
    }

    .chatbot-messages::-webkit-scrollbar-track {
        background: transparent;
    }

    .chatbot-messages::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 3px;
    }

        .chatbot-messages::-webkit-scrollbar-thumb:hover {
            background: #999;
        }

/* Message individuel */
.chatbot-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: chatbotMessageFadeIn 0.3s ease;
}

@keyframes chatbotMessageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message.user {
    flex-direction: row-reverse;
}

.chatbot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--dynamic-color-punch, #667eea);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chatbot-message.user .chatbot-avatar {
    background: #28a745;
}

.chatbot-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 70%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
}

.chatbot-message.bot .chatbot-message-content {
    background: #f0f0f0;
    border-bottom-left-radius: 4px;
}

.chatbot-message.user .chatbot-message-content {
    background: var(--dynamic-color-punch, #667eea);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message.error .chatbot-message-content {
    background: #ffebee;
    color: #c62828;
    border-left: 3px solid #c62828;
}

.chatbot-timestamp {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

/* Indicateur de frappe */
.chatbot-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

    .chatbot-typing-dots span {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--dynamic-color-punch, #667eea);
        animation: chatbotTypingBounce 1.4s infinite;
    }

        .chatbot-typing-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .chatbot-typing-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes chatbotTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Zone d'input */
.chatbot-input-container {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #eee;
    flex-shrink: 0; /* ⚡ AJOUT */
}

.chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.2s;
    max-height: 120px;
    overflow-y: auto;
}

    .chatbot-input:focus {
        outline: none;
        border-color: var(--dynamic-color-punch, #667eea);
    }

.chatbot-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--dynamic-color-punch, #667eea);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

    .chatbot-send-btn:hover {
        transform: scale(1.05);
    }

    .chatbot-send-btn:active {
        transform: scale(0.95);
    }

    .chatbot-send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* Character counter */
.chatbot-char-counter {
    padding: 0 20px 12px;
    text-align: right;
    font-size: 11px;
    color: #999;
    background: white;
    flex-shrink: 0; /* ⚡ AJOUT */
}

/* Responsive - AMÉLIORÉ */
@media (max-width: 480px) {
    .chatbot-widget.bottom-right {
        right: 10px !important;
        bottom: 10px !important;
    }

    .chatbot-widget.bottom-left {
        left: 10px !important;
        bottom: 10px !important;
    }

    .chatbot-window {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 100px) !important;
        bottom: 70px !important;
        right: 0 !important;
        left: 0 !important;
        margin: 0 10px !important;
    }

    .chatbot-toggle-btn {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
}

/* ⚡ AJOUT: Debug mode (supprimer après test) */
.chatbot-widget[data-debug="true"] {
    border: 2px solid red !important;
}

    .chatbot-widget[data-debug="true"] .chatbot-toggle-btn {
        border: 2px solid lime !important;
    }

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    .chatbot-window,
    .chatbot-message,
    .chatbot-typing-dots span {
        animation: none;
    }
}

/* ⚡ AJOUT: Empêcher les conflits avec d'autres éléments */
.chatbot-widget * {
    box-sizing: border-box;
}
