/* ============================================
     CHATBOT WIDGET - Version Automatisée
     Compatible avec chat-final.js
     ============================================ */

  /* Variables - Glassmorphism Élégant */
  :root {
    /* Fenêtre principale - Fond semi-transparent avec flou prononcé */
    --chatbot-bg-primary: rgba(255, 255, 255, 0.08);
    --chatbot-bg-secondary: rgba(255, 255, 255, 0.12);
    --chatbot-border: rgba(255, 255, 255, 0.18);
    --chatbot-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);

    /* Bulles de message - Légèrement plus opaques pour la lisibilité */
    --chatbot-bot-bubble: rgba(255, 255, 255, 0.18);
    --chatbot-bot-border: #a78bfa;
    --chatbot-user-bubble: rgba(78, 168, 222, 0.28);
    --chatbot-user-border: #4ea8de;

    /* Texte - Blanc pur avec ombre portée pour contraste */
    --chatbot-text: #ffffff;
    --chatbot-text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);

    /* Effet glassmorphism - Flou d'arrière-plan prononcé */
    --chatbot-blur: blur(16px);
    --chatbot-blur-strong: blur(20px);

    /* Styles généraux */
    --chatbot-border-radius: 16px;
    --chatbot-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Conteneur principal - INVISIBLE (contient uniquement le bouton et la fenêtre) */
#chatbot-container {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 9998 !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

/* Fenêtre du chatbot - Glassmorphism Élégant et Discret */
.chatbot-window,
#chatbot-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    z-index: 9999 !important;

    /* 🌟 Effet Glassmorphism Moderne */
    background: var(--chatbot-bg-primary);
    backdrop-filter: var(--chatbot-blur) saturate(180%);
    -webkit-backdrop-filter: var(--chatbot-blur) saturate(180%);

    /* Bordure subtile avec dégradé léger */
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-border-radius);

    /* Ombre douce et profonde */
    box-shadow: var(--chatbot-shadow), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;

    /* Structure */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatbotSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto !important;
}

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

/* Header - Glassmorphism avec séparation élégante */
.chatbot-header,
#chatbot-header {
    background: var(--chatbot-bg-secondary);
    backdrop-filter: var(--chatbot-blur);
    -webkit-backdrop-filter: var(--chatbot-blur);
    padding: 16px 20px;
    border-bottom: 1px solid var(--chatbot-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
}

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

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chatbot-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--chatbot-text);
    text-shadow: var(--chatbot-text-shadow);
    font-family: var(--chatbot-font);
    margin: 0;
}

.chatbot-status {
    font-size: 12px;
    color: var(--chatbot-text);
    opacity: 0.9;
    margin: 0;
}

.chatbot-close-btn,
#chatbot-close {
    background: none;
    border: none;
    color: #00D4FF;
    cursor: pointer;
    padding: 4px;
    font-size: 22px;
    line-height: 1;
    opacity: 1;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chatbot-close-btn:hover,
#chatbot-close:hover {
    transform: scale(1.2);
    opacity: 1;
    filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.5));
}

/* Messages - Zone de conversation transparente */
.chatbot-messages,
#chatbot-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 20px !important;
    background: transparent !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(167, 139, 250, 0.4) transparent !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
}

.chatbot-messages::-webkit-scrollbar,
#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb,
#chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.3);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover,
#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(167, 139, 250, 0.5);
}

/* ============================================
   MESSAGES - Classes utilisées par chat-final.js
   ============================================ */

/* Container de message */
.chatbot-message {
    display: flex !important;
    margin-bottom: 20px !important;
    clear: both !important;
    position: relative;
    z-index: calc(100 - var(--msg-index, 0));
    animation: messageSlideIn 0.3s ease;
}

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

.chatbot-message-user {
    justify-content: flex-end !important;
    margin-left: auto !important;
}

.chatbot-message-bot {
    justify-content: flex-start !important;
    margin-right: auto !important;
}

/* Bulle de message - Structure de base */
.chatbot-message-content {
    max-width: 85% !important;
    padding: 12px 16px !important;
    border-radius: 14px !important;
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    word-wrap: break-word !important;
    font-family: var(--chatbot-font) !important;
    font-weight: 400 !important;
    opacity: 1 !important;
}

/* Bulle Bot - Glassmorphisme avec opacité renforcée */
.chatbot-message-bot .chatbot-message-content {
    background: rgba(255, 255, 255, 0.50);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    border-left: 3px solid #a78bfa;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
}

/* Bulle User - Glassmorphisme avec opacité renforcée */
.chatbot-message-user .chatbot-message-content {
    background: rgba(78, 168, 222, 0.60);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    border-left: 3px solid #4ea8de;
    border-bottom-right-radius: 4px;
    text-align: left;
    box-shadow: 0 2px 6px rgba(78, 168, 222, 0.2);
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
}

/* Typing indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    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);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Zone d'input - Glassmorphism avec séparation élégante */
.chatbot-input-container,
#chatbot-input-area {
    padding: 14px 16px !important;
    background: var(--chatbot-bg-secondary) !important;
    backdrop-filter: var(--chatbot-blur) saturate(180%) !important;
    -webkit-backdrop-filter: var(--chatbot-blur) saturate(180%) !important;
    border-top: 1px solid var(--chatbot-border) !important;
    display: flex !important;
    align-items: flex-end !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 64px !important;
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.05);
}

.chatbot-input,
#chatbot-input {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    flex: 1;
    display: block !important;
    background: rgba(255, 255, 255, 1) !important;
    border: 1px solid #a78bfa !important;
    border-radius: 8px !important;
    padding: 10px 14px !important;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15), 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    color: #212529 !important;
    font-size: 16px !important;
    font-family: var(--chatbot-font) !important;
    line-height: 1.5 !important;
    resize: none !important;
    overflow-x: hidden !important;
    max-height: 120px !important;
    min-height: 40px !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: height 0.1s ease !important;
    outline: none !important;
}

.chatbot-input::placeholder,
#chatbot-input::placeholder {
    color: rgba(0, 0, 0, 0.5) !important;
    opacity: 1 !important;
}

.chatbot-input::-webkit-scrollbar,
#chatbot-input::-webkit-scrollbar {
    width: 6px !important;
}

.chatbot-input::-webkit-scrollbar-track,
#chatbot-input::-webkit-scrollbar-track {
    background: rgba(167, 139, 250, 0.1) !important;
    border-radius: 3px !important;
}

.chatbot-input::-webkit-scrollbar-thumb,
#chatbot-input::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.4) !important;
    border-radius: 3px !important;
    transition: background 0.2s ease !important;
}

.chatbot-input::-webkit-scrollbar-thumb:hover,
#chatbot-input::-webkit-scrollbar-thumb:hover {
    background: rgba(167, 139, 250, 0.6) !important;
}

.chatbot-input:hover,
.chatbot-input:focus,
.chatbot-input:active,
.chatbot-input:focus-visible,
#chatbot-input:hover,
#chatbot-input:focus,
#chatbot-input:active,
#chatbot-input:focus-visible {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    outline: none !important;
    background: rgba(255, 255, 255, 1) !important;
    border: 1px solid #a78bfa !important;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15), 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    color: #212529 !important;
}

.chatbot-send-btn,
#chatbot-send {
    background: #4ea8de !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
    height: 40px !important;
    min-height: 40px !important;
    font-weight: 600 !important;
    font-size: 0.875rem !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-family: var(--chatbot-font) !important;
    box-shadow: 0 2px 8px rgba(78, 168, 222, 0.3) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.chatbot-send-btn:hover,
#chatbot-send:hover {
    background: #3b82c4 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(78, 168, 222, 0.4) !important;
}

.chatbot-send-btn:active,
#chatbot-send:active {
    transform: translateY(0) !important;
}

.chatbot-send-btn svg,
#chatbot-send svg {
    width: 16px !important;
    height: 16px !important;
}

/* Bouton toggle - Version Ultra-Minimaliste et Élégante */
.chatbot-button,
#chatbot-toggle {
    position: fixed !important;
    bottom: 15px;
    right: 20px;
    width: 70px !important;
    height: 70px !important;
    border-radius: 50% !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.3s ease !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    line-height: 1 !important;
    pointer-events: auto !important;
    outline: none !important;
    font-size: 28px;
    color: #ffffff;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

.chatbot-button.hidden,
#chatbot-toggle.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.chatbot-button:hover,
#chatbot-toggle:hover {
    transform: scale(1.1) !important;
    filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.6)) !important;
}

/* État fermé */
.chatbot-closed .chatbot-window {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

/* Responsive */
@media (max-width: 480px) {
    #chatbot-container {
        background: none !important;
        border: none !important;
        box-shadow: none !important;
    }

    .chatbot-window,
    #chatbot-window {
        width: 90vw !important;
        height: 65vh !important;
        bottom: 10px !important;
        right: 10px !important;
        border-radius: 16px !important;
        transition: all 0.3s ease !important;
        animation: mobileSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

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

    .chatbot-window.expanded,
    #chatbot-window.expanded {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 80px) !important;
        bottom: 10px !important;
        right: 10px !important;
    }

    .chatbot-button,
    #chatbot-toggle {
        width: 64px !important;
        height: 64px !important;
        bottom: 12px !important;
        right: 16px !important;
        box-shadow: 0 4px 12px rgba(0, 212, 255, 0.4) !important;
        transition: all 0.3s ease !important;
    }

    .chatbot-button:hover,
    #chatbot-toggle:hover {
        transform: scale(1.05) !important;
        box-shadow: 0 6px 16px rgba(0, 212, 255, 0.6) !important;
    }

    .chatbot-input,
    #chatbot-input {
        font-size: 16px !important;
    }
}

/* Anti-fantôme - Supprime les ombres du site côté client */
body.chatbot-loaded * {
    box-shadow: none !important;
}
