/* General Styles */
:root {
    --primary-color: #25A4D9; /* Blue from screenshot */
    --secondary-color: #f0f2f5; /* Light grey background */
    --sidebar-bg: #ffffff;
    --chat-bg: #ffffff;
    --user-msg-bg: #25A4D9;
    --user-msg-text: #ffffff;
    --ai-msg-bg: #f0f2f5; /* Slightly different grey for AI messages */
    --ai-msg-text: #333333;
    --border-color: #e0e0e0;
    --text-color: #333333;
    --link-color: #007bff;
    --error-color: #dc3545;
    --success-color: #28a745;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

html {
    height: 100%;
    box-sizing: border-box;
}
*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-color);
    margin: 0;
    height: 100%;
    display: flex;
    overflow: hidden;
    background-color: var(--secondary-color);
}

a {
    color: var(--link-color);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Layout: Sidebar + Chat Area */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 15px;
}

.chat-area {
    flex-grow: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--chat-bg);
}

/* Sidebar Content */
.sidebar h2 {
    font-size: 16px;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar #new-chat-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 100%;
    margin-bottom: 15px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar #new-chat-btn:hover {
    background-color: #1e88b5; /* Darker blue */
}

.sidebar #topic-list {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar #topic-list li {
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid transparent;
}
.sidebar #topic-list li:hover {
    background-color: var(--secondary-color);
}
.sidebar #topic-list li.active {
    background-color: #e0f7ff; /* Light blue background for active */
    border-left: 3px solid var(--primary-color);
    font-weight: 500;
}

.sidebar .auth-links {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    text-align: left; /* Align link left */
}
.sidebar .auth-links button {
    display: block; /* Make button block level */
    width: 100%;
    margin-top: 10px;
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}
.sidebar .auth-links button:hover {
    background-color: var(--error-color);
    color: white;
}

/* Chat Area Content */
#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

.user-message, .ai-message {
    padding: 10px 15px;
    border-radius: 8px; /* Less rounded corners like screenshot 3 */
    margin-bottom: 12px;
    max-width: 75%;
    line-height: 1.5;
    word-wrap: break-word;
    display: inline-block;
    text-align: left;
}

.user-message {
    background-color: var(--user-msg-bg); /* Keep blue for user */
    color: var(--user-msg-text);
    margin-left: auto;
    float: right;
    clear: both;
    /* border-bottom-right-radius: 5px; Remove flat corner */
}

.ai-message {
    background-color: var(--ai-msg-bg); /* Keep light grey for AI */
    color: var(--ai-msg-text);
    margin-right: auto;
    float: left;
    clear: both;
     /* border-bottom-left-radius: 5px; Remove flat corner */
}

/* Clear floats */
#chat-messages::after {
    content: "";
    display: table;
    clear: both;
}


.error-message {
    color: var(--error-color);
    font-style: italic;
    background-color: transparent !important;
    float: left; /* Keep error messages left aligned */
    clear: both;
    margin-right: auto;
    max-width: 75%;
    padding: 5px 0; /* Less padding for errors */
}

/* Chat Input Area */
.chat-input {
    padding: 15px 20px; /* Restore padding */
    border-top: 1px solid var(--border-color);
    background-color: #f9fafb;
    display: flex;
    align-items: center; /* Keep items centered vertically */
    gap: 15px; /* Restore gap */
    flex-shrink: 0;
}

#message-input {
    flex-grow: 1;
    resize: none;
    margin: 0;
    padding: 10px 15px; /* Restore padding */
    border: 1px solid var(--border-color);
    border-radius: 4px !important; /* Standard rectangle */
    min-height: 40px; /* Standard height */
    height: auto; /* Allow auto height */
    line-height: 1.5;
    font-size: 14px;
    max-height: 120px; /* Allow some growth */
    overflow-y: auto; /* Add scroll if needed */
}
#message-input:focus {
    outline: none !important;
    border-color: var(--primary-color) !important;
    box-shadow: none !important;
}

#send-button {
    background-color: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important; /* Standard rectangle */
    width: auto !important; /* Auto width based on content */
    height: 40px !important; /* Match input min-height */
    padding: 8px 20px !important; /* Standard padding */
    display: inline-block !important; /* Standard button display */
    /* Remove flex properties */
    flex-shrink: 0 !important;
    font-size: 14px !important;
    line-height: normal !important; /* Standard line height */
    box-shadow: none !important; /* Remove shadow */
    transition: background-color 0.2s ease;
    text-align: center;
}
#send-button:hover {
    background-color: #1e88b5 !important;
}
#send-button:disabled {
    background-color: #cccccc !important;
    cursor: not-allowed;
    opacity: 0.8;
}

/* Auth Page Styles */
body.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--secondary-color);
}

.auth-container {
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-form h2 {
    margin-top: 0;
    margin-bottom: 25px;
    color: #333;
    font-size: 20px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 13px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}
.form-group input:focus {
     outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 164, 217, 0.2);
}

.auth-form button[type="submit"] {
    width: 100%;
    padding: 10px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    margin-top: 10px;
}
.auth-form button[type="submit"]:hover {
    background-color: #1e88b5;
}

.toggle-link, .home-link {
    margin-top: 20px;
    font-size: 13px;
    color: #555;
}
.toggle-link a, .home-link a {
    color: var(--link-color);
    cursor: pointer;
}

.auth-form .error-message, .auth-form .success-message {
    font-size: 13px;
    margin-top: 15px;
    min-height: 1.2em;
}
.auth-form .error-message { color: var(--error-color); }
.auth-form .success-message { color: var(--success-color); }

/* Loading dots */
.loading::after { content: ' .'; animation: loading-dots 1s infinite steps(3, start); display: inline-block; }
@keyframes loading-dots { 33% { content: ' ..'; } 66% { content: ' ...'; } }
