:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --user-bg: #ecf0f1;
    --assistant-bg: #ffffff;
    --border-color: #bdc3c7;
    --text-color: #2c3e50;
    --light-text: #7f8c8d;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
}

header {
    background: var(--primary-color);
    color: white;
    padding: 20px 30px;
    text-align: center;
    position: relative;
}

header h1 {
    font-size: 2em;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 0.95em;
    opacity: 0.9;
}

.header-actions {
    position: absolute;
    top: 20px;
    right: 30px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-actions button {
    padding: 8px 12px;
    font-size: 0.85em;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

#user-status {
    color: white;
    font-size: 0.9em;
}

.btn-link {
    background: none;
    border: none;
    color: white;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9em;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    background: var(--user-bg);
    border-left: 4px solid #3498db;
}

.message-assistant {
    background: var(--assistant-bg);
    border-left: 4px solid #2ecc71;
}

.message-label {
    font-weight: 700;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    color: var(--light-text);
}

.message-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.7;
}

.message-sources {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9em;
    color: var(--light-text);
}

.download-buttons {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.download-btn {
    padding: 8px 16px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.download-btn:hover {
    background: #2980b9;
}

.input-section {
    border-top: 2px solid var(--border-color);
    padding: 20px;
    background: white;
}

.ai-provider-section {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ai-provider-section label {
    font-weight: 600;
    color: var(--text-color);
}

.mode-toggle-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
}

.provider-select, .model-select, .mode-select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95em;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.provider-select {
    min-width: 180px;
}

.model-select {
    min-width: 200px;
}

.mode-select {
    min-width: 240px;
    font-weight: 600;
}

.provider-select:focus, .model-select:focus, .mode-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.input-container {
    width: 100%;
}

#user-input {
    width: 100%;
    min-height: 120px;
    max-height: 400px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

#user-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.input-controls {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    justify-content: flex-end;
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #2c3e50;
}

footer {
    background: var(--primary-color);
    color: white;
    text-align: center;
    padding: 15px;
    font-size: 0.9em;
    opacity: 0.9;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 10px;
}

.modal-content .note {
    color: var(--light-text);
    font-size: 0.9em;
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--light-text);
}

.empty-state h2 {
    font-size: 1.5em;
    margin-bottom: 10px;
    color: var(--text-color);
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        height: calc(100vh - 20px);
        border-radius: 8px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    .header-actions {
        position: static;
        margin-top: 10px;
    }
    
    .input-controls {
        flex-direction: column;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
    }
}
