/* frontend/static/css/style.css */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0; padding: 0; display: flex; flex-direction: column;
    height: 100vh; background-color: #ffffff; color: #000000; font-size: 16px;
}

header {
    background-color: #ffffff; color: #000000; padding: 10px 20px;
    text-align: center; border-bottom: 1px solid #cccccc; box-shadow: none;
    display: flex; justify-content: space-between; align-items: center;
}
header h1 { margin: 0; font-size: 1.5em; flex-grow: 1; text-align: left; }

#authStatusArea { display: flex; align-items: center; gap: 10px; font-size: 0.9em; }
.auth-button {
    padding: 6px 12px; background-color: #f0f0f0; color: #000000;
    border: 1px solid #cccccc; border-radius: 4px; cursor: pointer; font-size: 0.9em;
}
.auth-button:hover { background-color: #e0e0e0; }
#loggedInUserInfo strong { font-weight: 600; }

.container {
    display: flex; flex-direction: column; flex-grow: 1;
    overflow: hidden; padding: 15px; width: 90%; max-width: 1100px; 
    margin: 15px auto; box-sizing: border-box;
}

.chat-controls {
    display: flex; align-items: center; padding: 10px 0;
    background-color: #ffffff; border-bottom: 1px solid #eeeeee; margin-bottom: 10px;
    gap: 10px; 
}

#newConversationBtn, #historyBtn {
    padding: 10px 15px; background-color: #6c757d; color: white;
    border: 1px solid #5a6268; border-radius: 4px; cursor: pointer;
    font-size: 0.9em; transition: background-color 0.2s; white-space: nowrap;
}
#newConversationBtn:hover, #historyBtn:hover { background-color: #5a6268; }
#newConversationBtn:disabled, #historyBtn:disabled {
    background-color: #e9ecef; color: #adb5bd; border-color: #ced4da; cursor: not-allowed;
}

#modelSelector {
    padding: 10px; border: 1px solid #cccccc; border-radius: 4px;
    flex-grow: 1; min-width: 150px;
    background-color: #ffffff; color: #000000;
}

#loadingIndicator { color: #333333; font-style: italic; padding: 10px; }

#chatBox {
    flex-grow: 1; overflow-y: auto; padding: 15px;
    background-color: #ffffff; border: 1px solid #cccccc; border-radius: 6px;
    margin-bottom: 10px; 
}
#chatBox::-webkit-scrollbar { width: 8px; }
#chatBox::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
#chatBox::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 10px; }
#chatBox::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }
#chatBox { scrollbar-width: thin; scrollbar-color: #c1c1c1 #f1f1f1; }

.message {
    margin-bottom: 15px; padding: 12px 18px; border-radius: 18px;
    line-height: 1.6; max-width: 90%; word-wrap: break-word;
    border: 1px solid #dddddd; color: #000000;
}
.user-message {
    background-color: #f8f8f8; margin-left: auto; border-bottom-right-radius: 5px;
}
.bot-message {
    background-color: #ffffff; margin-right: auto; border-bottom-left-radius: 5px;
}
.message-attachment-note {
    font-size: 0.8em; color: #555; font-style: italic; margin-top: 5px; display: block;
}

.attachment-preview-area {
    padding: 8px 12px; background-color: #f0f0f0; border: 1px solid #d1d1d1;
    border-radius: 6px; margin-bottom: 10px; display: flex;
    justify-content: space-between; align-items: center;
    font-size: 0.9em; color: #333;
}
.attachment-preview-area.hidden { display: none; }
#attachmentFilename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 10px; }
#removeAttachmentBtn {
    background: transparent; border: none; color: #cc0000;
    font-size: 1.4em; font-weight: bold; cursor: pointer;
    padding: 0 5px; line-height: 1;
}
#removeAttachmentBtn:hover { color: #a70000; }

.chat-input-area {
    display: flex; align-items: center; padding: 10px 0; background-color: #ffffff;
}
#attachFileBtn {
    padding: 8px 12px; margin-right: 8px; background-color: #f0f0f0;
    color: #000000; border: 1px solid #cccccc; border-radius: 20px; 
    cursor: pointer; font-size: 1.2em; line-height: 1;
}
#attachFileBtn:hover { background-color: #e0e0e0; }
#attachFileBtn:disabled { background-color: #e9ecef; cursor: not-allowed; color: #6c757d; }

#userInput {
    flex-grow: 1; padding: 10px 15px; border: 1px solid #cccccc;
    border-radius: 20px; margin-right: 10px; resize: none;
    line-height: 1.5; font-size: 1em; background-color: #ffffff; color: #000000;
}

#sendStopBtn { 
    padding: 10px 20px; color: #000000; border: 1px solid #cccccc;
    border-radius: 20px; cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s; 
    font-size: 1em; min-width: 80px; text-align: center;
}
#sendStopBtn.send-action { background-color: #f0f0f0; border-color: #cccccc; }
#sendStopBtn.send-action:hover { background-color: #e0e0e0; }
#sendStopBtn.stop-action { background-color: #dc3545; border-color: #c82333; color: white; }
#sendStopBtn.stop-action:hover { background-color: #c82333; }
#sendStopBtn:disabled { background-color: #f5f5f5 !important; color: #aaaaaa !important; border-color: #dddddd !important; cursor: not-allowed; }

.hidden { display: none !important; }
#errorDisplay { 
    color: #D8000C; padding: 8px 10px; margin-top: 8px; margin-bottom: 5px;
    text-align: center; background-color: #FFD2D2; 
    border: 1px solid #D8000C; border-radius: 4px;
}

.reasoning-block { background-color: #f9f9f9; border-left: 3px solid #bbbbbb; padding: 10px 15px; margin-bottom: 10px; border-radius: 4px; font-size: 0.9em; }
.reasoning-block strong { display: block; margin-bottom: 5px; color: #000000; }
.reasoning-block p, .reasoning-block div { margin: 0; font-style: italic; color: #333333; white-space: pre-wrap; }
.reasoning-block code:not(pre code) { background-color: #eeeeee; padding: 0.1em 0.3em; border-radius: 3px; font-size: 0.95em; color: #000000;}

.bot-message .main-content-block, .bot-message .reasoning-block > div { line-height: 1.6; color: #000000; }
.bot-message .main-content-block > *:first-child, .bot-message .reasoning-block > div > *:first-child { margin-top: 0; }
.bot-message .main-content-block > *:last-child, .bot-message .reasoning-block > div > *:last-child { margin-bottom: 0; }
.bot-message h1, .bot-message h2, .bot-message h3, .bot-message h4, .bot-message h5, .bot-message h6 { margin-top: 1.2em; margin-bottom: 0.6em; font-weight: 600; color: #000000; }
.bot-message h1 { font-size: 1.7em; } .bot-message h2 { font-size: 1.4em; } .bot-message h3 { font-size: 1.2em; }
.bot-message p { margin-bottom: 0.8em; white-space: pre-wrap; color: #000000;}
.bot-message ul, .bot-message ol { margin-bottom: 0.8em; padding-left: 2em; color: #000000;}
.bot-message li { margin-bottom: 0.3em; }
.bot-message blockquote { border-left: 4px solid #cccccc; padding: 0.5em 1em; margin-left: 0; margin-right: 0; margin-bottom: 0.8em; color: #333333; background-color: #f8f8f8; }
.bot-message table { border-collapse: collapse; margin-bottom: 1em; width: auto; font-size: 0.9em; border: 1px solid #cccccc; }
.bot-message th, .bot-message td { border: 1px solid #cccccc; padding: 8px 12px; text-align: left; color: #000000; }
.bot-message th { background-color: #f0f0f0; font-weight: 600; }
.bot-message code:not(pre code) { background-color: #eeeeee; padding: 0.2em 0.4em; margin: 0 0.1em; font-size: 0.875em; border-radius: 3px; color: #000000; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; }

.code-block-container { margin-bottom: 1em; border-radius: 6px; border: 1px solid #cccccc; background-color: #ffffff; }
.code-block-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background-color: #f0f0f0; border-bottom: 1px solid #cccccc; border-top-left-radius: 5px; border-top-right-radius: 5px; color: #000000; }
.code-block-language { font-size: 0.85em; font-weight: 500; color: #000000; text-transform: lowercase; }
.copy-code-button { background-color: #e0e0e0; color: #000000; border: 1px solid #bbbbbb; padding: 5px 10px; font-size: 0.8em; border-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: background-color 0.2s; }
.copy-code-button svg { width: 1em; height: 1em; fill: #000000; }
.copy-code-button:hover { background-color: #d0d0d0; }
.copy-code-button:active { background-color: #c0c0c0; }
.code-block-container pre.hljs { margin: 0; border: none; border-radius: 0 0 5px 5px; padding: 0.8em 1em; overflow-x: auto; background-color: #ffffff !important; }
.code-block-container pre.hljs code { background: none; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.9em; line-height: 1.5; }

/* Modal Styles */
.modal { position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none !important; }
.modal-content { background-color: #ffffff; padding: 25px 30px; border: 1px solid #cccccc; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); position: relative; width: 90%; color: #000000; }
.auth-modal { max-width: 450px; } /* Auth modals specific width */
#historyModal .modal-content { max-width: 550px; /* History modal slightly wider */ }
.modal-content h2 { margin-top: 0; margin-bottom: 20px; text-align: center; font-size: 1.4em; color: #333333; }
.close-modal-btn { color: #888888; position: absolute; top: 10px; right: 20px; font-size: 28px; font-weight: bold; line-height: 1; }
.close-modal-btn:hover, .close-modal-btn:focus { color: #000000; text-decoration: none; cursor: pointer; }
.auth-modal .form-group { margin-bottom: 15px; }
.auth-modal label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 0.9em; }
.auth-modal input[type="text"], .auth-modal input[type="email"], .auth-modal input[type="password"] { width: calc(100% - 22px); padding: 10px; border: 1px solid #cccccc; border-radius: 4px; font-size: 1em; background-color: #ffffff; color: #000000; }
.auth-modal .form-button { width: 100%; padding: 10px; background-color: #007bff; color: white; border: none; border-radius: 4px; font-size: 1em; cursor: pointer; transition: background-color 0.2s; }
.auth-modal .form-button:hover { background-color: #0056b3; }
.auth-modal .error-message { color: #D8000C; background-color: #FFD2D2; border: 1px solid #D8000C; padding: 8px; margin-top: 10px; border-radius: 4px; font-size: 0.9em; text-align: center; }
#historyListContainer { max-height: 400px; overflow-y: auto; margin-top: 15px; }
#historyListContainer ul { list-style-type: none; padding: 0; }
#historyListContainer li { padding: 10px 12px; border-bottom: 1px solid #eee; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
#historyListContainer li:last-child { border-bottom: none; }
#historyListContainer li:hover { background-color: #f0f0f0; }
.history-item-content { flex-grow: 1; margin-right: 10px; }
.history-item-content strong { display: block; font-size: 0.95em; }
.history-item-content small { font-size: 0.8em; color: #555; }
.delete-history-item-btn { background: none; border: none; color: #dc3545; font-size: 1.1em; font-weight: bold; cursor: pointer; padding: 5px; line-height: 1; border-radius: 4px; margin-left: 10px; }
.delete-history-item-btn:hover { color: #c82333; background-color: #f8d7da; }