body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Arial', sans-serif;
    scroll-behavior: smooth;
    overflow-x: hidden;
    position: relative;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100dvh; /* Use dynamic viewport height for better mobile support */
    background-color: #f0f2f5;
    position: relative;
    overflow: hidden;
}

.chat-header {
    background-color: #4a4a4a;
    color: white;
    padding: 15px;
    text-align: center;
}

.chat-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-right: 30px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.message {
    max-width: 75%;
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
    animation: messageIn 0.3s ease-out;
    opacity: 0;
    transform: translateY(20px);
    animation-fill-mode: forwards;
    clear: both;
    word-break: break-all;
    font-size: 1.1rem;
}

.message.bot {
    margin-bottom: 0px;
    padding-bottom: 25px;
}

@keyframes messageIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background: #76e17644;
    float: right;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.message.ai {
    background-color: #d4edda;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.chat-input {
    display: flex;
    padding: 15px;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    word-break: break-all;
    position: relative;
}

#messageInput {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 20px;
    font-size: 1.1rem;
    line-height: 1.4rem;
    background-color: #f0f2f5;
    max-height: 150px;
    overflow: auto;
}

#messageInput[contenteditable=true]:empty:before{
    content: attr(placeholder);
    pointer-events: none;
    display: block; /* For Firefox */
    color: #aaa;
}

#sendButton {
    background-color: #0084ff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    margin-left: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendButton:hover {
    background-color: #0073e6;
}


/* For webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.botmessage {
 margin-left: 40px;
 margin-top: -12px;
}

.botlogo {
    width: 30px; 
    height: 30px; 
    border-radius: 50%; 
    position:absolute;

}

#reload {
    position: absolute;
    right: 10px;
}


/* HTML: <div class="loader"></div> */
.loader {
    width: 15px;
    aspect-ratio: 1;
    border-radius: 50%;
    animation: l5 1s infinite linear alternate;
    margin-left: 70px;
    margin-top: 7px;
  }
  @keyframes l5 {
      0%  {box-shadow: 20px 0 #000, -20px 0 #0002;background: #000 }
      33% {box-shadow: 20px 0 #000, -20px 0 #0002;background: #0002}
      66% {box-shadow: 20px 0 #0002,-20px 0 #000; background: #0002}
      100%{box-shadow: 20px 0 #0002,-20px 0 #000; background: #000 }
  }

@media (max-width: 600px) {
    body {
        font-size: 12px;
    }

    .chat-container {
        height: 100%; /* Use 100% instead of 100vh for better mobile keyboard handling */
        min-height: -webkit-fill-available; /* iOS viewport fix */
    }

    .message.bot {
        padding: 0px;
        padding-bottom: 10px;
    }
    .message.user {
        margin-bottom: 10px;
    }

    .botmessage {
        margin-left: 0;
    }
    .botlogo {
        margin-right: 10px;
        float: left;
        position: relative;
    }
    .message {
        margin-bottom: 5px;
        max-width: 100%;
    }
    .chat-header {
        padding: 10px;
    }

    .chat-messages {
        padding: 10px;
    }

    .chat-input {
        position: sticky;
        bottom: 0;
        padding: 10px;
        z-index: 10;
    }

    /* Ensure chat container adapts to visible viewport when keyboard is shown */
    @supports (-webkit-touch-callout: none) {
        .chat-container {
            height: -webkit-fill-available;
        }
    }
}
