* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    height: 100vh;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    text-align: center;
    padding: 2rem;
}

.login-container h1 {
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.login-container p {
    color: #888;
    margin-bottom: 2rem;
}

.login-button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #4a90d9;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
}

.login-button:hover {
    background: #3a7bc8;
}

/* Chat Layout */
.app {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background: #16162a;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2a4a;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #2a2a4a;
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.new-chat-btn:hover {
    background: #3a7bc8;
}

.conversations {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    display: block;
    padding: 0.75rem;
    color: #ccc;
    text-decoration: none;
    border-radius: 4px;
    margin-bottom: 2px;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item:hover {
    background: #2a2a4a;
}

.conversation-item.active {
    background: #2a2a4a;
    color: white;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #2a2a4a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.user-name {
    color: #888;
}

.logout-link {
    color: #4a90d9;
    text-decoration: none;
}

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

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.welcome {
    text-align: center;
    padding: 4rem 2rem;
    color: #888;
}

.welcome h2 {
    margin-bottom: 0.5rem;
    color: #ccc;
}

.message {
    max-width: 800px;
    margin: 0 auto 1rem;
    padding: 1rem;
    border-radius: 8px;
}

.message.user {
    background: #2a2a4a;
}

.message.assistant {
    background: #1e3a5f;
}

.message-content {
    line-height: 1.6;
}

/* Markdown styles */
.message-content p {
    margin: 0 0 1em 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 1.5em 0 0.5em 0;
    font-weight: 600;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
    margin-top: 0;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.1em; }

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: #0d1117;
    border-radius: 6px;
    padding: 1em;
    overflow-x: auto;
    margin: 1em 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
    line-height: 1.5;
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0 1em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.25em 0;
}

.message-content blockquote {
    border-left: 3px solid #4a90d9;
    margin: 1em 0;
    padding: 0.5em 1em;
    background: rgba(74, 144, 217, 0.1);
    border-radius: 0 4px 4px 0;
}

.message-content blockquote p {
    margin: 0;
}

.message-content a {
    color: #58a6ff;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
}

.message-content th,
.message-content td {
    border: 1px solid #3a3a5a;
    padding: 0.5em 0.75em;
    text-align: left;
}

.message-content th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
}

.message-content hr {
    border: none;
    border-top: 1px solid #3a3a5a;
    margin: 1.5em 0;
}

.message-content img {
    max-width: 100%;
    border-radius: 4px;
}

.tool-calls {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.tool-call {
    font-size: 0.8rem;
    color: #888;
}

.tool-name {
    background: #333;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: monospace;
}

/* Input Area */
.input-area {
    padding: 1rem;
    border-top: 1px solid #2a2a4a;
    display: flex;
    gap: 0.5rem;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

#message-input {
    flex: 1;
    padding: 0.75rem;
    background: #2a2a4a;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    color: white;
    font-size: 1rem;
    resize: none;
    font-family: inherit;
}

#message-input:focus {
    outline: none;
    border-color: #4a90d9;
}

#send-btn {
    padding: 0.75rem 1.5rem;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

#send-btn:hover {
    background: #3a7bc8;
}

#send-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

/* Loading state */
.loading .message-content::after {
    content: "...";
    animation: dots 1s infinite;
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* Settings Button */
.settings-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
}

.settings-btn:hover {
    color: #ccc;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    background: #1e1e3a;
    border-radius: 8px;
    padding: 1.5rem;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid #3a3a5a;
}

.modal-content h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #ccc;
    font-size: 0.9rem;
}

.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: #2a2a4a;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    color: white;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4a90d9;
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.6rem 1.2rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: #4a90d9;
    color: white;
}

.btn-primary:hover {
    background: #3a7bc8;
}

.btn-secondary {
    background: #3a3a5a;
    color: #ccc;
}

.btn-secondary:hover {
    background: #4a4a6a;
}
