* {
    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;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.logo p {
    font-size: 14px;
    opacity: 0.8;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e74c3c;
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: #2ecc71;
}

.status-dot.offline {
    background: #e74c3c;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100% - 80px);
}

.chat-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.chat-header h2 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 20px;
}

.chat-header p {
    color: #6c757d;
    font-size: 14px;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #ffffff;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: #f1f3f4;
    color: #2c3e50;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-input-container {
    border-top: 1px solid #e9ecef;
    background: white;
}

.input-wrapper {
    display: flex;
    padding: 16px;
    gap: 8px;
}

#messageInput {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#messageInput:focus {
    border-color: #667eea;
}

#messageInput:disabled {
    background: #f8f9fa;
    color: #6c757d;
}

#sendButton {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

#sendButton:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#sendButton:disabled {
    background: #dee2e6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.config-section {
    border-top: 1px solid #e9ecef;
}

.config-toggle {
    padding: 12px 16px;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 14px;
    color: #6c757d;
    transition: background-color 0.2s;
}

.config-toggle:hover {
    background: #e9ecef;
}

.config-panel {
    padding: 16px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: none;
}

.config-panel.open {
    display: block;
}

.config-row {
    margin-bottom: 12px;
}

.config-row label {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 4px;
    font-weight: 500;
}

.config-row input {
    width: 100%;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.config-row input:focus {
    border-color: #667eea;
}

.config-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.connect-btn, .clear-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.connect-btn {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
}

.connect-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

.clear-btn {
    background: #e9ecef;
    color: #6c757d;
}

.clear-btn:hover {
    background: #dee2e6;
}

/* Loading animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #f1f3f4;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .container {
        height: calc(100vh - 20px);
    }
    
    .header {
        padding: 16px;
    }
    
    .logo h1 {
        font-size: 20px;
    }
    
    .chat-header {
        padding: 16px;
    }
    
    .message-content {
        max-width: 85%;
    }
}