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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* Login Styles */
.card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 100%;
}

.card h1 {
    font-size: 32px;
    margin-bottom: 10px;
    text-align: center;
    color: #667eea;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary {
    background: #ff6b6b;
    color: white;
    font-size: 14px;
    padding: 8px 16px;
}

.btn-secondary:hover {
    background: #ee5a52;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 14px;
}

/* Chat Styles */
.chat-wrapper {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h1 {
    font-size: 24px;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    font-size: 14px;
    opacity: 0.9;
}

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

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.welcome-message h2 {
    font-size: 28px;
    color: #667eea;
    margin-bottom: 10px;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-user {
    text-align: right;
}

.message-content {
    display: inline-block;
    padding: 14px 18px;
    border-radius: 12px;
    max-width: 70%;
    word-wrap: break-word;
}

.message-user .message-content {
    background: #667eea;
    color: white;
}

.message-assistant .message-content {
    background: white;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Markdown formatting styles */
.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.message-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.95em;
}

.message-label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #666;
}

.message-user .message-label {
    text-align: right;
}

.input-container {
    padding: 20px 30px;
    background: white;
    border-radius: 0 0 16px 16px;
    border-top: 2px solid #f0f0f0;
}

#chatForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.model-selector-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.model-selector-container label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

#modelSelect {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

#modelSelect:focus {
    outline: none;
    border-color: #667eea;
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#promptInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s;
}

#promptInput:focus {
    outline: none;
    border-color: #667eea;
}

#chatForm .btn-primary {
    width: 100%;
    padding: 12px 30px;
}

/* Metrics Panel */
.metrics-panel {
    margin-top: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.metrics-header {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.metric-label {
    color: #666;
    font-weight: 500;
}

.metric-value {
    color: #333;
    font-weight: 600;
    font-family: 'Monaco', 'Courier New', monospace;
}

@media (max-width: 600px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading Spinner */
.spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
}

.spinner-border {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-wrapper {
        height: 100vh;
        border-radius: 0;
    }

    .chat-header {
        border-radius: 0;
        flex-direction: column;
        gap: 10px;
    }

    .message-content {
        max-width: 85%;
    }
}
