#icon-back {
    position: fixed;
    bottom: 20px; 
    right: 20px; 
    width: 60px; 
    height: 60px; 
    border-radius: 50%; 
    cursor: pointer;
    z-index: 99999999;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#chat-icon {
    display: flex;
}

#collapsed-icon {
    padding: 10px;
}

#chat-widget-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    transition: transform 0.3s ease-in-out;
    z-index: 99999999;
}

#chat-widget-container.expanded {
    transform: scale(1);
    transform-origin: bottom right;
}

#chat-widget-container.collapsed {
    transform: scale(0);
    transform-origin: bottom right;
}

.chat-widget {
    width: 420px;
    padding: 0px;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 5px;
    border-radius: 16px;
}

.container {
    border-radius: 16px;
    margin-bottom: 0px !important;
    padding-left: 0px !important;
}

#exit-button {
    position: fixed;
    top: 5px;
    right: 10px;
    cursor: pointer;
    font-weight: bold;
}

.chat-body {
    padding: 10px;
    overflow-x: wrap;
    border-radius: 8px;
}

.chat-messages {
    max-height: 450px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-radius: 16px 16px 0px 0px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    border-radius: 5px;
    padding: 20px;
    height: 50px;
    margin-top: 20px;
    margin-right: 30px;
}

.chat-messages::-webkit-scrollbar-thumb {
    border-radius: 10px;
    border: 0px solid rgba(0, 0, 0, 0.0);
}

.server-message {
    padding: 12px 16px 12px 16px;
    margin: 20px 50px 20px 20px;
    align-self: flex-start;
    word-wrap: break-word;
    word-break: break-word;
    text-align: left;
    font-size: 15px;
    border-radius: 0px 16px 16px 16px;
    box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.25);
}

.client-message {
    padding: 12px 16px;
    margin: 20px 20px 20px 50px;
    align-self: flex-end;
    word-wrap: break-word;
    word-break: break-word;
    text-align: left;
    font-size: 15px;
    border-radius: 16px 0px 16px 16px;
    box-shadow: 0px 4px 24px 0 rgba(0, 0, 0, 0.25);
}

.chat-input {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: 25px;
}

.input-field {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 10px;
    border-radius: 25px;
    background-color: none;
    resize: none;
    overflow: hidden;
    min-height: 40px;
    max-height: 250px;
}

.send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    padding: 10px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: filter 0.3s ease-in-out;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.send-button.flip-colors:hover {
    filter: invert(1);
}

.loading-container {
    display: flex;          
    align-items: center;     
    font-style: italic;
    
}

.loading-indicator {
    display: inline-flex !important;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 6px solid rgba(0, 0, 0, 0.14);
    animation: spin 1s linear infinite;
    align-self: start;
    flex-shrink: 0;
    margin: 20px;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}


@media only screen and (max-width: 768px) {
    #icon-back {
        bottom: 20px;
        right: 20px;
    }

    #chat-widget-container {
        position: fixed;
        bottom: 90px; /* Adjust this based on icon height + margin */
        right: 20px;
        width: calc(100% - 40px); /* Full width minus margins */
        transition: transform 0.3s ease-in-out;
        z-index: 99999999;
        display: flex;
        flex-direction: column; /* Stack chat body and input vertically */
    }

    #chat-widget-container.expanded {
        transform: scale(1);
        transform-origin: bottom right;
    }

    #chat-widget-container.collapsed {
        transform: scale(0);
        transform-origin: bottom right;
    }

    .chat-widget {
        flex-grow: 1; /* Ensure chat-widget fills available space */
        width: 100%;
        height: 100%;
        padding: 0;
        border-radius: 16px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
        display: flex;
        flex-direction: column; /* Stack header, body, and input vertically */
    }

    .chat-header {
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        padding: 5px;
        border-radius: 16px;
    }

    .container {
        border-radius: 16px;
        margin-bottom: 0px !important;
        padding-left: 0px !important;
    }

    #exit-button {
        position: absolute;
        top: 5px;
        right: 10px;
        cursor: pointer;
        font-weight: bold;
    }

    .chat-body {
        padding: 10px;
        border-radius: 8px;
        display: flex;
        flex-direction: column; /* Stack messages and input */
        flex-grow: 1; /* Ensure chat-body takes up remaining space */
    }

    .chat-messages {
        max-height: 400px; /* Take up full height of chat-body */
        overflow-y: scroll;
        display: flex;
        flex-direction: column;
        border-radius: 16px 16px 0 0;
    }

    .chat-messages::-webkit-scrollbar {
        width: 8px;
    }

    .chat-messages::-webkit-scrollbar-track {
        border-radius: 5px;
    }

    .chat-messages::-webkit-scrollbar-thumb {
        border-radius: 10px;
        border: 0 solid rgba(0, 0, 0, 0.0);
    }

    .server-message {
        padding: 12px 16px;
        margin: 10px;
        align-self: flex-start;
        word-wrap: break-word;
        word-break: break-word;
        text-align: left;
        font-size: 15px;
        border-radius: 0 16px 16px 16px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    }

    .client-message {
        padding: 12px 16px;
        margin: 10px;
        align-self: flex-end;
        word-wrap: break-word;
        word-break: break-word;
        text-align: left;
        font-size: 15px;
        border-radius: 16px 0 16px 16px;
        box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.25);
    }

    .chat-input {
        display: flex;
        align-items: center;
        padding: 6px 16px;
        border-radius: 25px;
    }

    .send-button {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 10px;
        padding: 10px;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        transition: filter 0.3s ease-in-out, background-color 0.3s ease, color 0.3s ease;
    }

    .send-button.flip-colors:hover {
        filter: invert(1);
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }

    .loading-indicator {
        display: inline-flex !important;
        width: 35px;
        height: 35px;
        border-radius: 50%;
        border: 6px solid rgba(0, 0, 0, 0.14);
        animation: spin 1s linear infinite;
        align-self: start;
        flex-shrink: 0;
        margin: 20px;
    }

    .loading-container {
        display: flex;          
        align-items: center;     
        font-style: italic;
        
    }
    
    .loading-indicator {
        display: inline-flex !important;
        width: 35px;
        height: 35px;
        border-radius: 50%;
        border: 6px solid rgba(0, 0, 0, 0.14);
        animation: spin 1s linear infinite;
        align-self: start;
        flex-shrink: 0;
        margin: 20px;
    }
    
    @keyframes spin {
        100% {
            transform: rotate(360deg);
        }
    }
}
