* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    flex: 1;
}

.settings-panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 20px;
}

/* API Status */
.api-status {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e1e5e9;
}

.api-status h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-status h3 i {
    color: #667eea;
}

.api-status-grid {
    display: grid;
    gap: 8px;
}

.api-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #dee2e6;
}

.api-name {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

.status-indicator {
    font-size: 14px;
    transition: color 0.3s ease;
}

.status-indicator[data-status="unknown"] {
    color: #6c757d;
}

.status-indicator[data-status="available"] {
    color: #28a745;
}

.status-indicator[data-status="unavailable"] {
    color: #dc3545;
}

.model-selection {
    margin-bottom: 25px;
}

.model-selection label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.model-selection select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s ease;
    margin-bottom: 15px;
}

.model-selection select:focus {
    outline: none;
    border-color: #667eea;
}

.model-selection select:last-of-type {
    margin-bottom: 0;
}

/* Provider-specific styling */
.model-selection select[id="provider-select"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    border-color: #667eea;
}

.model-selection select[id="provider-select"] option {
    background: white;
    color: #333;
}

.system-prompt {
    margin-bottom: 25px;
}

.system-prompt label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.system-prompt textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.system-prompt textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Usage Statistics */
.usage-stats {
    border-top: 1px solid #e1e5e9;
    padding-top: 20px;
}

.usage-stats h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.usage-stats h3 i {
    color: #667eea;
}

.stats-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.stat-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.stat-value {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    font-family: 'Courier New', monospace;
}

#total-cost {
    color: #28a745;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: #5a6268;
}

.chat-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    max-height: 600px;
}

.welcome-message {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.welcome-message i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 20px;
}

.welcome-message h3 {
    margin-bottom: 10px;
    color: #333;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #667eea;
    color: white;
}

.message.ai .message-avatar {
    background: #28a745;
    color: white;
}

.message-content {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    max-width: 70%;
    word-wrap: break-word;
}

.message.user .message-content {
    background: #667eea;
    color: white;
}

.message.ai .message-content {
    background: #e9ecef;
    color: #333;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    opacity: 0.7;
}

.message-text {
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Token and Cost Information */
.token-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    opacity: 0.8;
    flex-wrap: wrap;
    gap: 8px;
}

.token-count {
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.cost-estimate {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.message.user .token-info {
    border-top-color: rgba(255,255,255,0.2);
}

.message.user .token-count {
    background: rgba(255,255,255,0.1);
    color: white;
}

.message.user .cost-estimate {
    background: rgba(255,255,255,0.1);
    color: white;
}

.chat-input-container {
    border-top: 1px solid #e1e5e9;
    padding: 20px;
    background: #f8f9fa;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.input-wrapper textarea {
    flex: 1;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s ease;
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #5a6fd8;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.input-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .settings-panel {
        position: static;
        order: 2;
    }
    
    .chat-container {
        order: 1;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .container {
        padding: 15px;
    }
    
    .token-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}