﻿/* --- Conteneur général (popup) --- */
#assistantOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0);
    z-index: 9999;
}

#assistantContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-height: 500px;
    display: none;
    flex-direction: column;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    /* Animation */
    transition: all 0.3s ease-in-out;
    transform: translateY(20px);
    opacity: 0;
}

#assistantContainer.visible {
    transform: translateY(0);
    opacity: 1;
}

/* --- En-tête assistant --- */
#assistantContainer .assistant-header {
    background: #f2f2f2;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#assistantContainer .assistant-header button {
    border: none;
    background: none;
    font-size: 16px;
}

.assistant-header img {
    width: 25px;
    margin-inline: 10px;
}

/* --- Historique des messages --- */
#assistantHistory {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-size: 1em;
}

    #assistantHistory .message {
        margin-bottom: 10px;
    }

    /* Message utilisateur */
    #assistantHistory .user .bubble {
        background: #dceeff;
        text-align: right;
        margin-left: auto;
    }

    /* Message assistant */
    #assistantHistory .assistant .bubble,
    #assistantHistory .bot.error .bubble {
        background: #f2f2f2;
        text-align: left;
        margin-right: auto;
    }

/* --- Bulle de message --- */
.bubble {
    position: relative;
    padding: 8px 12px 20px 12px;
    border-radius: 8px;
    max-width: 100%;
    display: inline-block;
}

/* --- Message assistant : largeur miniumum --- */
#assistantHistory .assistant .bubble {
    min-width: 363px;
}

.bubble-content {
    font-size: 1em;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.bubble-time {
    position: absolute;
    right: 8px;
    bottom: 5px;
    font-size: 0.75em;
    color: #888;
}

/* Listes dans les bulles */
.bubble-content p {
    margin-bottom: 10px;
}

.bubble-content ol,
.bubble-content ul {
    margin-left: 1.5em;
    margin-bottom: 10px;
}

.bubble-content li {
    margin-bottom: 5px;
}

.bubble-content strong {
    font-weight: bold;
}

/* Liste numérotée personnalisée */
.bubble-content ol {
    counter-reset: custom-counter;
    list-style: none;
    padding-left: 0;
    padding-top: 10px;
}

    .bubble-content ol > li {
        counter-increment: custom-counter;
        position: relative;
        padding-left: 1.5em;
        margin-bottom: 10px;
    }

        .bubble-content ol > li::before {
            content: counter(custom-counter) ") ";
            position: absolute;
            left: 0;
            font-weight: bold;
        }

/* --- Formulaire de saisie --- */
#assistantPromptForm {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    border-top: 1px solid #ddd;
    gap: 5px;
}

#assistantPrompt {
    flex: 1;
}

/* Bouton envoyer et loader */
#envoyerZone {
    position: relative;
    width: auto;
}

/* --- Bouton flottant (déplaçable par appui prolongé, cf. assistantia.js) --- */
#assistantToggleBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: none;
    border: none;
    z-index: 9999;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

    #assistantToggleBtn:hover {
        opacity: 0.6;
    }

    /* Déplacement en cours */
    #assistantToggleBtn.assistant-button-dragging {
        cursor: grabbing;
        opacity: 1;
        filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
    }

    #assistantToggleBtn img {
        width: 50px;
    }

#assistantPromptForm {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #ddd;
}

#envoyerButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}


/* --- Cacher le bouton si assistant ouvert --- */
.hiddenAssistant {
    display: none !important;
}

/* Actions header */
.assistant-header .assistant-actions button {
    border: none;
    background: none;
    font-size: 16px;
    margin-left: 8px;
    cursor: pointer;
}

/* Mode plein écran */
#assistantContainer.fullscreen {
    top: 5vh;
    left: 20vw;
    right: 20vw;
    bottom: 5vh;
    position: fixed;
    width: auto;
    height: auto;
    max-height: none;
}

    #assistantContainer.fullscreen #assistantHistory {
        height: calc(100% - 100px); /* header + footer prompt approx */
    }


/* Mobile : toujours en plein écran et sans bouton plein écran */
@media (max-width: 768px) {
    body.is-mobile #assistantContainer {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-height: none !important;
        border-radius: 0 !important;
        transform: none !important; /* pas d’animation qui pousse vers le bas */
        opacity: 1 !important; /* visible immédiatement */
    }

    body.is-mobile #assistantHistory {
        max-height: none !important; /* laisse le flex:1 faire le job */
    }

    /* Cache les icônes agrandir/réduire sur mobile */
    body.is-mobile #btnAssistantFullscreen {
        display: none !important;
    }
}

@media (min-width:769px) and (max-width: 1350px)
{
    /* Mode plein écran */
    #assistantContainer.fullscreen {
        left: 15vh;
        right: 15vw;
    }
}