/* پالت رنگی */
:root {
    --chatbot-primary: #2B2A66;
    --chatbot-secondary: #3C3B8C;
    --chatbot-accent: #4A47A3;
    --chatbot-text: #333;
    --chatbot-background: #ffffff;
    --chatbot-light-bg: #f8f8f8;
    --chatbot-border: #e0e0e0;
    --chatbot-success: #4CAF50;
    --chatbot-error: #f44336;
    --chatbot-shadow: 0 5px 20px rgba(0,0,0,0.15);
    --chatbot-transition: all 0.3s ease;
}

/* تنظیم فونت و جهت برای فارسی */
#pro-chatbot, 
#pro-chatbot * {
    font-family: 'Tahoma', 'IRANSans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    direction: rtl;
    box-sizing: border-box;
}

/* کانتینر اصلی */
#pro-chatbot {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    line-height: 1.5;
    font-size: 14px;
}

/* آیکن چت */
.chat-icon {
    display: flex !important; /* تضمین نمایش آیکن */
    position: relative;
    width: 60px;
    height: 60px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    padding: 12px;
    cursor: pointer;
    box-shadow: var(--chatbot-shadow);
    transition: var(--chatbot-transition);
    align-items: center;
    justify-content: center;
}

.chat-icon:after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--chatbot-success);
    border-radius: 50%;
    top: 0;
    right: 0;
    border: 2px solid white;
}

.chat-icon.offline:after {
    background: var(--chatbot-error);
}

.chat-icon:hover {
    transform: scale(1.05);
}

.chat-icon img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

/* پنجره چت */
.chat-window {
    display: none;
    width: 350px;
    height: 500px;
    background: var(--chatbot-background);
    border-radius: 20px;
    box-shadow: var(--chatbot-shadow);
    position: absolute;
    bottom: calc(100% + 20px);
    right: 0;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.chat-window.active {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* هدر چت */
.chat-header {
    background: var(--chatbot-primary);
    color: white;
    padding: 15px 20px;
    border-radius: 20px 20px 0 0;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status.online { background: var(--chatbot-success); }
.status.offline { background: var(--chatbot-error); }

.close-btn {
    margin-right: auto;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.close-btn:hover {
    opacity: 1;
}

/* بدنه چت */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    min-height: 0; /* ✅ مهم */
}

/* استایل اسکرول بار برای مرورگرهای مدرن */
.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: var(--chatbot-light-bg);
}

.chat-body::-webkit-scrollbar-thumb {
    background-color: var(--chatbot-secondary);
    border-radius: 20px;
}

/* بخش خوشامدگویی */
.welcome-section {
    margin-bottom: 20px;
    background-color: var(--chatbot-light-bg);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

.welcome-section p {
    margin: 0 0 10px 0;
}

.welcome-section p:last-child {
    margin-bottom: 0;
}

/* دسته‌بندی‌ها */
.categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.category-btn {
    background: var(--chatbot-secondary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--chatbot-transition);
    text-align: center;
    font-weight: 500;
    font-size: 13px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.category-btn:hover {
    background: var(--chatbot-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* تاریخچه چت */
.chat-history {
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* استایل اسکرول‌بار فقط برای .chat-history */
.chat-history::-webkit-scrollbar {
    width: 6px;
}
.chat-history::-webkit-scrollbar-track {
    background: var(--chatbot-light-bg);
}
.chat-history::-webkit-scrollbar-thumb {
    background-color: var(--chatbot-secondary);
    border-radius: 20px;
}

/* پیام ها */
.message {
    max-width: 85%;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.3s ease-out forwards;
}

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

.bot-message {
    align-self: flex-start;
}

.message .content {
    padding: 12px 15px;
    border-radius: 15px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.user-message .content {
    background-color: var(--chatbot-primary);
    color: white;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 5px;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.bot-message .content {
    background-color: var(--chatbot-light-bg);
    color: var(--chatbot-text);
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 15px;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

/* قسمت پاسخ‌ها */
.response-item {
    margin-bottom: 15px;
    background-color: white;
    border: 1px solid var(--chatbot-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.response-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.response-item h4 {
    margin: 0;
    padding: 12px 15px;
    background-color: var(--chatbot-light-bg);
    font-size: 15px;
    font-weight: 600;
    color: var(--chatbot-primary);
    border-bottom: 1px solid var(--chatbot-border);
}

.response-content {
    padding: 12px 15px;
    font-size: 13px;
    color: var(--chatbot-text);
    line-height: 1.6;
}

.read-more {
    display: block;
    padding: 8px 15px;
    text-align: left;
    color: var(--chatbot-primary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    border-top: 1px solid var(--chatbot-border);
    transition: background-color 0.2s;
}

.read-more:hover {
    background-color: rgba(0,0,0,0.03);
    text-decoration: underline;
}

/* پیام‌های خاص */
.no-results, .no-direct-results {
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 10px;
}

.no-results {
    color: var(--chatbot-error);
    background-color:
	
	/* بخش اضافه شده  */
	/* استایل برای بخش ورودی */
.chat-input {
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding: 10px 0;
    border-top: 1px solid var(--chatbot-border);
}

.chat-input input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.3s;
}

.chat-input input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 2px rgba(43, 42, 102, 0.1);
}

.send-btn {
    background: var(--chatbot-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0;
}

.send-btn:before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-left: 10px solid white;
    border-bottom: 7px solid transparent;
    margin-right: -2px;
}

/* وضعیت اتصال */
.connection-status {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 11px;
    color: var(--chatbot-light-text);
}

/* حالت آفلاین */
.chatbot-offline .offline-message {
    background-color: #ffebee;
    color: var(--chatbot-error);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: center;
    font-size: 13px;
}

/* ریسپانسیو */
@media (max-width: 576px) {
    #pro-chatbot {
        right: 20px;
        bottom: 20px;
    }
    
    .chat-window {
        width: 350px;
    height: 500px; /* ✅ ارتفاع ثابت */
        right: 0;
        max-width: 400px;
    }
    
    .categories {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* سربرگ دسته بندی */
.category-header {
    background: var(--chatbot-light-bg);
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.category-header h4 {
    margin: 0;
    font-size: 15px;
    color: var(--chatbot-primary);
}
.back-to-categories,
.back-to-posts {
    background: var(--chatbot-secondary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
}
.back-to-categories:hover,
.back-to-posts:hover {
    background: var(--chatbot-accent);
}

/* لیست تیترها */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.post-title-item {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--chatbot-border);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.post-title-item:hover {
    background: var(--chatbot-light-bg);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* پیام های کمکی */
.loading-posts,
.no-posts {
    text-align: center;
    padding: 20px;
    color: #777;
    font-style: italic;
}

/* جلوگیری از اسکرول صفحه اصلی */
body.chatbot-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}
.back-to-categories {
    background: var(--chatbot-secondary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-top: 15px;
    display: inline-block;
}
.back-to-categories:hover {
    background: var(--chatbot-accent);
}
.posts-titles-list {
    font-weight: bold;
    margin: 15px 0 10px;
    color: var(--chatbot-primary);
    font-size: 14px;
}

.post-title-item {
    background: white;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.post-title-item:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.back-to-categories,
.back-to-posts {
    background: var(--chatbot-secondary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin: 15px 0;
    display: block;
    width: fit-content;
}

.back-to-categories:hover,
.back-to-posts:hover {
    background: var(--chatbot-accent);
}

.posts-list-title {
    font-weight: bold;
    margin: 15px 0 10px;
    color: var(--chatbot-primary);
    font-size: 14px;
}

.post-title-item {
    background: white;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.post-title-item:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.back-to-categories,
.back-to-posts {
    background: var(--chatbot-secondary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin: 15px 0;
    display: block;
    width: fit-content;
}

.back-to-categories:hover,
.back-to-posts:hover {
    background: var(--chatbot-accent);
}