/* body */
body {
    font-family: "poppinsmedium", Helvetica, Arial;
}

/* bulle ouverture fenêtre de discussion */
.open-icone {
    cursor: pointer;
    border-radius: 50%;
    width: 70px;
    height: 70px;
    background-color: #f3333f;
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    bottom: 8%;
    left: 4%;
    animation: pulse 2s infinite;
    transition: transform 0.3s ease;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.icone-open {
    display: none;
}

/********************** Container de la fenêtre de discussion *******************/
/* État fermé */
.agent-container {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
    visibility: hidden;
}

/* État ouvert */
.agent-container.open {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 1s ease, transform 1s ease;
    pointer-events: auto;
    visibility: visible;

    width: 35%;
    height: 90vh;
    border: 2px solid #2e8c8d;
    border-radius: 10px;
    overflow: hidden;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: fixed;
    left: 20px;
    bottom: 0;
    z-index: 1000;
    scroll-behavior: smooth;
    margin-bottom: 3em;
    justify-content: space-between;
}

/*********************En-tête de l'agent *****************/
#agent-header {
    background-color: #2e8c8d;
    color: white;
    padding: 0.5em;
    display: flex;
    align-items: center;
    gap: 3%;
    font-size: 20px;
}

/* Logo circulaire */
.logo {
    border-radius: 50%;
    width: 15%;
    height: 35%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.imgLogo {
    width: 100%;
    height: auto;
}

/* Bouton de fermeture */
#agent-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    color: white;
    cursor: pointer;
    transition: color 0.3s;
    width: 20%;
}

.header-text {
    width: 80%;
    text-align: center;
}

/* ***********************zone d'échange user/agent****************** */
#zone-messages {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* padding: 1em; */
    gap: 1em;
    max-height: 100%;
    box-sizing: border-box;
}

.message-list {
    flex: 1;
}

.agent-messages,
.user-messages {
    padding: 0.1em;
    display: flex;
    align-items: flex-end;
    gap: 2%;
    background-color: white;
    overflow-wrap: break-word;
    display: flex;
    align-items: flex-start;
    margin: 1em 0;
    max-width: 95%;
}

/* Messages agent */
.agent-icon {
    width: 2.5em;
    height: 2.5em;
    border-radius: 50%;
}

.agent-message,
.user-message {
    border-radius: 10px;
    padding: 0.3em;
    width: 92%;
    max-width: 85%;
}

.agent-message {
    border: 1px solid #141735;
    color: #141735;
    line-height: 1.2;
    min-height: 2.5em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    word-break: break-word;
}

.user-message {
    align-self: flex-end;
    border: 1px solid #018382;
    word-break: break-word;
    overflow-wrap: break-word;
    display: flex;
    align-items: center;
    flex-direction: row;
    justify-content: flex-start;
}

.avatar {
    width: 8%;
    height: 100%;
    border-radius: 50%;
}

/************************Bouton de choix de questions******************* */
#user-choice {
    display: flex;
    align-items: center;
    flex-direction: column;
    width: 100%;
    height: 90%;
    gap: 10%;
    padding: 1em;
    margin-top: 1em;

}

#apprendreAapprendre-btn,
#faq-btn,
#rag-btn {
    justify-content: center;
    border-radius: 10px;
    padding: 0.5em 1em;
    cursor: pointer;
    font-size: 16px;
    margin: 0.5em 0.5em;
    width: 80%;
    background-color: white;
    color: #141735;
    height: 6em;
}

/* Bouton FAQ */
#faq-btn {
    border: 2px solid #018382;

}

#faq-btn:hover,
#faq-btn:active {
    border: 3px solid #018382;
    background-color: white;
}

/* Bouton RAG */
#rag-btn {
    border: 2px solid #141735;
}

#rag-btn:hover,
#rag-btn:active {
    border: 3px solid #141735;
}

/* Bouton aprendre a apprendre */
#apprendreAapprendre-btn {
    border: 2px solid #ffcc33;
}

#apprendreAapprendre-btn:hover,
#apprendreAapprendre-btn:active {
    border: 3px solid #ffcc33;
}


#type-question-selectionne {
    background-color: white;
    margin-left: 2em;
    height: 5%;
    font-weight: 600;
    font-size: 16px;

}

/********************* Zone de saisie message user ************************/
.agent-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    /* ou 100% si parent a une hauteur fixée */
    max-height: 90vh;
    position: relative;
}

#zone-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1em;
    /* Pour éviter que les messages soient cachés sous l'input */
}

#zone-question-user {
    flex-shrink: 0;
    padding: 1em;
    background: #fff;
    border-top: 1px solid #eee;
    /* Fixe la zone d’input en bas */
}

#user-input {
    display: flex;
    gap: 0.5em;
}

#user-input textarea {
    flex: 1;
    resize: none;
}

#user-input {
    display: flex;
    border: 1px solid #018382;
    background-color: white;
    border-radius: 10px;
    font-size: 14px;
    height: 40%;
    padding: 0.5em;
    margin: 0.5em 0.5em;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

h5 {
    margin: 0.2em;
}

#user-input textarea {
    flex: 1;

}

#answer-input-rag,
#answer-input-faq,
#answer-input-apprendreAapprendre {
    width: 95%;
    height: 100%;
    border: none;
}

#answer-input-rag:focus,
#answer-input-faq:focus,
#answer-input-apprendreAapprendre:focus {
    outline: none;
    box-shadow: none;
}

/* btn envoie message */
#send-btn {
    border: none;
    border-radius: 50%;
    width: 8%;
    height: auto;
    margin-left: 6px;
    cursor: pointer;
    background-color: white;
}

.fa-solid {
    font-size: 30px;
}

/************************chargement spinner******************* */
/* Spinner circulaire */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #018382;
    /* Couleur du spinner */
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}



/*********************** RESPONSIVE MOBILE / TABLETTE ************************/
@media screen and (max-width: 768px) {
    .agent-container.open {
        width: 100%;
        height: 100vh;
        left: 0;
        border-radius: 0;
    }

    #faq-btn,
    #rag-btn {
        width: 100%;
    }

    .open-icone {
        width: 60px;
        height: 60px;
        bottom: 5%;
        left: 5%;
    }
}

/* Tablettes (portrait ou paysage) */
@media screen and (max-width: 1024px) {
    .agent-container.open {
        width: 80%;
        height: 80%;
        left: 10%;
        bottom: 10%;
        border-radius: 10px;
    }

    #agent-header {
        font-size: 16px;
    }

    .header-text {
        font-size: 14px;
    }

    .user-message,
    .agent-message {
        font-size: 14px;
    }
}

/* Smartphones */
@media screen and (max-width: 600px) {
    .agent-container.open {
        width: 95%;
        height: 90%;
        left: 2.5%;
        bottom: 5%;
        border-radius: 10px;
    }

    #agent-header {
        flex-direction: column;
        align-items: flex-start;
        font-size: 14px;
    }

    .header-text {
        width: 100%;
        text-align: left;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .avatar,
    .agent-icon {
        width: 24px;
    }

    .user-message,
    .agent-message {
        font-size: 13px;
        max-width: 100%;
        word-break: break-word;
    }

    #faq-btn,
    #rag-btn {
        font-size: 14px;
        padding: 0.5em;
        width: 100%;
    }

    #user-choice {
        flex-direction: column;
        gap: 0.5em;
    }

    #user-input {
        flex-direction: column;
        height: auto;
    }

    #send-btn {
        width: 100%;
        margin: 0.5em 0 0 0;
    }

    #answer-input-faq,
    #answer-input-rag {
        width: 100%;
    }

    #switch-type {
        position: sticky;
        bottom: 0;
        background-color: white;
        border-top: 1px solid #ccc;
    }
}

/* Très petits smartphones (ex : iPhone SE, anciens Android) */
@media screen and (max-width: 450px) {
    .agent-container.open {
        width: 98vw;
        left: 1vw;
        border-radius: 0;
        font-size: 13px;
    }

    #agent-header {
        display: flex;
        flex-direction: row;
    }

    #user-choice button,
    #apprendreAapprendre-btn,
    #faq-btn,
    #rag-btn {
        font-size: 13px;
        padding: 0.3em 0.5em;
        height: 4em;
        width: 95%;
    }

    #zone-question-user {
        padding: 0.5em;
    }

    #user-input {
        display: flex;
        flex-direction: row;
    }

    #send-btn {
        width: 10%;
        height: auto;
        margin-left: 0.5em;
    }

    #agent-header {
        font-size: 16px;
        padding: 0.3em;
    }

    #user-input textarea {
        font-size: 13px;
    }

    #type-question-selectionne {
        font-size: 12px;
    }
}