/* ========================================
   CHATBOT PROFESSIONNEL - STYLES
   ======================================== */

/* Container principal du chatbot */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Bouton d'ouverture du chat */
.chatbot-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: pulse-glow 2s infinite;
}

.chatbot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

.chatbot-trigger.active {
    transform: rotate(45deg);
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

/* Badge de notification sur le bouton */
.chatbot-trigger .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ff4444;
    border-radius: 50%;
    border: 2px solid white;
    display: none;
    animation: bounce-notification 0.5s ease-in-out infinite alternate;
}

.chatbot-trigger.has-notification .notification-badge {
    display: block;
}

@keyframes bounce-notification {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.2);
    }
}

/* Animation d'attention pour nouvelle réponse */
@keyframes attention-shake {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-15deg);
    }

    75% {
        transform: rotate(15deg);
    }
}

.chatbot-trigger.new-message {
    animation: attention-shake 0.5s ease-in-out 3;
}

/* Animation du bouton */
@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    }

    50% {
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5), 0 0 0 10px rgba(102, 126, 234, 0.1);
    }
}

/* Fenêtre de chat */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 600px;
    height: 800px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.chatbot-window.show {
    display: flex;
    animation: slideUpFade 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header du chat */
.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-info {
    display: flex;
    align-items: center;
}

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

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

.chatbot-details p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

/* Actions header (boutons) */
.chatbot-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-clear,
.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-clear:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chatbot-close {
    font-size: 20px;
}

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

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

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

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

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

/* Messages */
.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.bot {
    align-items: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 6px;
}

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

.message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    padding: 0 8px;
}

/* Indicateur de frappe */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    margin-bottom: 16px;
    max-width: 80%;
}

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

.typing-dots span {
    height: 6px;
    width: 6px;
    background: #6c757d;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    animation: typing 1.4s infinite ease-in-out;
}

.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.4;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

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

.chatbot-input-form {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 24px;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    transition: border-color 0.2s;
}

.chatbot-input-form:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-input-field {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    line-height: 1.4;
}

.chatbot-input-field::placeholder {
    color: #6c757d;
}

.chatbot-send {
    background: #667eea;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    margin-left: 8px;
}

.chatbot-send:hover {
    background: #5a67d8;
}

.chatbot-send:disabled {
    background: #e9ecef;
    cursor: not-allowed;
}

/* Suggestions rapides */
.quick-suggestions {
    padding: 12px 16px;
    border-top: 1px solid #e9ecef;
    background: #fafbfc;
}

.quick-suggestions h6 {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestion-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.suggestion-btn {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
}

.suggestion-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Badge en ligne */
.online-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #28a745;
    border: 2px solid white;
    border-radius: 50%;
}

/* Responsive */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 10px;
        right: 10px;
    }

    .chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: -10px;
        bottom: 70px;
    }
}

/* Animations d'entrée des messages */
.message-enter {
    opacity: 0;
    transform: translateY(10px);
    animation: messageEnter 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes messageEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* État de connexion */
.connection-status {
    padding: 8px 16px;
    background: #f8d7da;
    color: #721c24;
    font-size: 12px;
    text-align: center;
    border-top: 1px solid #f5c6cb;
}

.connection-status.connected {
    background: #d1edff;
    color: #0c5460;
    border-top-color: #bee5eb;
}

/* ========================================
   MARKDOWN SUPPORT - STYLES
   ======================================== */

/* Paragraphes et texte de base */
.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Headers */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
    margin-top: 0;
}

.message-content h1 {
    font-size: 20px;
}

.message-content h2 {
    font-size: 18px;
}

.message-content h3 {
    font-size: 16px;
}

.message-content h4 {
    font-size: 14px;
}

.message-content h5,
.message-content h6 {
    font-size: 13px;
}

/* Text styling */
.message-content strong,
.message-content b {
    font-weight: 600;
}

.message-content em,
.message-content i {
    font-style: italic;
}

/* Liens */
.message-content .chatbot-link {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
    transition: all 0.2s;
}

.message-content .chatbot-link:hover {
    color: #5a67d8;
    border-bottom-color: #5a67d8;
}

/* Messages utilisateur - liens en blanc */
.message.user .message-content .chatbot-link {
    color: rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.4);
}

.message.user .message-content .chatbot-link:hover {
    color: white;
    border-bottom-color: white;
}

/* Listes */
.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.message-content ul li {
    list-style-type: disc;
}

.message-content ol li {
    list-style-type: decimal;
}

/* Listes imbriquées */
.message-content ul ul,
.message-content ol ul {
    margin: 2px 0;
}

/* Code inline */
.message-content .chatbot-code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: #c7254e;
}

/* Code inline pour messages utilisateur */
.message.user .message-content .chatbot-code {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
}

/* Blocs de code */
.message-content .chatbot-pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.message-content .chatbot-pre code {
    background: none;
    padding: 0;
    color: #2c3e50;
}

/* Blocs de code pour messages utilisateur */
.message.user .message-content .chatbot-pre {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-content .chatbot-pre code {
    color: rgba(255, 255, 255, 0.95);
}

/* Citations */
.message-content .chatbot-blockquote {
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 3px solid #667eea;
    background: rgba(102, 126, 234, 0.05);
    font-style: italic;
    color: #495057;
}

.message.user .message-content .chatbot-blockquote {
    border-left-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
}

/* Ligne horizontale */
.message-content hr {
    margin: 12px 0;
    border: none;
    border-top: 1px solid #e9ecef;
}

.message.user .message-content hr {
    border-top-color: rgba(255, 255, 255, 0.3);
}

/* Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.message-content table th,
.message-content table td {
    padding: 6px 8px;
    border: 1px solid #e9ecef;
    text-align: left;
}

.message-content table th {
    background: #f8f9fa;
    font-weight: 600;
}

.message.user .message-content table th,
.message.user .message-content table td {
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-content table th {
    background: rgba(255, 255, 255, 0.15);
}

/* Scrollbar pour les blocs de code longs */
.message-content .chatbot-pre::-webkit-scrollbar {
    height: 6px;
}

.message-content .chatbot-pre::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 3px;
}

.message-content .chatbot-pre::-webkit-scrollbar-thumb {
    background: #c1c7cd;
    border-radius: 3px;
}

.message-content .chatbot-pre::-webkit-scrollbar-thumb:hover {
    background: #a0a7ae;
}