* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.bot-avatar {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    min-width: 50px;
    min-height: 50px;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: none;
    display: block;
}

.header-info h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 5px;
}

.status {
    font-size: 14px;
    opacity: 0.9;
}

.clear-chat {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s;
}

.clear-chat:hover {
    background: rgba(255, 255, 255, 0.3);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 15px;
    max-width: 80%;
    align-items: flex-start;
    position: relative;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.bot-message .message-content {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
}

.message-content {
    padding: 15px 20px;
    border-radius: 20px;
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.6;
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.user-message .bot-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.bot-message .bot-avatar {
    background: #f8f9fa;
    color: #667eea;
    border: 2px solid #e9ecef;
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.welcome-message {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    min-width: 40px;
    min-height: 40px;
}

.bot-message .bot-avatar .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: none;
    display: block;
}

.welcome-message .bot-avatar {
    background: #f8f9fa;
    color: #667eea;
    border: 2px solid #e9ecef;
    width: 40px;
    height: 40px;
    font-size: 18px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    min-width: 40px;
    min-height: 40px;
}

.welcome-message .bot-avatar .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: none;
    display: block;
}

.welcome-message .message-content {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
}

.input-container {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.input-wrapper {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    background: white;
    border-radius: 25px;
    padding: 5px;
    border: 2px solid #e9ecef;
    transition: border-color 0.3s;
}

.input-wrapper:focus-within {
    border-color: #667eea;
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    padding: 15px 20px;
    font-size: 16px;
    resize: none;
    background: transparent;
    font-family: inherit;
    line-height: 1.4;
}

.send-button {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: transform 0.2s, box-shadow 0.3s;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.loading-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Scrollbar personnalisée */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .chat-container {
        height: 95vh;
        border-radius: 15px;
    }

    .chat-header {
        padding: 15px;
    }

    .header-info h1 {
        font-size: 20px;
    }

    .bot-avatar {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .message {
        max-width: 90%;
    }

    .messages-container {
        padding: 15px;
    }

    .input-container {
        padding: 15px;
    }
}

/* Animation d'apparition des messages */
.message {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Notification mode démo */
.demo-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 15px;
    max-width: 350px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

.demo-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.demo-content i {
    color: #f59e0b;
    font-size: 20px;
    margin-top: 2px;
}

.demo-content strong {
    color: #92400e;
    display: block;
    margin-bottom: 4px;
}

.demo-content p {
    color: #92400e;
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Styles de protection pour les avatars */
.bot-avatar img {
    max-width: none !important;
    max-height: none !important;
    width: 100% !important;
    height: 100% !important;
}

/* Gestion des erreurs d'image */
.avatar-image {
    background-color: #f8f9fa;
}

.avatar-image:error {
    display: none;
}

.bot-avatar:has(.avatar-image:error)::before {
    content: "🤖";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    z-index: 5;
}

@media (max-width: 768px) {
    .demo-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .bot-avatar {
        min-width: 40px;
        min-height: 40px;
    }
}
