/* Base styles for the chat container */
.aai-chat-container {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 600px;
    margin: 30px auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 600px; /* Fixed height for desktop, adjusted for mobile */
    border: 1px solid #e0e0e0;
}

/* Header styling */
.aai-chat-header {
    background-color: #3646DD;
    color: white;
    padding: 15px 20px;
    font-size: 1.2em;
    font-weight: bold;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Icon in header */
.aai-chat-header .gemini-icon {
    margin-right: 10px;
    font-size: 1.5em; /* Adjust icon size */
}

/* Messages area styling */
.aai-chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto; /* Enable scrolling for messages */
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    scroll-behavior: smooth; /* Smooth scrolling for new messages */
}

/* Individual message container */
.message {
    display: flex;
    align-items: flex-end; /* Align bubbles to the bottom */
}

.user-message {
    justify-content: flex-end; /* User messages align right */
}

.bot-message {
    justify-content: flex-start; /* Bot messages align left */
}

/* Message bubble styling */
.message-bubble {
    padding: 12px 16px;
    border-radius: 20px;
    max-width: 75%; /* Limit bubble width */
    position: relative;
    word-wrap: break-word; /* Ensure long words wrap */
}

.user-message .message-bubble {
    background-color: #e3f2fd; /* Light blue for user messages */
    color: #333;
    border-bottom-right-radius: 5px; /* Slightly less rounded on the bottom-right for user */
}

.bot-message .message-bubble {
    background-color: #f1f0f0; /* Light grey for bot messages */
    color: #333;
    border-bottom-left-radius: 5px; /* Slightly less rounded on the bottom-left for bot */
}

/* Message text styling */
.message-text {
    font-size: 0.95em;
    line-height: 1.4;
}

/* Message timestamp styling */
.message-info-time {
    font-size: 0.75em;
    color: #999;
    margin-top: 5px;
    text-align: right; /* Default to right for user messages */
}

.bot-message .message-info-time {
    text-align: left; /* Align left for bot messages */
}

/* Input area styling */
.aai-chat-input-area {
    display: flex;
    padding: 15px 20px;
    background-color: #f7f7f7;
    border-top: 1px solid #e0e0e0;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    align-items: center; /* Vertically align items in the input area */
    justify-content: center; /* Center the input wrapper horizontally */
}

/* Material Symbols icon settings */
.material-symbols-rounded {
    font-variation-settings:
    'FILL' 1,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24
}

/* Input wrapper for textarea and send button */
.message-input-wrapper {
    position: relative; /* Crucial: This makes the wrapper the positioning context for its children */
    width: 100%;
    max-width: 500px; /* Adjust as needed */
    border: 1px solid #ccc;
    border-radius: 25px; /* Rounded corners for the entire unit */
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex; /* Use flex to allow textarea to fill space */
    align-items: flex-end; /* Align items to the bottom, useful if textarea grows */
    padding: 10px; /* Padding inside the wrapper */
}

/* Textarea styling */
.message-input {
    flex-grow: 1; /* Allows the textarea to take up available space */
    border: none;
    outline: none;
    padding-right: 50px; /* Make space for the button inside the textarea */
    padding-left: 15px; /* Consistent left padding */
    padding-top: 10px;
    padding-bottom: 10px;
    font-size: 1em; /* Adjusted to be consistent with chat text */
    background-color: transparent;
    min-height: 40px; /* Initial height for the textarea */
    resize: vertical; /* Allow vertical resizing, but not horizontal */
    overflow-y: auto; /* Enable scrollbar if text exceeds height */
    line-height: 1.4; /* Improve readability for multi-line text */
    transition: all 0.2s ease-in-out; /* Smooth transition for focus */
}

.message-input::placeholder {
    color: #999;
}

.message-input:focus {
    border-color: #3646DD;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

/* Send button styling */
.send-button {
    position: absolute; /* Take the button out of the normal flow */
    right: 10px; /* Distance from the right edge of the wrapper */
    top: 50%; /* Start from the middle vertically */
    transform: translateY(-50%); /* Adjust upwards by half its height to perfectly center */
    background-color: #3646DD;
    color: #FFFFFF;
    border: none;
    border-radius: 50%; /* Makes the button round */
    width: 36px; /* Adjust size as needed */
    height: 36px; /* Adjust size as needed */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 18px; /* Size of the Material Symbol icon */
    padding: 0;
    flex-shrink: 0; /* Prevent button from shrinking */
    z-index: 10; /* Ensure the button is above the textarea */
    transition: background-color 0.2s ease, transform 0.2s ease; /* Smooth transitions */
}

.send-button:hover {
    background-color: #FFFFFF !important;;
    color: #3646DD !important;
    border: 3px solid !important;
    border-color: #3646DD !important;
    border-radius: 50%; /* Makes the button round */
    transform: translateY(-50%) scale(1.05); /* Slight scale effect on hover */
}

.send-button:active {
    background-color: #3646DD;
    transform: translateY(-50%) scale(0.95); /* Slight shrink effect on click */
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .aai-chat-container {
        margin: 15px;
        height: 80vh; /* Adjust height for mobile viewport */
        border-radius: 8px;
    }

    .aai-chat-header {
        padding: 12px 15px;
        font-size: 1.1em;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
    }

    .aai-chat-messages {
        padding: 15px;
        gap: 8px;
    }

    .message-bubble {
        max-width: 85%;
        padding: 10px 14px;
    }

    .aai-chat-input-area {
        padding: 10px 15px;
        border-bottom-left-radius: 8px;
        border-bottom-right-radius: 8px;
    }

    .message-input-wrapper {
        padding: 8px;
    }

    .message-input {
        padding: 8px 12px;
        min-height: 35px;
        padding-right: 40px; /* Adjust for smaller button on mobile */
    }

    .send-button {
        width: 32px; /* Smaller button on mobile */
        height: 32px;
        font-size: 16px;
        right: 8px;
    }
}