:root {
    --bg-color: #1e1e1e;
    --sidebar-bg: #252526;
    --input-bg: #3c3c3c;
    --text-color: #d4d4d4;
    --accent-color: #007acc;
    --msg-user-bg: #0e639c;
    --msg-model-bg: #3c3c3c;
    --border-color: #444;
    --message-font-size: 16px;
}

body {
    margin: 0;
    font-family: 'Microsoft YaHei', '微软雅黑', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
}

#new-chat-btn {
    width: 100%;
    padding: 8px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Drag Overlay */
.drag-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    pointer-events: none; /* Let events pass through so we don't flicker */
}

.drag-overlay.active {
    display: flex;
}

.drag-content {
    text-align: center;
    color: white;
    background-color: var(--sidebar-bg);
    padding: 40px;
    border-radius: 12px;
    border: 2px dashed var(--accent-color);
}

.drag-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.session-item {
    padding: 10px;
    margin-bottom: 5px;
    background-color: #333;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item:hover, .session-item.active {
    background-color: #444;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

#settings-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.welcome-message {
    text-align: center;
    margin-top: 50px;
    color: #888;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 8px;
    line-height: 1.5;
    font-size: var(--message-font-size);
    overflow-wrap: anywhere; /* Horizontal wrapping */
    word-break: break-word;
}

.message.user {
    align-self: flex-end;
    background-color: var(--msg-user-bg);
}

.message.model {
    align-self: flex-start;
    background-color: var(--msg-model-bg);
}

/* Input Area */
.input-area {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.preview-area {
    padding: 5px;
    font-size: 0.9rem;
    color: #aaa;
}

.input-controls {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    resize: none;
    height: 50px; /* Base height */
    font-family: inherit;
}

.file-tag {
    display: inline-flex;
    align-items: center;
    background: #333;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 5px;
    font-size: 0.8rem;
    border: 1px solid #555;
}

.remove-file {
    margin-left: 5px;
    cursor: pointer;
    color: #f44;
    font-weight: bold;
}

.remove-file:hover {
    color: #f00;
}

#send-btn, #upload-btn {
    height: 40px;
    padding: 0 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: var(--accent-color);
    color: white;
}

#upload-btn {
    background-color: #444;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: var(--sidebar-bg);
    margin: 15% auto;
    padding: 20px;
    border: 1px solid var(--border-color);
    width: 400px;
    border-radius: 8px;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.sidebar-toggle {
    display: none; /* Hidden on desktop */
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 100;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .container {
        position: relative;
    }

    .sidebar {
        position: absolute;
        left: -260px;
        top: 0;
        height: 100%;
        z-index: 90;
        transition: left 0.3s ease;
        box-shadow: 2px 0 5px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .chat-area {
        width: 100%;
    }

    .message {
        max-width: 90%;
        font-size: 14px; /* Adjust font size for mobile */
    }

    #message-input {
        height: 40px;
    }
}

.close:hover {
    color: white;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 8px;
    background-color: var(--input-bg);
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
    box-sizing: border-box;
}

.form-group small {
    color: #888;
    font-size: 0.8rem;
}

#save-settings {
    width: 100%;
    padding: 10px;
    background-color: var(--accent-color);
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}
