body {
    direction: rtl; /* راست‌چین کردن کل صفحه */
    font-family: 'Vazirmatn', 'B Nazanin', sans-serif; /* فونت‌های فارسی */
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: flex-end; /* برای قرارگیری چت‌بات در سمت راست */
    align-items: flex-end;
    min-height: 100vh;
}

/* دکمه شناور چت (دایره‌ای) */
.chat-toggle-button {
    position: fixed;
    bottom: 30px;
    right: 30px; /* قرارگیری در سمت راست */
    width: 60px;
    height: 60px;
    background-color: #007bff; /* رنگ آبی */
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.3s ease-in-out, background-color 0.3s ease;
    z-index: 1001; /* بالاتر از پنجره چت */
}

.chat-toggle-button:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

/* انیمیشن چرخش دکمه در زمان بارگذاری */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chat-toggle-button.spinning {
    animation: spin 0.8s ease-out; /* انیمیشن سریع چرخش */
}

/* پنجره اصلی چت‌بات */
.chat-container {
    position: fixed;
    bottom: 100px; /* کمی بالاتر از دکمه */
    right: 30px; /* هم‌راستا با دکمه */
    width: 360px;
    height: 500px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* حالت اولیه: مخفی */
    transform: scale(0.1);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out, visibility 0.3s;
    transform-origin: bottom right; /* مرکز انیمیشن باز شدن */
    z-index: 1000;
}

.chat-container.open {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

/* هدر چت‌بات */
.chat-header {
    background-color: #007bff; /* رنگ آبی */
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #0056b3;
}

.chat-title {
    margin: 0;
    font-size: 1.2em;
}

.close-chat-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.close-chat-button:hover {
    transform: rotate(90deg);
}

/* باکس نمایش پیام‌ها */
.chat-box {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column; /* پیام‌های جدید به پایین اضافه می‌شوند */
    gap: 10px; /* فاصله بین پیام‌ها */
    background-color: #f9f9f9;
}

/* استایل پیام‌ها */
.message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 20px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-sender {
    font-weight: bold;
    margin-bottom: 5px;
    display: block;
    font-size: 0.9em;
    color: #555;
}

.bot-message {
    background-color: #e2f0ff; /* آبی روشن برای ربات */
    align-self: flex-start; /* پیام ربات در سمت راست */
    border-bottom-right-radius: 5px; /* کمی تغییر در گوشه */
}

.user-message {
    background-color: #dcf8c6; /* سبز روشن برای کاربر */
    align-self: flex-end; /* پیام کاربر در سمت چپ */
    border-bottom-left-radius: 5px; /* کمی تغییر در گوشه */
}

/* ناحیه ورودی پیام */
.chat-input-area {
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #ffffff;
}

#user-input {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid #cccccc;
    border-radius: 25px;
    margin-left: 10px; /* فاصله از دکمه ارسال */
    font-family: inherit;
    font-size: 1em;
    transition: border-color 0.2s ease;
    outline: none;
}

#user-input:focus {
    border-color: #007bff;
}

#send-button {
    background-color: #28a745; /* رنگ سبز برای ارسال */
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#send-button:hover {
    background-color: #218838;
    transform: scale(1.05);
}

/* استایل برای نشانگر تایپ */
.typing-indicator .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #888;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator .dot:nth-child(1) {
    animation-delay: -0.32s;
}
.typing-indicator .dot:nth-child(2) {
    animation-delay: -0.16s;
}
.typing-indicator .dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}