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

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --border-color: #334155;
    --text-color: #f1f5f9;
    --text-secondary: #94a3b8;
    --user-msg-bg: #6366f1;
    --assistant-msg-bg: #1e293b;
    --input-bg: #1e293b;
    --hover-color: #2563eb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    padding: 20px 24px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 24px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

header h1 > * {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.monkey-wave {
    display: inline-block;
    animation: wave 2s ease-in-out infinite;
    transform-origin: 70% 70%;
    font-size: 28px;
    -webkit-text-fill-color: initial !important;
    color: inherit;
    background: none !important;
}

@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    10%, 30% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    40%, 60% { transform: rotate(0deg); }
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.model-selector label {
    font-size: 14px;
    color: var(--text-secondary);
}

#model {
    padding: 8px 12px;
    background: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

#model:hover,
#model:focus {
    border-color: var(--primary-color);
}

.clear-btn {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 15px;
}

.message.user .message-content {
    background: var(--user-msg-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--assistant-msg-bg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

.input-container {
    padding: 20px 24px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    background: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    outline: none;
    transition: border-color 0.2s;
}

#userInput:focus {
    border-color: var(--primary-color);
}

#userInput::placeholder {
    color: var(--text-secondary);
}

#sendBtn {
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 48px;
    height: 48px;
}

#sendBtn:hover {
    background: var(--hover-color);
    transform: translateY(-1px);
}

#sendBtn:active {
    transform: translateY(0);
}

#sendBtn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
}

footer {
    padding: 12px 24px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    transition: background 0.3s;
}

.status-indicator.connected {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.info {
    font-size: 12px;
    opacity: 0.7;
}

/* Scrollbar styling */
.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    header h1 {
        font-size: 20px;
    }

    .message-content {
        max-width: 90%;
        font-size: 14px;
    }

    .model-selector {
        font-size: 13px;
    }

    #model {
        font-size: 13px;
    }
}
