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

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --bg: #f5f6fa;
    --surface: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dce1e6;
    --user-bg: #eaf2f8;
    --assistant-bg: #ffffff;
    --error: #c0392b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Login */
.login-container {
    margin: auto;
    padding: 2rem;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.logo {
    max-width: 160px;
    height: auto;
    margin-bottom: 1rem;
}

.logo-small {
    height: 28px;
    width: auto;
    margin-right: 0.75rem;
}

.login-container h1 {
    color: var(--primary);
    margin-bottom: 0.25rem;
    font-size: 1.75rem;
}

.subtitle {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.2);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    margin-top: 0.5rem;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--user-bg);
}

.error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

/* Chat Layout */
#chat-screen header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
}

.header-left h2 {
    color: var(--primary);
    font-size: 1.25rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#user-display {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Messages */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-message {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
    font-size: 0.95rem;
}

.message {
    max-width: 80%;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    line-height: 1.5;
    position: relative;
}

.message.user {
    align-self: flex-end;
    background: var(--user-bg);
    border: 1px solid var(--border);
}

.message.assistant {
    align-self: flex-start;
    background: var(--assistant-bg);
    border: 1px solid var(--border);
    white-space: pre-wrap;
}

.message .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--bg);
}

.sources {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-light);
}

.sources a {
    color: var(--primary-light);
    text-decoration: none;
}

.sources a:hover {
    text-decoration: underline;
}

/* Input */
#chat-screen footer {
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

#chat-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#question-input {
    flex: 1;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    min-height: 2.5rem;
    max-height: 8rem;
}

#question-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.2);
}

#chat-form .btn-primary {
    width: auto;
    margin-top: 0;
    white-space: nowrap;
}

/* Loading indicator */
.loading {
    align-self: flex-start;
    padding: 0.875rem 1rem;
    color: var(--text-light);
    font-style: italic;
}

.loading::after {
    content: "";
    animation: dots 1.5s infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .message {
        max-width: 95%;
    }

    #chat-messages {
        padding: 1rem;
    }

    #chat-screen footer {
        padding: 0.75rem 1rem;
    }
}
