/* style.css */

:root {
    --primary-color: #4f46e5;
    --primary-light: #818cf8;
    --background-color: #f9fafb;
    --chat-bg: #ffffff;
    --user-msg-bg: #e0e7ff;
    --assistant-msg-bg: #f3f4f6;
    --system-msg-bg: #dcfce7;
    --error-msg-bg: #fee2e2;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

header {
    text-align: center;
    padding: 1rem;
    background-color: var(--chat-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 70vh;
    background-color: var(--chat-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

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

.message.user {
    align-self: flex-end;
    background-color: var(--user-msg-bg);
    border-bottom-right-radius: 0;
}

.message.assistant {
    align-self: flex-start;
    background-color: var(--assistant-msg-bg);
    border-bottom-left-radius: 0;
}

.message.system {
    align-self: flex-start;
    background-color: var(--system-msg-bg);
    border: 1px solid var(--border-color);
}

.message.error {
    align-self: flex-start;
    background-color: var(--error-msg-bg);
    border: 1px solid #fecaca;
    color: #b91c1c;
}

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

.timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-align: right;
}

.input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--chat-bg);
}

.loading {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

form {
    display: flex;
    gap: 0.5rem;
}

textarea {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    resize: none;
    min-height: 3rem;
    max-height: 10rem;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: var(--primary-light);
}

button {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

button:hover:not(:disabled) {
    background-color: var(--primary-light);
}

button:disabled {
    background-color: #d1d5db;
    cursor: not-allowed;
}

/* Responsive styles */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }
    
    .container {
        gap: 0.75rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .chat-container {
        height: 80vh;
    }
    
    .chat-history {
        padding: 1rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-area {
        padding: 0.75rem;
    }
    
    form {
        gap: 0.25rem;
    }
    
    textarea {
        padding: 0.5rem 0.75rem;
    }
    
    button {
        padding: 0.5rem 1rem;
    }
}

/* Scrollbar styling */
.chat-history::-webkit-scrollbar {
    width: 0.5rem;
}

.chat-history::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0.25rem;
}

.chat-history::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 0.25rem;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}