.zwh-app-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 500px;
    transition: all 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    font-family: 'Raleway', sans-serif;
}

.zwh-app-wrapper.is-active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    background-color: #ffffff;
    padding: 60px 20px;
    justify-content: flex-end;
}

.zwh-main-container {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.zwh-main-title {
    font-family: 'Roboto', sans-serif;
    font-size: 32px;
    font-weight: 400;
    color: #000;
    text-align: center;
    margin-bottom: 20px;
}

.zwh-main-title .highlight { color: #64B97C; }
.zwh-app-wrapper.is-active .zwh-main-title { display: none; }

.zwh-chat-history {
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0; /* Important pour Firefox/Flexbox */
    padding-bottom: 20px;
}

.zwh-chat-history::-webkit-scrollbar { display: none; }

.bubble-user {
    align-self: flex-end;
    background-color: #318C64;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 18px 18px 2px 18px;
    max-width: 80%;
    font-family: 'Roboto', sans-serif;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.bubble-ai {
    /* --- INDISPENSABLE POUR EVITER L'ECRASEMENT --- */
    flex-shrink: 0;        /* Interdit au navigateur de réduire cette bulle */
    height: auto !important; /* Force la hauteur à s'adapter au texte */
    
    /* Le reste de ton style */
    align-self: flex-start;
    background-color: transparent;
    color: #000;
    padding: 10px 0;
    width: 100%;
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
    margin-top: 15px;      /* Un peu plus d'espace entre les messages */
    display: block;
    
    /* Animation simple et sans danger (Opacité seule) */
    animation: fadeInOnly 0.5s ease-out forwards;
}

.bubble-ai a {
    color: #318C64 !important;
    text-decoration: underline !important;
    background-color: rgba(49, 140, 100, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 500;
}

.bubble-ai strong { font-weight: 700; color: #318C64 !important; }

/* — ANIMATION LOADING — */
.zwh-typing { display: none; align-self: flex-start; padding: 15px 0; margin-bottom: 10px; }
.zwh-typing .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 4px;
    background-color: #318C64;
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out both;
}

.zwh-typing .dot:nth-child(1) { animation-delay: -0.32s; }
.zwh-typing .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulse {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* — BARRE DE SAISIE — */
.zwh-input-box {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px 25px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.zwh-textarea-container { position: relative; width: 100%; display: flex; align-items: center; }

.zwh-input-box textarea {
    width: 100%;
    border: none;
    outline: none;
    font-family: 'Roboto', sans-serif;
    font-size: 18px;
    resize: none;
    padding: 10px 55px 10px 0;
    background: transparent;
    z-index: 2;
    position: relative;
    line-height: 24px;
}

.zwh-placeholder-overlay {
    position: absolute;
    top: 10px;
    left: 0;
    z-index: 1;
    pointer-events: none;
    height: 24px;
    width: 90%;
    overflow: hidden;
    transition: opacity 0.1s ease-out;
}

#zwh-placeholder-text {
    display: block;
    font-family: 'Roboto', sans-serif;
    font-size: 18px;
    color: #b0b0b0;
    transition: transform 0.5s ease, opacity 0.5s ease;
    line-height: 24px;
}

.btn-send-up {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 15px;
    bottom: 12px;
    width: 42px;
    height: 42px;
    background-color: #318C64;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 3;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 8px rgba(49, 140, 100, 0.2);
}

.btn-send-up:hover:not(:disabled) {
    transform: scale(1.1);
    background-color: #266d4e;
}

.btn-send-up:disabled {
    background-color: #e0e0e0;
    cursor: not-allowed;
}

/* — MOBILE — */
@media screen and (max-width: 600px) {
    #zwh-placeholder-text {
        font-size: 13px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 85%;
    }
    #user-input {
        font-size: 16px !important;
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

.zwh-ai-disclaimer { text-align: center; font-size: 12px; color: #aaa; margin-top: 15px; font-family: 'Roboto', sans-serif; }
.privacy-link { color: #aaa !important; text-decoration: underline !important; margin-left: 5px; }

/* --- NOUVEL INDICATEUR DE CHARGEMENT --- */
.zwh-logo-frame {
    width: 22px !important;
    height: 22px !important;
    /* On met ton lien ici */
    background-image: url('https://zerowattheure.com/wp-content/uploads/2024/01/Logo-Zero-Wattheure-cut.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
}

.zwh-typing {
    display: none; /* Toujours piloté par le JS */
    align-self: flex-start;
    padding: 10px 0;
    margin-bottom: 10px;
}

.zwh-spinner-container {
    position: relative;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Sécurité ultime : rien ne dépasse */
}

.zwh-spinner-logo {
    width: 18px;   /* Le logo en tout petit au centre */
    height: 18px;
    object-fit: contain;
    z-index: 2;
}

.zwh-spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(49, 140, 100, 0.1);
    border-top: 2px solid #318C64;
    border-radius: 50%;
    animation: zwh-spin 0.9s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    z-index: 1;
}

#typing-indicator .zwh-spinner-logo {
    width: 18px !important;
    height: 18px !important;
    max-width: 18px !important;
    display: block;
    object-fit: contain;
}

/* L'animation de rotation */
@keyframes zwh-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeInOnly {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* On s'assure que le formulaire aligne les boutons et le texte */
#zwh-form {
    display: flex;
    align-items: center; /* Aligne verticalement au centre */
    gap: 10px; /* Espace entre la poubelle, le texte et l'envoi */
    width: 100%;
}

/* Style du nouveau bouton Reset */
.zwh-btn-reset {
    background: none;
    border: none;
    cursor: pointer;
    color: #666; /* Couleur de l'icone (gris) */
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0; /* Empêche le bouton d'être écrasé */
}

.zwh-btn-reset:hover {
    background-color: #f0f0f0; 
    color: #4CAF50; /* Remplace par ton Vert Zéro Wattheure exact */
    /* OU color: #333; pour rester sobre */
}

/* Ajustement pour que la zone de texte prenne tout l'espace restant */
.zwh-textarea-container {
    flex-grow: 1; 
}

/* --- FIX CHATBOT PAGE 27655 (INTEGRATION) --- */

/* --- FIX PAGE 27655 : RENDRE LE CHATBOT "SOLIDE" --- */

/* 1. LE CONTENEUR PRINCIPAL (La Brique) */
.chatbot-design-b #zwh-app-wrapper {
    /* C'est la ligne MAGIQUE : On le remet dans le flux normal */
    position: relative !important; 
    
    /* On casse les liens qui le collaient à l'écran */
    top: auto !important;
    left: auto !important;
    bottom: auto !important;
    right: auto !important;
    
    /* On lui donne une vraie taille physique */
    height: 80vh !important;       
    width: 100% !important;
    max-width: 1100px !important;   /* Largeur contenue pour PC */
    min-height: 600px;
    /* On le centre et on met de l'espace autour */
    margin: 40px auto !important;  
    
    /* On s'assure qu'il est visible */
    z-index: 1; /* Niveau de base */
    background-color: transparent !important; /* Plus de fond blanc */
    box-shadow: none !important;              /* Plus d'ombre portée */
    border: none !important;

    transition: height 0.5s ease-in-out, margin 0.5s ease-in-out;
}

.chatbot-design-b #zwh-app-wrapper:has(.zwh-chat-history:empty) {
    /* C'EST LA CLÉ : La hauteur s'adapte au contenu (Titre + Input) */
    height: auto !important;
    min-height: auto !important; /* On annule le min-height */
    
    /* On ajoute un peu de marge en haut pour centrer visuellement le bloc sur l'écran */
    margin-top: 15vh !important; 
    margin-bottom: 1px !important; /* Espace avant les boutons "Étude gratuite" */
}

/* 2. LE CONTENU INTERNE */
.chatbot-design-b .zwh-main-container {
    height: 100% !important;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Important pour les coins arrondis */
    justify-content: flex-end; /* Par défaut aligné bas */
}

/* 3. L'HISTORIQUE DE CHAT */
.chatbot-design-b .zwh-chat-history {
    order:1;
    flex-grow: 1;
    overflow-y: auto !important;
    height: auto !important;
    padding-bottom: 90px !important; /* Espace pour la barre de saisie */
}

/* --- FIX FINAL PAGE 27655 : ORDRE DES ÉLÉMENTS --- */

/* 1. LE CONTENEUR (La pile de Lego) */
.chatbot-design-b .zwh-main-container {
    display: flex;
    flex-direction: column;
    height: 100% !important;
    justify-content: flex-end; /* Pousse tout vers le bas si l'historique est vide */
}

.chatbot-design-b .zwh-main-container:has(.zwh-chat-history:empty) {
    justify-content: center !important; /* Centre verticalement */
}

/* 2. L'HISTORIQUE (ORDRE 1 : Tout en haut) */
.chatbot-design-b .zwh-chat-history {
    order: 1;
    flex-grow: 1; /* C'est lui qui s'étire pour remplir le vide */
    overflow-y: auto !important;
    /* height: auto !important; */
    padding-bottom: 20px !important;
}

.chatbot-design-b .zwh-chat-history:empty {
    display: none !important;
}

/* 3. LE TITRE (ORDRE 2 : Au-dessus du prompt) */
.chatbot-design-b .zwh-main-title {
    order: 2;
    text-align: center;
    padding: 0 20px;
    z-index: 5;
    position: relative;
    margin-bottom: 40px !important; /* 20vh = 20% de la hauteur de l'écran */
    margin-top: 0 !important;
    font-size: 3rem !important;      /* Très gros (ajuste si besoin) */
    font-weight: 475 !important;     /* Très gras (Extra Bold) */
    line-height: 1.2 !important;     /* Espacement des lignes serré */
    color: #222 !important;          /* Noir profond pour le contraste */
}

/* 4. LA BARRE DE SAISIE (ORDRE 3) */
.chatbot-design-b .zwh-input-box {
    order: 3;
    
    /* IMPORTANT : On annule le positionnement "absolute" d'avant */
    position: relative !important; 
    bottom: auto !important;
    left: auto !important;
    
    width: 96% !important; /* Un peu moins large pour faire joli */
    margin: 0 auto !important; /* Centré */
    
    /* On remet des bords arrondis partout car elle n'est plus collée au fond */
    border-radius: 15px !important; 
    border: 1px solid #eee; /* Petit contour subtil */
    background: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
}

/* 5. LE DISCLAIMER (ORDRE 4 : Tout en bas) */
.chatbot-design-b .zwh-ai-disclaimer {
    order: 4;
    
    /* Positionnement */
    margin-top: 10px !important;
    padding-bottom: 15px !important; /* Espace avant la fin de la boîte blanche */
    
    /* Style */
    text-align: center;
    font-size: 0.75rem;
    color: #999;
    background: transparent; /* Pas de fond blanc qui cache le reste */
}

.chatbot-design-b .zwh-chat-history,
.chatbot-design-b .zwh-input-box,
.chatbot-design-b .bubble-user,
.chatbot-design-b .bubble-ai {
    font-weight: 400 !important; /* 400 = Normal */
    font-family: inherit; /* Utilise la police du site */
}

/* 2. On s'assure que le gras du Markdown (les **mots**) reste bien gras */
.chatbot-design-b strong, 
.chatbot-design-b b {
    font-weight: 700 !important; /* 700 = Bold */
}

/* 3. Petit fix pour le placeholder (le texte fantôme) qui peut aussi être touché */
.chatbot-design-b ::placeholder {
    font-weight: 400 !important;
    opacity: 0.7;
}

/* --- FIX POLICE D'ÉCRITURE --- */
.chatbot-design-b #zwh-app-wrapper,
.chatbot-design-b #zwh-app-wrapper * {
    /* Cela force la police propre de l'ordinateur (San Francisco sur Mac, Segoe UI sur Windows, Roboto sur Android) */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !important;
}



/* --- FIX ANIMATION CHARGEMENT (Place en bas) --- */
.chatbot-design-b .zwh-typing {
    /* On lui donne le même rang que le titre pour qu'elle descende */
    order: 2; 
    
    /* On s'assure qu'elle ne colle pas trop à la barre de saisie */
    margin-bottom: 15px !important;
    margin-left: 20px !important; /* Alignée à gauche comme une bulle IA */
    
    /* On s'assure qu'elle est visible par dessus le reste */
    position: relative;
    z-index: 10;
    
    /* Optionnel : Si elle est trop large */
    width: auto !important;
    align-self: flex-start; /* Se cale à gauche */
}

/* --- VERSION MOBILE "GRIGNOTAGE" (PAGE 27655) --- */
@media screen and (max-width: 768px) {

    /* 1. LE CADRE PRINCIPAL */
    .chatbot-design-b #zwh-app-wrapper {
        position: relative !important;
        
        /* C'EST ICI QUE ÇA SE JOUE : */
        /* On prend 100% de la largeur + 40px pour manger les marges du thème */
        width: calc(100% + 110px) !important; 
        
        /* On le tire vers la gauche pour le recentrer parfaitement */
        margin-left: -75px !important; 
        margin-right: -20px !important;
        
        /* Reset des autres propriétés */
        left: auto !important;
        top: auto !important;
        height: 80vh !important;
        margin-top: 10px !important;
        margin-bottom: 20px !important;
        
        background: #fff;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    /* 2. LE CONTENU INTERNE */
    .chatbot-design-b .zwh-main-container {
        display: flex;
        flex-direction: column;
        height: 100% !important;
        width: 100% !important;
    }

    /* 3. L'HISTORIQUE (Marges internes de sécurité) */
    .chatbot-design-b .zwh-chat-history {
        order: 1;
        flex-grow: 1;
        /* IMPORTANT : On remet un peu d'air à l'intérieur pour que le texte ne touche pas le bord de l'écran */
        padding: 10px 15px 20px 15px !important; 
    }

    /* 4. LE TITRE */
    .chatbot-design-b .zwh-main-title {
        order: 2;
        font-size: 1.1rem !important;
        margin-bottom: 5vh !important;
        margin-top: 0 !important;
        padding: 0 10px;
        font-size: 1.8rem !important; /* Plus petit sur mobile pour pas casser l'écran */
        margin-bottom: 30px !important;
    }

    /* 5. L'ANIMATION DE CHARGEMENT */
    .chatbot-design-b .zwh-typing {
        order: 2; 
        margin-left: 15px !important;
        margin-bottom: 10px !important;
    }

    /* 6. LA ZONE DE SAISIE (Largeur adaptée au nouveau cadre) */
    .chatbot-design-b .zwh-input-box {
        order: 3;
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        
        /* On prend presque toute la nouvelle largeur */
        width: 94% !important; 
        margin: 0 auto !important; /* Centré */
        
        border-radius: 25px !important;
        padding: 8px !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
        background: #fff;
        border: 1px solid #eee;
    }

    /* 7. LE DISCLAIMER */
    .chatbot-design-b .zwh-ai-disclaimer {
        order: 4;
        font-size: 10px !important;
        margin-top: 10px !important;
        padding-bottom: 10px !important;
    }
    
    /* 8. ANTI-ZOOM IPHONE */
    .chatbot-design-b input, 
    .chatbot-design-b textarea {
        font-size: 16px !important; 
    }
}

/* Force le header Divi/WP à rester au-dessus si besoin */
header, #main-header {
    z-index: 99999;
    position: relative;
}

