/* style.css */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    background: #4a5568;
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-weight: 600;
}

header p {
    font-size: 1rem;
    opacity: 0.9;
}

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

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f7fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 80%;
    padding: 16px;
    border-radius: 12px;
    animation: fadeIn 0.3s ease-out;
}

.user-message {
    align-self: flex-end;
    background: #667eea;
    color: white;
}

.assistant-message {
    align-self: flex-start;
    background: #e2e8f0;
}

.system-message {
    align-self: center;
    background: #f0f4f8;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    max-width: 90%;
    text-align: center;
}

.system-message.error {
    background: #fed7d7;
    color: #c53030;
    border-color: #feb2b2;
}

.message-role {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.message-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.input-area {
    display: flex;
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    gap: 12px;
}

#userInput {
    flex: 1;
    padding: 14px;
    border: 1px solid #cbd5e0;
    border-radius: 12px;
    resize: none;
    min-height: 60px;
    max-height: 150px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#userInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#sendButton {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

#sendButton:hover:not(:disabled) {
    background: #5a67d8;
}

#sendButton:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f7fafc;
    padding: 20px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e2e8f0;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 0;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background: #a0aec0;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

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

@keyframes typing {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1); opacity: 1; }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        border-radius: 0;
    }
    
    header {
        padding: 16px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .chat-history {
        padding: 16px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-area {
        padding: 12px;
    }
    
    #userInput {
        min-height: 50px;
        padding: 12px;
    }
}