body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #1a1a1a; /* Darker background */
    height: 100vh;
    margin: 0;
}

#chat-container {
    width: 100%;
    height: 100vh;
    background-color: #1a1a1a; /* Darker background */
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chat-header {
    background-color: #000000;
    color: white;
    padding: 15px;
    font-size: 1.2em;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10; /* Ensure header is on top */
    position: relative; /* Needed for positioning settings button and z-index */
    display: flex; /* To align button and title */
    align-items: center;
    justify-content: center; /* Center the h2 using flexbox */
}

#chat-header h2 {
    margin: 0; /* Remove default margin */
    flex-grow: 1; /* Allow h2 to take available space and push button */
    text-align: center; /* Center the text within the h2 */
}

.header-icon-button {
    background: none;
    border: none;
    cursor: pointer;
    position: absolute; /* Position relative to chat-header */
    top: 50%;
    transform: translateY(-50%);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#settings-btn {
    right: 15px; /* Position settings button on the right */
}

#history-btn {
    left: 15px; /* Position history button on the left */
}

.header-icon-button img {
    width: 28px; /* Size for settings icon */
    height: 28px;
}

#chat-box {
    flex-grow: 1;
    padding: 20px 20px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    z-index: 1; /* Ensure chat bubbles are on top layer */
    position: relative;
}

.message {
    padding: 10px 15px;
    border-radius: 10px;
    max-width: 80%;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative; /* For summary button */
}

.summary-button {
    display: none;
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 2px;
}

.summary-button img {
    width: 16px;
    height: 16px;
}

.message.user-message:hover .summary-button {
    display: block;
}

.user-message {
    background-color: #000000; /* Pure black for user */
    color: white;
    align-self: flex-end;
}

.bot-message {
    background-color: #000000; /* Pure black, same as user message */
    color: #ffffff;
    align-self: flex-start;
}

.typing-indicator p {
    color: #ffffff; /* Changed from #aaa to white */
    font-style: italic;
}

#chat-form {
    display: flex;
    border-top: 1px solid #333; /* Slightly lighter border for subtle separation */
    padding: 10px 20px; /* Adjusted vertical padding */
    background-color: #2c2c2c; /* Lighter dark grey for input area */
    flex-shrink: 0;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    align-items: center; /* Vertically align input and button */
    position: relative; /* Needed for z-index to work */
    z-index: 10; /* Ensure the input form (and upload button) is on top */
}

#user-input {
    flex-grow: 1;
    border: none; /* No border */
    background-color: #333333; /* Slightly lighter than form background */
    color: white;
    border-radius: 20px; /* Keep similar roundness for input field */
    padding: 10px 15px;
    font-size: 1em;
    outline: none;
    margin-right: 10px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05); /* Very subtle light border effect */
}

#user-input::placeholder {
    color: #aaa;
}

#user-input:focus {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); /* Slightly more prominent on focus */
}

#chat-form button {
    background-color: black; /* Changed to black for the circle */
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px; /* Padding inside the button for the icon */
    width: 55px; /* Fixed size for button */
    height: 55px; /* Fixed size for button */
    border-radius: 50%; /* Made circular */
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

#chat-form button:hover {
    background-color: rgba(255, 255, 255, 0.1); /* Subtle hover effect */
}

#chat-form button img {
    width: 40px; /* Adjust to a fixed size */
    height: 40px; /* Maintain aspect ratio */
    object-fit: contain;
}

/* Specific styles for the new upload button */
#upload-btn {
    margin-right: 10px; /* Space between upload button and input */
    position: relative;
    z-index: 11; /* Ensure upload button is visible and on top */
}

/* Hide the actual file input */
.hidden-file-input {
    display: none;
}

/* Modal styles */
#settings-modal,
#history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Dark overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* On top of everything */
}

.modal-hidden {
    display: none !important; /* Important to override flex */
}

.modal-content {
    background-color: #2c2c2c; /* Same as chat form background */
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    color: white;
    text-align: center;
    display: flex; /* Use flexbox for content layout */
    flex-direction: column; /* Stack children vertically */
    max-height: 90vh; /* Limit modal height */
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #ffffff;
    flex-shrink: 0; /* Prevent title from shrinking */
}

#persona-input {
    width: calc(100% - 20px); /* Account for padding */
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #555;
    border-radius: 8px;
    background-color: #333;
    color: white;
    font-size: 1em;
    resize: vertical; /* Allow vertical resizing */
    outline: none;
}

#persona-input::placeholder {
    color: #aaa;
}

#persona-input:focus {
    border-color: #888;
}

#chat-history-content {
    flex-grow: 1; /* Allow history content to take available space */
    overflow-y: auto; /* Enable scrolling for history */
    text-align: left; /* Align text within history content */
    padding: 10px;
    border: 1px solid #444;
    border-radius: 8px;
    background-color: #333;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-history-item {
    padding: 10px 15px;
    border-radius: 10px;
    word-wrap: break-word;
    line-height: 1.4;
    background-color: #1a1a1a;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space out name and delete button */
}

.chat-history-item:hover {
    background-color: #333;
}

.chat-history-item.active-chat {
    border: 2px solid #007bff; /* Highlight active chat */
    padding: 8px 13px; /* Adjust padding due to border */
}

.chat-name {
    flex-grow: 1;
    font-weight: bold;
}

/* Style for the new chat button */
.new-chat-button {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
    margin-bottom: 15px; /* Space below the button */
}

.new-chat-button:hover {
    background-color: #0056b3;
}

.user-history-item {
    background-color: #000000;
    color: white;
    align-self: flex-end; /* Align user messages to the right */
    max-width: 90%;
}

.assistant-history-item {
    background-color: #1a1a1a; /* A slightly different dark color for bot history */
    color: #ffffff;
    align-self: flex-start; /* Align bot messages to the left */
    max-width: 90%;
}

.chat-history-sender {
    font-weight: bold;
    margin-right: 5px;
    color: #a0a0a0; /* Slightly dim the sender label */
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px; /* Space between buttons */
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

.modal-content button {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}

#save-persona-btn {
    background-color: #007bff; /* A nice blue for save */
    color: white;
}

#save-persona-btn:hover {
    background-color: #0056b3;
}

#close-modal-btn,
#close-history-modal-btn {
    background-color: #6c757d; /* A grey for close */
    color: white;
}

#close-modal-btn:hover,
#close-history-modal-btn:hover {
    background-color: #5a6268;
}

/* New styles for delete button */
.delete-chat-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease-in-out; /* Add transition for hover effect */
}

.delete-chat-button img {
    width: 20px;
    height: 20px;
    opacity: 0.7; /* Slightly dim the icon */
    transition: opacity 0.2s ease-in-out;
}

.delete-chat-button:hover img {
    opacity: 1; /* Full opacity on hover */
    transform: scale(1.1); /* Slightly enlarge on hover */
}

/* Memories modal styles */
#memories-list {
    flex-grow: 1;
    overflow-y: auto;
    text-align: left;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 8px;
    background-color: #333;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
}

.memory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1a1a1a;
    padding: 10px 15px;
    border-radius: 10px;
    color: white;
}

.delete-memory-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
}

.delete-memory-btn img {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: opacity 0.2s ease-in-out;
}

.delete-memory-btn:hover img {
    opacity: 1;
    transform: scale(1.1);
}

/* Clear Data button in settings */
#clear-data-btn {
    background-color: #dc3545;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
    margin-top: 15px;
}
#clear-data-btn:hover {
    background-color: #c82333;
}