/* دکمه toggle چت */
.chat-toggle {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    z-index: 1001;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: pulse 2s infinite;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
}

@keyframes pulse {
    0% { box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4); }
    50% { box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4), 0 0 0 10px rgba(102, 126, 234, 0.1); }
    100% { box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4); }
}

/* چت باکس اصلی */
.chat-box {
    position: fixed;
    bottom: 100px;
    left: 25px;
    width: 380px;
    max-height: 550px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    direction: rtl;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    visibility: hidden;
}

/* هدر چت */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status.online::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.header-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* منطقه پیام‌ها */
.chat-messages {
    height: 350px;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    font-size: 14px;
    line-height: 1.6;
    scroll-behavior: smooth;
}

/* پیام خوش‌آمدگویی */
.welcome-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeInUp 0.6s ease-out;
}

.bot-avatar {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-content {
    background: #ffffff;
    border-radius: 18px 18px 18px 4px;
    padding: 15px 18px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    max-width: 85%;
}

.message-content p {
    margin: 0 0 8px 0;
    color: #374151;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* پیام‌های کاربر */
.user-message {
    display: flex;
    justify-content: flex-start;
    margin: 15px 0;
    animation: fadeInRight 0.4s ease-out;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 18px;
    max-width: 75%;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    word-wrap: break-word;
}

/* پیام‌های ربات */
.bot-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 15px 0;
    animation: fadeInLeft 0.4s ease-out;
}

.bot-message .message-bubble {
    background: #ffffff;
    color: #374151;
    border-radius: 18px 18px 18px 4px;
    padding: 12px 18px;
    max-width: 75%;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
}

/* پیام‌های خطا */
.error-message {
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.error-message .message-bubble {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border-radius: 18px;
    padding: 12px 18px;
    max-width: 85%;
    text-align: center;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

/* نشانگر بارگذاری */
.loading-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 15px 0;
}

.loading-message .message-bubble {
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 18px 18px 18px 4px;
    padding: 15px 18px;
    font-style: italic;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* منطقه ورودی */
.chat-input-container {
    padding: 20px;
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #f8fafc;
    border-radius: 25px;
    padding: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#chat-input-text {
    flex: 1;
    min-height: 20px;
    max-height: 100px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    color: #374151;
    line-height: 1.5;
}

#chat-input-text::placeholder {
    color: #9ca3af;
}

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* نشانگر تایپ */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    margin-top: 8px;
    font-size: 13px;
    color: #6b7280;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.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.3; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* اسکرول بار سفارشی */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: background 0.3s;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* انیمیشن‌های responsive */
@media (max-width: 480px) {
    .chat-box {
        width: calc(100vw - 40px);
        left: 20px;
        right: 20px;
        bottom: 90px;
    }
    
    .chat-toggle {
        left: 20px;
        bottom: 20px;
    }
    
    .chat-messages {
        height: 300px;
    }
}

/* حالت تاریک */
@media (prefers-color-scheme: dark) {
    .chat-box {
        background: #1f2937;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .chat-messages {
        background: linear-gradient(180deg, #111827 0%, #1f2937 100%);
    }
    
    .message-content {
        background: #374151;
        color: #f9fafb;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .bot-message .message-bubble {
        background: #374151;
        color: #f9fafb;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .input-wrapper {
        background: #374151;
    }
    
    #chat-input-text {
        color: #f9fafb;
    }
    
    #chat-input-text::placeholder {
        color: #9ca3af;
    }
}