/* ChatBot Styles - Interface moderne et fluide avec IA */

/* Variables CSS pour la cohérence */
:root {
    --chatbot-primary: #667eea;
    --chatbot-secondary: #764ba2;
    --chatbot-success: #2ecc71;
    --chatbot-danger: #ff4757;
    --chatbot-warning: #ffa502;
    --chatbot-ai: #667eea;
    --chatbot-local: #2ecc71;
    --chatbot-error: #ff4757;
    --chatbot-shadow: rgba(102, 126, 234, 0.3);
    --chatbot-border-radius: 12px;
    --chatbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Bouton d'ouverture du chat */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 8px 25px var(--chatbot-shadow);
    transition: var(--chatbot-transition);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

.chatbot-toggle.active {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
}

/* Notification badge */
.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: var(--chatbot-danger);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Container du ChatBot */
.chatbot-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-container.active {
    display: flex;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* En-tête du ChatBot */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chatbot-status {
    flex: 1;
}

.chatbot-name {
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

.chatbot-online {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Indicateurs de statut améliorés */
.online-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: var(--chatbot-transition);
    position: relative;
}

/* Statut IA activée */
.online-indicator.ai-enabled {
    background: var(--chatbot-ai);
    animation: aiPulse 2s infinite;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.6);
}

@keyframes aiPulse {
    0%, 50% {
        opacity: 1;
        transform: scale(1);
    }
    25% {
        opacity: 0.7;
        transform: scale(1.2);
    }
    75% {
        opacity: 0.9;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mode IA */
.online-indicator.local-mode {
    background: var(--chatbot-local);
    animation: blink 1.5s infinite;
}

/* État d'erreur */
.online-indicator.error-state {
    background: var(--chatbot-error);
    animation: errorBlink 1s infinite;
}

@keyframes errorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* État en ligne normal */
.online-indicator.online {
    background: var(--chatbot-success);
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Corps du ChatBot */
.chatbot-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Zone de messages */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Messages individuels */
.message {
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

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

.message.bot {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.message.user {
    display: flex;
    justify-content: flex-end;
}

.bot-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--chatbot-border-radius);
    word-wrap: break-word;
    line-height: 1.5;
    position: relative;
}

.message.bot .message-content {
    background: #f8f9fa;
    border-bottom-left-radius: 4px;
    color: #2c3e50;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Source des messages */
.message-source {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    display: inline-block;
    font-weight: 500;
}

/* Indicateurs de source par couleur */
.message[data-source="ai"] .message-content {
    border-left: 3px solid var(--chatbot-ai);
}

.message[data-source="local"] .message-content {
    border-left: 3px solid var(--chatbot-local);
}

.message[data-source="default"] .message-content {
    border-left: 3px solid var(--chatbot-warning);
}

/* Indicateur de frappe amélioré */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    margin: 0 20px 20px 20px;
    animation: fadeInUp 0.3s ease;
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #bdc3c7;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

.typing-text {
    font-size: 12px;
    color: #7f8c8d;
    font-style: italic;
    margin-left: 8px;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Zone de saisie */
.chatbot-input-area {
    padding: 20px;
    border-top: 1px solid #ecf0f1;
    background: #fafbfc;
}

.chatbot-input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: white;
    border-radius: var(--chatbot-border-radius);
    padding: 8px;
    border: 2px solid #ecf0f1;
    transition: var(--chatbot-transition);
}

.chatbot-input-container:focus-within {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 80px;
    min-height: 20px;
    padding: 4px 0;
}

.chatbot-send {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chatbot-transition);
    flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--chatbot-shadow);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Suggestions rapides améliorées */
.quick-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.suggestion-chip {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--chatbot-transition);
    color: #5a6c7d;
    font-weight: 500;
}

.suggestion-chip:hover {
    background: var(--chatbot-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

/* Messages de bienvenue */
.welcome-message {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--chatbot-border-radius);
    padding: 16px;
    margin-bottom: 16px;
    border-left: 4px solid var(--chatbot-primary);
}

.welcome-message h4 {
    margin: 0 0 8px 0;
    color: var(--chatbot-primary);
    font-size: 14px;
}

.welcome-message p {
    margin: 0;
    font-size: 13px;
    color: #6c757d;
}

/* Scrollbar personnalisée */
.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* Responsive design */
@media (max-width: 768px) {
    .chatbot-container {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-width: none;
        max-height: none;
    }

    .chatbot-toggle {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 20px;
    }
}

/* Formatage du contenu des messages */
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 0 0 8px 0;
    font-weight: 600;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 16px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content strong {
    font-weight: 600;
    color: var(--chatbot-primary);
}

/* Animations réduites pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
    .chatbot-container {
        animation: none;
    }

    .message {
        animation: none;
    }

    .typing-dot {
        animation: none;
    }

    .online-indicator {
        animation: none !important;
    }

    * {
        transition: none !important;
    }
}

/* États spéciaux pour les messages d'erreur et de retry */
.message[data-source="error"] .message-content {
    background: #fff5f5;
    border-left: 3px solid var(--chatbot-error);
    color: #c53030;
}

.message[data-source="retry"] .message-content {
    background: #fffbeb;
    border-left: 3px solid var(--chatbot-warning);
    color: #d69e2e;
}

/* Amélioration de l'accessibilité */
.chatbot-toggle:focus,
.chatbot-send:focus,
.suggestion-chip:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: 2px;
}

/* Indicateur de connexion dans l'en-tête */
.chatbot-header.ai-enabled {
    background: linear-gradient(135deg, var(--chatbot-ai) 0%, #5a67d8 100%);
}

.chatbot-header.local-mode {
    background: linear-gradient(135deg, var(--chatbot-local) 0%, #48bb78 100%);
}

.chatbot-header.error-state {
    background: linear-gradient(135deg, var(--chatbot-error) 0%, #e53e3e 100%);
}
