/* آیکون چت بات */
#chatbot-icon {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(145deg, #004080, #00254D);
    color: white;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    cursor: grab;
    box-shadow: 0 8px 25px rgba(41, 128, 185, 0.3);
    z-index: 9999;
    transition: all 0.3s ease;
    font-family: 'Vazir', sans-serif;
    border: 3px solid white;
    animation: pulse 2s infinite;
}

#chatbot-icon:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 12px 30px rgba(41, 128, 185, 0.4);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 64, 128, 0.6);
    }

    33% {
        box-shadow: 0 0 0 10px rgba(0, 64, 128, 0.4);
    }

    66% {
        box-shadow: 0 0 0 20px rgba(0, 64, 128, 0.2);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 64, 128, 0);
    }
}

/* نوتیفیکیشن */
#chatbot-notification {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #e74c3c;
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-5px);
    }
}

/* باکس چت */
#chatbot-box {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 380px;
    max-height: 600px;
    background: #f8f9fa;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    font-family: 'Vazir', sans-serif;
    overflow: hidden;
    border: 2px solid #003366;
}

#chatbot-header {
    background: #003366 !important;
    color: white;
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
}

#chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: all 0.2s;
}

#chatbot-close:hover {
    transform: scale(1.2);
}

#chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #e6f2ff;
    direction: rtl;
    font-size: 14px;
    line-height: 1.8;
}

.chatbot-message {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.7;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message.user {
    background: white;
    margin-left: auto;
    border-bottom-right-radius: 2px;
    border: 1px solid #003366;
    color: #003366;
    text-align: right;
    direction: ltr;
}

.chatbot-message.bot {
    background: white;
    margin-right: auto;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: right;
    border: 1px solid #003366;
}

.chatbot-message.error {
    background: #ffebee;
    border-left: 3px solid #e53935;
}

/* بخش ورودی */
#chatbot-input-box {
    display: flex;
    padding: 5px;
    background: white;
    border-top: 1px solid 003366;
    position: relative;
}

#chatbot-input {
    flex: 1;
    padding: 5px 5px;
    border: 1px solid #003366;
    outline: none;
    font-family: 'Vazir', sans-serif;
    font-size: 14px;
    transition: all 0.3s;
    direction: rtl;
    ext-align: right;
    background: #e6f2ff;
}

#chatbot-input::placeholder {
     border-color: #003366;
    color: #666;
    opacity: 1;
    /* برای نمایش کامل placeholder */
    font-family: 'Vazir', sans-serif;
}
}

#chatbot-input:focus {
    border-color: #003366;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

#chatbot-send {
    background: #003366;
    color: white;
    border: none;
    padding: 0 20px;
    border-top-left-radius: 25px;
    border-bottom-left-radius: 25px;

    cursor: pointer;
    font-family: 'Vazir', sans-serif;
    font-size: 14px;
    transition: all 0.3s;
}

#chatbot-send:hover {
    background: #003366;
}

/* پیشنهادات */
#chatbot-suggestions {
    position: absolute;
    bottom: 60px;
    right: 15px;
    left: 15px;
    background: white;
    border: 1px solid #003366;
    border-radius: 15px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 10000;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    direction: rtl;
}

#chatbot-suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #e6f2ff;
    border-bottom: 1px solid #003366;
    font-size: 14px;
    font-weight: bold;
    color: #003366;
}

#chatbot-suggestions-close {
    background: none;
    border: none;
    color: #003366;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

#chatbot-suggestions-close:hover {
    color: #e53935;
}

#chatbot-suggestions-list {
    max-height: 160px;
    overflow-y: auto;
}

.suggestion-item {
    display: flex;
    flex-direction: row-reverse;
    /* تغییر جهت نمایش به راست به چپ */
    justify-content: flex-end;
    /* تراز به سمت راست */
    align-items: center;
    padding: 10px 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s;
    font-size: 13px;
    direction: rtl;
    /* جهت متن راست به چپ */
}



.suggestion-item:hover {
    background: #e6f2ff;
    border: 1px solid #003366;
    border-radius: 15px;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-text {
    margin-right: 10px;
    /* فاصله بین آیکون و متن */
    flex-grow: 1;
    /* پر کردن فضای باقیمانده */
}

.suggestion-icon {
    font-size: 14px;
    min-width: 20px;
    /* عرض ثابت برای آیکون */
    text-align: center;
}

/* لینک‌ها */
.chatbot-message a {
    color: #2980b9;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.2s;
}

.chatbot-message a:hover {
    color: #1a5276;
    text-decoration: underline;
}

/* فوتر */
#chatbot-footer {
    background: #e6f2ff;
    color: #003366;
    font-size: 11px;
    text-align: center;
    padding: 5px;
    border-top: 1px solid #003366;
}

/* اسکرول بار */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #e6f2ff;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #003366;
}

/* انیمیشن در حال پردازش */
.typing-indicator {
    display: inline-block;
    position: relative;
    padding: 12px 16px;
    background: white;
    border-radius: 15px;
    border: 1px solid #003366;
    margin-bottom: 15px;
    margin-right: auto;
    max-width: 85%;
    text-align: right;
    color: #003366;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #003366;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

/* منوی نوع جستجو */
#chatbot-search-type {
    position: relative;
    display: inline-block;
}

#chatbot-type-toggle {
    background: #003366;
    /* رنگ مشابه دکمه ارسال */
    color: white;
    border: none;
    padding: 0 15px;
 
    height: 40px;
    border-top-right-radius: 25px;
    border-bottom-right-radius: 25px;

    cursor: pointer;
    font-family: 'Vazir', sans-serif;
    font-size: 14px;
    /* سایز فونت مشابه */
    transition: all 0.3s;
    /* انیمیشن مشابه */
    display: flex;
    align-items: center;
    justify-content: center;
 
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    /* سایه مشابه */
}

#chatbot-type-toggle:hover {
    background: #003366;
    /* رنگ هاور مشابه */
    transform: scale(1.05);
    /* افکت هاور مشابه */
    /* transform: rotate(15deg); حذف شده */
}

#chatbot-type-menu {
    position: absolute;
    top: 50%;
    /* موقعیت عمودی در وسط فرم */
    left: 50%;
    /* موقعیت افقی در وسط فرم */
    transform: translate(-100%, -100%);
    /* تنظیم دقیق مرکز */
    background: white;
    border: 1px solid #003366;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    width: 200px;
    max-height: 360px;
    overflow-y: auto;
    display: none;
    animation: fadeIn 0.2s ease-out;
}

#chatbot-type-menu div {
    padding: 5px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s;
    background: #e6f2ff;
}

#chatbot-type-menu div:hover {
   
    border-radius: 15px;
    border: 1px solid #003366;
}

.search-type-icon {
    margin-left: 8px;
    font-size: 16px;
}

/* استایل‌های مختلف برای انواع جستجو */
#chatbot-input[data-search-type="keyword"]::placeholder {
    color: #e74c3c;
}

#chatbot-input[data-search-type="comments"]::placeholder {
    color: #2ecc71;
}

#chatbot-input[data-search-type="tree"]::placeholder {
    color: #f39c12;
}

#chatbot-input[data-search-type="researcher"]::placeholder {
    color: #9b59b6;
}

#chatbot-input[data-search-type="resume"]::placeholder {
    color: #1abc9c;
}

/* آیکون‌های نوع پیشنهاد */
.suggestion-keyword .suggestion-icon {
    color: #e74c3c;
}

.suggestion-title .suggestion-icon {
    color: #3498db;
}

.suggestion-researcher .suggestion-icon {
    color: #9b59b6;
}

.suggestion-tree .suggestion-icon {
    color: #f39c12;
}

.suggestion-resume .suggestion-icon {
    color: #1abc9c;
}

/* ==================== Mobile Responsive Styles ==================== */
@media only screen and (max-width: 768px) {
    /* Full-screen chatbox on mobile */
    #chatbot-box {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        border-radius: 0 !important;
        border: none !important;
    }

    /* Adjust header for mobile */
    #chatbot-header {
        padding: 15px !important;
        font-size: 18px !important;
    }

    /* Make close button more accessible */
    #chatbot-close {
        font-size: 28px !important;
        padding: 5px !important;
    }

    /* Adjust messages container */
    #chatbot-messages {
        padding: 15px !important;
        font-size: 16px !important;
    }

    /* Make input area more touch-friendly */
    #chatbot-input-box {
        padding: 10px !important;
    }

    #chatbot-input {
        padding: 12px 15px !important;
        font-size: 16px !important;
    }

    #chatbot-send {
        padding: 0 25px !important;
        font-size: 16px !important;
    }

    /* Adjust chat icon for mobile */
    #chatbot-icon {
        width: 60px !important;
        height: 60px !important;
        bottom: 20px !important;
        right: 20px !important;
    }

    /* Disable pulse animation on mobile */
    #chatbot-icon {
        animation: none !important;
    }

    /* Make suggestions more touch-friendly */
    #chatbot-suggestions {
        bottom: 70px !important;
        max-height: 40vh !important;
    }

    .suggestion-item {
        padding: 12px 15px !important;
        font-size: 15px !important;
    }

    /* Disable dragging on mobile */
    #chatbot-icon {
        cursor: pointer !important;
    }

    /* Hide drag-related events on mobile */
    #chatbot-icon.on('mousedown touchstart', function(e) {
        e.preventDefault();
        return false;
    }

    /* Adjust search type menu for mobile */
    #chatbot-type-menu {
        width: 250px !important;
        transform: translate(-50%, -100%) !important;
        left: 50% !important;
        right: auto !important;
    }

    #chatbot-type-menu div {
        padding: 12px 20px !important;
        font-size: 15px !important;
    }

    /* Make typing indicator larger */
    .typing-indicator span {
        width: 10px !important;
        height: 10px !important;
    }

    /* Adjust message bubbles */
    .chatbot-message {
        max-width: 90% !important;
        padding: 15px !important;
        font-size: 15px !important;
    }
}

/* ==================== Very Small Mobile Devices ==================== */
@media only screen and (max-width: 480px) {
    #chatbot-header {
        padding: 12px !important;
        font-size: 16px !important;
    }

    #chatbot-messages {
        padding: 10px !important;
    }

    .chatbot-message {
        padding: 12px !important;
        font-size: 14px !important;
    }

    #chatbot-input {
        padding: 10px 12px !important;
    }

    #chatbot-send {
        padding: 0 20px !important;
    }
}

/* ==================== Mobile Interaction Fixes ==================== */
/* Prevent accidental dragging on mobile */
@media (hover: none) and (pointer: coarse) {
    #chatbot-icon {
        touch-action: manipulation;
        user-select: none;
        -webkit-user-drag: none;
    }
}

/* Improved touch target for chat icon */
#chatbot-icon {
    touch-action: manipulation;
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    #chatbot-icon:hover {
        transform: none !important;
    }
    
    #chatbot-send:hover {
        background: #003366 !important;
    }
    
    .suggestion-item:hover {
        background: transparent !important;
    }
}

/* ==================== Mobile-Specific Adjustments ==================== */
/* Make sure keyboard doesn't cover input on mobile */
@media (max-height: 600px) {
    #chatbot-input-box {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
}

/* Adjust for devices with notches */
@supports(padding: max(0px)) {
    #chatbot-box {
        padding-left: max(15px, env(safe-area-inset-left)) !important;
        padding-right: max(15px, env(safe-area-inset-right)) !important;
    }
}
/* ==================== Mobile Touch Fixes ==================== */
@media only screen and (max-width: 768px) {
    #chatbot-icon {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
    
    #chatbot-icon img {
        pointer-events: none;
    }
    
    /* افزایش ناحیه قابل کلیک */
    #chatbot-icon::after {
        content: '';
        position: absolute;
        top: -15px;
        left: -15px;
        right: -15px;
        bottom: -15px;
    }
}