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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f1f5f9;
    color: #0f172a;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #ffffff;
    padding: 16px 24px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

h1 {
    font-size: 1.5rem;
    color: #0f172a;
}

.subtitle {
    font-size: 0.85rem;
    color: #64748b;
}

.language-select {
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-select label {
    font-size: 0.9rem;
    color: #64748b;
}

select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    cursor: pointer;
    font-size: 0.9rem;
}

select:hover {
    border-color: #94a3b8;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    overflow: hidden;
}

.welcome-message {
    background: #e0f2fe;
    border-left: 4px solid #0284c7;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    color: #075985;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.message {
    display: flex;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease-in;
}

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

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

.message-bot {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-user .message-content {
    background: #dbeafe;
    color: #0f172a;
    border-bottom-right-radius: 4px;
}

.message-bot .message-content {
    background: #dcfce7;
    color: #0f172a;
    border-bottom-left-radius: 4px;
}

.message-label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
    display: block;
}

.message-user .message-label {
    color: #0369a1;
}

.message-bot .message-label {
    color: #15803d;
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    margin-top: 8px;
    font-weight: 500;
}

.input-area {
    background: #ffffff;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 -2px 16px rgba(15, 23, 42, 0.08);
    flex-shrink: 0;
}

.input-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

textarea {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    resize: none;
    min-height: 56px;
    max-height: 120px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: #2563eb;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    background: #2563eb;
    color: white;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    font-size: 0.95rem;
}

button:hover {
    background: #1d4ed8;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.typing-indicator {
    display: inline-block;
    animation: blink 1s infinite;
    margin-left: 2px;
    color: #15803d;
}

@keyframes blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

.clear-btn {
    background: #ef4444;
    padding: 8px 16px;
    font-size: 0.85rem;
}

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

.error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 40px 20px;
    font-size: 0.95rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .message-content {
        max-width: 85%;
    }
    .input-form {
        flex-direction: column;
    }
    .button-group {
        flex-direction: row;
        width: 100%;
    }
    button {
        flex: 1;
    }
}

/* RTL Language Support */
html[lang="ar"], html[lang="fa"] {
    direction: rtl;
}

html[lang="ar"] .message-user,
html[lang="fa"] .message-user {
    justify-content: flex-start;
}

html[lang="ar"] .message-bot,
html[lang="fa"] .message-bot {
    justify-content: flex-end;
}

html[lang="ar"] .message-user .message-content,
html[lang="fa"] .message-user .message-content {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
}

html[lang="ar"] .message-bot .message-content,
html[lang="fa"] .message-bot .message-content {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}