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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.subtitle {
    opacity: 0.9;
    font-size: 0.95rem;
}

.language-selector {
    margin: 16px auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.language-selector label {
    font-size: 0.9rem;
    opacity: 0.95;
}

.language-selector select {
    padding: 6px 12px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.language-selector select:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.language-selector select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
}

.language-selector select option {
    background: #5a4a8a;
    color: white;
}

.status {
    display: inline-block;
    margin-top: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status.connected {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.status.disconnected {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.status.reconnecting {
    background: rgba(251, 191, 36, 0.2);
    color: #f59e0b;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.token-counter {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

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

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    padding: 14px 18px;
    border-radius: 12px;
    max-width: 90%;
    line-height: 1.5;
    animation: slideIn 0.3s ease;
}

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

.message.system {
    background: #f3f4f6;
    color: #374151;
    align-self: center;
    max-width: 100%;
    text-align: center;
    font-weight: 500;
}

.message.question {
    background: #ede9fe;
    border-left: 4px solid #7c3aed;
    color: #5b21b6;
    align-self: flex-start;
}

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

.message.flags {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    color: #78350f;
    align-self: flex-start;
}

.message.rationale {
    background: #dbeafe;
    border-left: 4px solid #3b82f6;
    color: #1e40af;
    align-self: flex-start;
}

.message.error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
    align-self: center;
    max-width: 100%;
}

.message.haily {
    background: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%);
    border-left: 4px solid #667eea;
    color: #4c1d95;
    align-self: flex-start;
    font-weight: 500;
}

.message ul {
    margin-top: 8px;
    padding-left: 20px;
}

.message li {
    margin-bottom: 4px;
}

.input-container {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

#answer-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

#answer-input:focus {
    outline: none;
    border-color: #667eea;
}

#send-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

#send-btn:active {
    transform: translateY(0);
}

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

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

.chat-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .container {
        height: 100vh;
        border-radius: 0;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .message {
        max-width: 95%;
    }
}
