/*--------------------
Modal Styles
--------------------*/
/*--------------------
Chat Modal Overlay
--------------------*/
.bg {
    display: none; /* Hidden by default; show it via JS when needed */
    position: fixed;
    z-index: 999; /* Ensure overlay is above other elements */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(255, 255, 255, 1); /* Semi-transparent white overlay */
}
#fileName {
    margin-left: 10px;
    font-style: italic;
    color: #444;
}

.chat-info {
    flex: 1; /* occupe tout l’espace dispo entre avatar et bouton */
}
/* Header */
.chat-header {
    display: flex;
    align-items: center;
    padding: 10px;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px 20px 0 0;
    position: relative;
}
.chat-header h1 {
    margin: 0;
    font-size: 14px;
}
.chat-header h2 {
    margin: 0;
    font-size: 11px;
    color: #666;
}
.chat-header .avatar {
    flex-shrink: 0;
    margin-right: 10px;
}
.chat-header img {
    width: 30px;
    border-radius: 50%;
}

#toggleSizeBtn {
    margin-left: 10px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #333;
    transition: color 0.3s ease;
}

#toggleSizeBtn:hover {
    color: rgb(253, 197, 0);
}

.chat.fullscreen {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    max-height: none;
    border-radius: 0;
    margin: 0;
    z-index: 2000; /* au-dessus du reste */
}
/*--------------------
Chat Container (Modal Content)
--------------------*/
.chat {
    background-size: cover;
    font-size: 12px;
    line-height: 1.3;
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 380px;
    height: 500px;
    max-height: 500px;
    z-index: 9000; /* Higher than overlay */
    overflow: hidden;
    background: rgba(255, 255, 255, 1);
    border-radius: 12px;
    justify-content: space-between;
    flex-direction: column;
    margin-bottom: 30px;
    background: #fff;
    transition: all 0.3s ease-in-out;
    display: none; /* Hide chat box by default */
    opacity: 0;
    transform: translateY(50px);
    border: 1px solid rgb(235, 235, 235);
}
.chat.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Adjust the chat box for smaller screens */
@media (max-width: 1024px) {
    .chat {
        width: 36%; /* Increase width for tablets and smaller laptops */
    }
}

/* For mobile devices */
@media (max-width: 768px) {
    .chat {
        width: 46%; /* Adjust width for mobile screens */
        height: 60vh; /* Adjust height for smaller screens */
    }
}

/* For very small screens like phones in portrait mode */
@media (max-width: 480px) {
    .chat {
        width: 70%; /* Almost full width for very small screens */
        height: 50vh; /* Adjust height further if needed */
    }
}

/*--------------------
Mixins
--------------------*/

/*--------------------
Chat Container
--------------------*/
#toggleChat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgb(250, 164, 26); /* repli si le degrade n'est pas supporte */
    background-image: linear-gradient(300deg, #ffcb06 0%, #faa41f 98%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: filter 0.3s ease;
}

#toggleChat img {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

#toggleChat:hover {
    /* un degrade ne s'anime pas via background-color : on assombrit l'ensemble */
    filter: brightness(0.94);
}

/*--------------------
Chat Title
--------------------*/
.chat-title {
    flex: 0 1 45px;
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.7); /* translucent white */
    border-radius: 20px ;
    color: #333; /* dark text for contrast */
    text-transform: uppercase;
    text-align: left;
    padding: 10px 10px 10px 50px;
}

.chat-title h1,
.chat-title h2 {
    font-weight: normal;
    font-size: 10px;
    margin: 0;
    padding: 0;
}
.chat-title h2 {
    color: rgba(0, 0, 0, 0.6);
    font-size: 8px;
    letter-spacing: 1px;
}
.chat-title .avatar {
    position: absolute;
    z-index: 1;
    top: 8px;
    left: 9px;
    border-radius: 30px;
    width: 30px;
    height: 30px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 2px solid #ddd; /* subtle border */
}
.chat-title .avatar img {
    width: 100%;
    height: auto;
}

/*--------------------
Messages
--------------------*/
.messages {
    flex: 1 1 auto;
    /* min-height:0 : sans cela un enfant flex refuse de retrecir sous la taille
       de son contenu, et le defilement ne se declencherait jamais */
    min-height: 0;
    color: #1f1f1f;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
    width: 100%;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}
.messages::-webkit-scrollbar {
    width: 7px;
}
.messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}
.messages .messages-content {
    width: 100%;
    /* reprend le padding qu'appliquait .mCSB_inside > .mCSB_container */
    padding: 0 10px;
    overflow: hidden; /* contient les bulles, qui sont en float */
}
.messages .message {
    clear: both;
    float: left;
    padding: 15px 15px 15px 15px;
    border-radius: 10px 10px 10px 0;
    background: #ededed;
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.4;
    margin-left: 35px;
    position: relative;
    text-shadow: none; /* removed shadow for clarity */
    max-width: 90%; /* limit the message width */
    overflow-wrap: break-word; /* ensure long words wrap */
}

.messages .message .timestamp {
    position: absolute;
    bottom: -15px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.65);
}
.messages .message::before {
    content: "";
    position: absolute;
    bottom: -6px;
    border-top: 6px solid rgba(255, 255, 255, 0.8); /* same white as bubble */
    left: 0;
    border-right: 7px solid transparent;
}
.messages .message .avatar {
    position: absolute;
    z-index: 1;
    bottom: -15px;
    left: -35px;
    border-radius: 30px;
    width: 30px;
    height: 30px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 2px solid #ddd;
}
.messages .message .avatar img {
    width: 100%;
    height: auto;
}

/* Personal Message (from the user) */
.messages .message.message-personal {
    float: right;
    color: #333;
    text-align: right;
    background: linear-gradient(120deg, #f8f8f8, #eaeaea); /* subtle white gradient */
    border-radius: 10px 10px 0 10px;
}
.messages .message.message-personal::before {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 5px solid transparent;
    border-top: 4px solid #e0e0e0; /* light accent for the tail */
    bottom: -4px;
}
.messages .message:last-child {
    margin-bottom: 30px;
}
.messages .message.new {
    transform: scale(0);
    transform-origin: 0 0;
    animation: bounce 500ms linear both;
}
/* Loading dots for message bubbles */
.messages .message.loadingChat::before {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    content: "";
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    z-index: 2;
    margin-top: 4px;
    animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite;
    border: none;
    animation-delay: 0.15s;
}
.messages .message.loadingChat span {
    display: block;
    font-size: 0;
    width: 20px;
    height: 10px;
    position: relative;
}
.messages .message.loadingChat span::before {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    content: "";
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    z-index: 2;
    margin-top: 4px;
    animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite;
    margin-left: -7px;
}
.messages .message.loadingChat span::after {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    content: "";
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    z-index: 2;
    margin-top: 4px;
    animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite;
    margin-left: 7px;
    animation-delay: 0.3s;
}

/*--------------------
Message Box (Input Area)
--------------------*/
.message-box {
    display: flex; /* Set flexbox to align children */
    align-items: center; /* Center vertically */
    justify-content: space-between; /* Space out the content inside the box */
    width: 100%;
    background: rgba(219, 219, 219, 0.7); /* light translucent white */
    padding: 10px;
    position: relative;
    border-radius: 15px;
}

.message-box .message-input {
    background: none;
    border: none;
    outline: none !important;
    resize: none;
    color: #333;
    font-size: 14px;
    height: 17px;
    margin: 0;
    padding-right: 50px; /* Make space for the buttons */
    width: 100%; /* Make sure the text area takes all available width */
}

/* New class for the button container */
.message-box .button-container {
    display: flex; /* Align buttons horizontally */
    justify-content: flex-end; /* Push buttons to the right */
    gap: 10px; /* Add space between the buttons */
    position: absolute;
    top: 50%; /* Center buttons vertically */
    right: 10px; /* Position buttons near the right side */
    transform: translateY(-50%); /* Adjust for perfect vertical centering */
}

.message-box .message-submit {
    color: #333;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 12px;
    text-transform: uppercase;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 10px;
    outline: none !important;
    transition: background 0.2s ease;
}
.message-box .message-submit:hover {
    background: #f7f7f7;
}

/*--------------------
Custom Scrollbar
--------------------*/
.mCSB_scrollTools {
    margin: 1px -3px 1px 0;
    opacity: 0;
}

.mCSB_inside > .mCSB_container {
    margin-right: 0px;
    padding: 0 10px;
}

.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {
    background-color: rgba(0, 0, 0, 0.2) !important;
}

.chat.fullscreen .chat-body .message {
    font-size: 15px;   /* increase font size for messages */
    line-height: 1.6;  /* improve readability */
}

.chat.fullscreen .chat-header h1 {
    font-size: 18px;
}

.chat.fullscreen .chat-header h2 {
    font-size: 13px;
}

.chat.fullscreen .message-input {
    font-size: 14px;
}

/* Footer */
.chat-footer {
    display: flex;
    align-items: center;
    padding: 8px;
    border-top: 1px solid #ddd;
    background: #fff;
}
.chat-footer textarea {
    flex: 1;
    border: none;
    resize: none;
    padding: 8px;
    border-radius: 8px;
    outline: none;
    background: #f5f5f5;
    /* Un textarea n'herite pas de la police de la page : sans "font: inherit"
       il garde celle du navigateur. On aligne ensuite sur .messages .message */
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: #1f1f1f;
}
.chat-footer button {
    margin-left: 6px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 24px;
    color: rgb(253, 197, 0);
}

/*--------------------
Bounce Animation
--------------------*/
@keyframes bounce {
    0% {
        transform: matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    4.7% {
        transform: matrix3d(0.45, 0, 0, 0, 0, 0.45, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    9.41% {
        transform: matrix3d(0.883, 0, 0, 0, 0, 0.883, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    14.11% {
        transform: matrix3d(1.141, 0, 0, 0, 0, 1.141, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    18.72% {
        transform: matrix3d(1.212, 0, 0, 0, 0, 1.212, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    24.32% {
        transform: matrix3d(1.151, 0, 0, 0, 0, 1.151, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    29.93% {
        transform: matrix3d(1.048, 0, 0, 0, 0, 1.048, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    35.54% {
        transform: matrix3d(0.979, 0, 0, 0, 0, 0.979, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    41.04% {
        transform: matrix3d(0.961, 0, 0, 0, 0, 0.961, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    52.15% {
        transform: matrix3d(0.991, 0, 0, 0, 0, 0.991, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    63.26% {
        transform: matrix3d(1.007, 0, 0, 0, 0, 1.007, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    85.49% {
        transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
    100% {
        transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    }
}
@keyframes ball {
    from {
        transform: translateY(0) scaleY(0.8);
    }
    to {
        transform: translateY(-10px);
    }
}