/* دکمه استیکی چت */
.chat-bot-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chat-bot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
}

.chat-bot-toggle:active {
    transform: scale(0.95);
}

.chat-bot-toggle .chat-icon,
.chat-bot-toggle .close-icon {
    width: 28px;
    height: 28px;
    color: #ffffff;
    transition: all 0.3s ease;
    position: absolute;
}

.chat-bot-toggle .close-icon {
    opacity: 0;
    transform: rotate(90deg);
}

.chat-bot-toggle.active .chat-icon {
    opacity: 0;
    transform: rotate(-90deg);
}

.chat-bot-toggle.active .close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* پنل چت */
.chat-bot-container {
    position: fixed;
    bottom: 100px;
    left: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chat-bot-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* هدر چت */
.chat-bot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    color: #ffffff;
    border-radius: 20px 20px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-bot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-bot-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-bot-avatar svg {
    width: 28px;
    height: 28px;
    color: #ffffff;
}

.chat-bot-header-info {
    flex: 1;
}

.chat-bot-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.chat-bot-status {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.chat-bot-reset-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #ffffff;
    flex-shrink: 0;
}

.chat-bot-reset-btn svg {
    width: 18px;
    height: 18px;
}

.chat-bot-reset-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.6);
}

.chat-bot-reset-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ناحیه پیام‌ها */
.chat-bot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-bot-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-bot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-bot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-bot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* پیام */
.message {
    margin-bottom: 20px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* فوتر پیام */
.message-footer {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    direction: rtl;
}

.message-footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
    /* flex: 1; */
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar svg {
    width: 18px;
    height: 18px;
    color: #ffffff;
}

.message-sender {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.message-time-header {
    font-size: 11px;
    color: #6b7280;
    margin-right: 4px;
}

.message-content {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.message-text {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    direction: rtl;
    text-align: right;
    max-width: 85%;
    width: fit-content;
}

/* پیام کاربر */
.user-message {
    align-items: flex-start;
}

.user-message .message-content {
    align-items: flex-start;
}

.user-message .message-footer {
    /* flex-direction: row-reverse;
    align-self: flex-start; */
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.user-message .message-text {
    background: #1f2937;
    color: #ffffff;
    text-align: right;
    margin-right: 0;
    margin-left: auto;
}

.user-message .message-sender {
    color: #374151;
}

/* پیام ربات */
.bot-message {
    align-items: flex-end;
}

.bot-message .message-content {
    align-items: flex-end;
}

.bot-message .message-footer {
    align-self: flex-end;
    justify-content: flex-end;
}

.bot-message .message-footer-left {
    justify-content: flex-start;
    flex-direction: row-reverse;
}

.bot-message .message-text {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    margin-right: auto;
    margin-left: 0;
}

.bot-message .message-sender {
    color: #374151;
}

/* دکمه‌های عملیات پیام */
.message-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.user-message .message-actions {
    display: none;
}


.user-message .message-footer {
    justify-content: flex-start;
}

.message-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: #f3f4f6;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.message-action-btn:hover {
    background: #e5e7eb;
    transform: scale(1.1);
}

.message-action-btn svg {
    width: 14px;
    height: 14px;
    color: #6b7280;
}

.message-action-btn:hover svg {
    color: #374151;
}

/* سوالات سریع */
.chat-bot-quick-questions {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    overflow-x: auto;
    overflow-y: hidden;
}

.chat-bot-quick-questions::-webkit-scrollbar {
    height: 4px;
}

.chat-bot-quick-questions::-webkit-scrollbar-track {
    background: transparent;
}

.chat-bot-quick-questions::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.quick-questions-scroll {
    display: flex;
    gap: 8px;
    direction: rtl;
    white-space: nowrap;
}

.quick-question-btn {
    padding: 8px 16px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.quick-question-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    transform: translateY(-1px);
}

.quick-question-btn:active {
    transform: translateY(0);
}

/* ناحیه ورودی */
.chat-bot-input-container {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.chat-bot-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    border-radius: 24px;
    padding: 4px;
}
#chatBotInput{
    overflow: unset;
    padding: unset;
    min-height: unset;
    resize: unset;
}
.chat-bot-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 14px;
    color: #1f2937;
    outline: none;
    font-family: inherit;
    direction: rtl;
    text-align: right;
    resize: none;
    overflow: hidden;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
}

.chat-bot-input::placeholder {
    color: #9ca3af;
}

.chat-bot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-bot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-bot-send:active {
    transform: scale(0.95);
}

.chat-bot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-bot-send svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

/* تایپینگ ایندیکیتور */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ریسپانسیو */
@media (max-width: 768px) {
    .chat-bot-toggle {
        width: 56px;
        height: 56px;
        bottom: 20px;
        left: 20px;
    }

    .chat-bot-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
        bottom: 90px;
        left: 20px;
        border-radius: 16px;
    }

    .chat-bot-header {
        border-radius: 16px 16px 0 0;
        padding: 16px;
    }

    .chat-bot-messages {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .chat-bot-toggle {
        width: 52px;
        height: 52px;
        bottom: 16px;
        left: 16px;
    }

    .chat-bot-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: 80px;
        left: 16px;
        border-radius: 12px;
    }

    .chat-bot-title {
        font-size: 16px;
    }

    .message-text {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* پشتیبانی از حالت LTR (چپ به راست) */
html[dir="ltr"] .chat-bot-toggle {
    left: auto;
    right: 24px;
}

html[dir="ltr"] .chat-bot-container {
    left: auto;
    right: 24px;
}

html[dir="ltr"] .chat-bot-input {
    direction: ltr;
    text-align: left;
}

html[dir="ltr"] .message-text {
    direction: ltr;
    text-align: left;
}

html[dir="ltr"] .message-time {
    direction: ltr;
    text-align: right;
}

html[dir="ltr"] .user-message .message-time {
    text-align: left;
}

html[dir="ltr"] .user-message {
    flex-direction: row;
}

html[dir="ltr"] .bot-message .message-text {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}

html[dir="ltr"] .user-message .message-text {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

@media (max-width: 768px) {
    html[dir="ltr"] .chat-bot-toggle {
        left: auto;
        right: 20px;
    }

    html[dir="ltr"] .chat-bot-container {
        left: auto;
        right: 20px;
    }
}

@media (max-width: 480px) {
    html[dir="ltr"] .chat-bot-toggle {
        left: auto;
        right: 16px;
    }

    html[dir="ltr"] .chat-bot-container {
        left: auto;
        right: 16px;
    }
}

/* انیمیشن ورود */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: fadeInUp 0.3s ease;
}

/* Toast Message */
.toast-message {
    position: fixed;
    bottom: 100px;
    right: 50%;
    transform: translateX(50%) translateY(20px);
    background: #1f2937;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-message.show {
    opacity: 1;
    transform: translateX(50%) translateY(0);
}

.message-text h1,.message-text h2,.message-text h3 ,.message-text h4,.message-text h5,.message-text h6{
    font-size: 14px;
}
.message-text h1,.message-text h2,.message-text h3 ,.message-text h4,.message-text h5,.message-text h6,.message-text p,.message-text li p , .message-text li{
    margin-bottom: 0px;
}
.chat-bot-body .scrollToTop.button-show {
    right: 12px !important;
}
@media (max-width: 1025px){
    body:has(.wd-toolbar) div.chat-bot-toggle{
        bottom: 60px !important;
    }
}