/* Reset and base styles */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@400;500;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --chat-max-width: 800px;
    --chat-height: 80vh;
    --chat-font-size: 16px;
    --sidebar-width: 250px;
    --color-primary: #4a90e2;
    --color-primary-hover: #357ab7;
    --color-background: #f5f7fa;
    --color-user-bg: var(--color-primary);
    --color-assistant-bg: #e1e1e1;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-background);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
header {
    background-color: var(--color-primary);
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    padding-bottom: 0.25rem;
}

header h1[contenteditable="true"] {
    cursor: text;
}

header .header-right button {
    background-color: #fff;
    color: var(--color-primary);
    border: none;
    padding: 0.5rem 1rem;
    margin-left: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s, color 0.3s;
    display: inline-flex; /* Changed from flex to inline-flex */
    align-items: center;
    justify-content: center; /* Added to center the content */
    gap: 0.5rem;
}

/* Add specific styling for the settings button if needed */
#settings-btn {
    white-space: nowrap; /* Prevents line breaks */
    background-color: #fff;
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    padding: 0.5rem;
}

header .header-right button:hover {
    background-color: var(--color-primary-hover);
    color: #fff;
}

header .header-right button i {
    font-size: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px; /* Adjust spacing as needed */
}

/* Container to hold sidebar and main content */
.container {
    display: flex;
    height: calc(100vh - 80px); /* Adjust based on header/footer height */
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background-color: #ffffff;
    border-right: 1px solid #ddd;
    padding: 1rem;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    position: fixed;
    top: 80px; /* Height of header */
    left: 0;
    bottom: 0;
    z-index: 999;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    color: #333;
}

.close-sidebar-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s;
}

.close-sidebar-btn:hover {
    color: #000;
}

.conversation-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.conversation-item {
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.conversation-item:hover {
    background-color: #f0f0f0;
}

.conversation-item.active {
    background-color: #e0e0e0;
}

.conversation-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: #ff5c5c;
    font-size: 1rem;
    margin-left: 0.25rem;
    transition: color 0.3s;
}

.conversation-actions button:hover {
    color: #cc0000;
}

.export-btn {
    background-color: #4a90e2;
    color: #fff;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.export-btn:hover {
    background-color: #357ab7;
}

.export-btn i {
    font-size: 1rem;
}

#regenerate-title-btn i, #settings-sidebar-btn i {
    font-size: 1rem;
}

#regenerate-title-btn:hover, #settings-sidebar-btn:hover {
    background-color: #357ab7;
}

/* Main Chat Section */
main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    margin-left: 0;
    transition: margin-left 0.3s ease-in-out;
}

body.sidebar-open main {
    margin-left: var(--sidebar-width);
}

.chat-section {
    width: 100%;
    max-width: var(--chat-max-width);
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: var(--chat-height);
    font-size: var(--chat-font-size);
}

.chat-history {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.chat-history.hidden {
    display: none;
}

.chat-history h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #333;
}

.chat-input {
    border-top: 1px solid #ddd;
    padding: 1rem;
}

.chat-input form {
    display: flex;
}

.chat-input textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
    font-size: inherit;
    min-height: 60px;
}

.chat-input button {
    background-color: #4a90e2;
    color: #fff;
    border: none;
    padding: 0 1.5rem;
    margin-left: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

.chat-input button:hover {
    background-color: #357ab7;
}

/* Message Styles */
.message {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 0.75rem 1rem;
    font-size: inherit;
    line-height: 1.4;
    white-space: pre-wrap;
    position: relative;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    background-color: var(--color-assistant-bg);
    color: #333;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.user .message-content {
    background-color: var(--color-user-bg);
    color: #fff;
    border-radius: 16px 16px 0 16px;
}

.message.assistant .message-content {
    border-radius: 16px 16px 16px 0;
}


.message-content pre {
    background-color: #f6f8fa;
    border-radius: 8px;
    padding: 1.5rem 0.75rem 0.75rem;
    margin-top: 0.5rem;
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    position: relative;
}

.message-content pre::before {
    content: attr(data-lang);
    position: absolute;
    top: 0.25rem;
    left: 0.5rem;
    font-size: 0.75rem;
    color: #555;
}

.message-content pre code {
    display: block;
}

.copy-code-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background-color: var(--color-primary);
    color: #fff;
    border: none;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-content pre:hover .copy-code-btn {
    opacity: 1;
}

.message-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.message-actions button {
    background-color: #ff5c5c;
    border: none;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.3s;
}

.message-actions button.regenerate-btn {
    background-color: #ffa500;
}

.message-actions button:hover {
    background-color: #cc0000;
}

.message-actions button.regenerate-btn:hover {
    background-color: #e69500;
}

/* Timestamps */
.message-content .timestamp {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.25rem;
    align-self: flex-end;
}

/* Avatars */
.message.user .message-content::before {
    content: url('files/user-avatar.png'); /* Replace with actual avatar path */
    position: absolute;
    top: 0;
    left: -70px;
    width: 64px;
    height: 64px;
}

.message.assistant .message-content::before {
    content: url('files/assistant-avatar.png'); /* Replace with actual avatar path */
    position: absolute;
    top: 0;
    right: -70px;
    width: 64px;
    height: 64px;
}

/* Settings Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right:0;
    bottom:0;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
}

.close-button:hover {
    color: #000;
}

.modal-content h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.warning-text {
    color: red;
    font-size: 0.8rem;
}

.save-btn {
    background-color: #4a90e2;
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

.save-btn:hover {
    background-color: #357ab7;
}

.add-model-btn {
    background-color: #4a90e2;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
    margin-bottom: 1rem;
}

.add-model-btn:hover {
    background-color: #357ab7;
}
body.dark-mode {
    background-color: #121212;
    color: #fffdff;
}

body.dark-mode .chat-section {
    background-color: #1e1e1e;
    color: #fffdff;
}

body.dark-mode .sidebar {
    background-color: #1e1e1e;
    color: #cccccc;
}

body.dark-mode .modal-content {
    background-color: #1e1e1e;
    color: #fffdff;
}

body.dark-mode .form-group input,
body.dark-mode .form-group select {
    background-color: #333333;
    color: #ffffff;
    border: 1px solid #555555;
}

body.dark-mode .add-model-btn {
    background-color: #444444;
    color: #ffffff;
}

body.dark-mode .add-model-btn:hover {
    background-color: #666666;
}

body.dark-mode .message.user .message-content {
    background-color: #333333;
    color: #ffffff;
}

body.dark-mode .message.assistant .message-content {
    background-color: #444444;
    color: #ffffff;
}

body.dark-mode .message-content pre {
    background-color: #2d2d2d;
}

body.dark-mode .message-content pre::before {
    color: #ccc;
}

body.dark-mode .copy-code-btn {
    background-color: var(--color-primary);
}

body.dark-mode .theme-toggle-btn {
    background-color: #444444;
    color: #ffffff;
}

/* Loading Indicator Styles */
#loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-size: 1.2rem;
    color: #333;
    z-index: 1001;
}

.hidden {
    display: none;
}

/* Footer Styles */
footer {
    background-color: #4a90e2;
    color: #fff;
    text-align: center;
    padding: 0.75rem;
    font-size: 0.9rem;
    width: 100%;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .sidebar {
        width: 80%;
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    body.sidebar-open main {
        margin-left: 0;
    }
}

/* Folder-related styles */
.folder-controls {
    padding: 10px;
    margin-top: 15px;
    border-top: 1px solid #ddd;
}

.folder-list {
    list-style: none;
    padding: 0;
    margin: 5px 0;
}

.folder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 2px;
}

.folder-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.folder-item.active {
    background-color: rgba(0, 0, 0, 0.1);
    font-weight: bold;
}

.folder-actions {
    display: flex;
    gap: 5px;
    opacity: 0.6;
}

.folder-actions button {
    background: none;
    border: none;
    font-size: 0.9em;
    cursor: pointer;
    padding: 2px;
}

.folder-actions button:hover {
    opacity: 0.8;
}

.folder-separator {
    height: 1px;
    background-color: #ddd;
    margin: 10px 0;
}

.folder-menu {
    position: absolute;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 150px;
}

.folder-menu-item {
    padding: 8px 12px;
    cursor: pointer;
}

.folder-menu-item:hover {
    background-color: #f0f0f0;
}

.folder-menu-item.selected {
    background-color: #e0e0e0;
}

#create-folder-btn {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

#create-folder-btn:hover {
    background-color: #eaeaea;
}

/* Dark mode support for folders */
.dark-mode .folder-controls {
    border-color: #444;
}

.dark-mode .folder-separator {
    background-color: #444;
}

.dark-mode .folder-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .folder-item.active {
    background-color: rgba(255, 255, 255, 0.15);
}

.dark-mode #create-folder-btn {
    background-color: #333;
    border-color: #555;
    color: #ccc;
}

.dark-mode #create-folder-btn:hover {
    background-color: #444;
}

.dark-mode .folder-menu {
    background-color: #222;
    border-color: #555;
    color: #ddd;
}

.dark-mode .folder-menu-item:hover {
    background-color: #333;
}

.dark-mode .folder-menu-item.selected {
    background-color: #444;
}

/* Sidebar actions */
.sidebar-actions {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
}

.sidebar-actions .export-btn {
    flex: 1; /* Make buttons take equal width */
}

