/* استایل اصلی ویجت چت */
.wp-ai-ca-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
}

/* دکمه شناور چت */
.wp-ai-ca-chat-button {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
}

.wp-ai-ca-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.6);
}

.wp-ai-ca-chat-icon {
    color: white;
    width: 24px;
    height: 24px;
}

/* انیمیشن پالس */
.wp-ai-ca-pulse-animation {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid #10b981;
    border-radius: 50%;
    animation: wp-ai-ca-pulse 2s infinite;
}

@keyframes wp-ai-ca-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* کانتینر چت */
.wp-ai-ca-chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: wp-ai-ca-slide-up 0.3s ease;
}

@keyframes wp-ai-ca-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wp-ai-ca-chat-container.active {
    display: flex;
}

/* هدر چت */
.wp-ai-ca-chat-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wp-ai-ca-chat-title h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.wp-ai-ca-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
}

.wp-ai-ca-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #34d399;
    border-radius: 50%;
    margin-left: 6px;
}

.wp-ai-ca-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.wp-ai-ca-close-btn:hover {
    opacity: 1;
}

/* بخش پیام‌ها */
.wp-ai-ca-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
}

.wp-ai-ca-message {
    display: flex;
    margin-bottom: 16px;
    animation: wp-ai-ca-message-appear 0.3s ease;
}

@keyframes wp-ai-ca-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wp-ai-ca-message.user-message {
    flex-direction: row-reverse;
}

.wp-ai-ca-message-avatar {
    flex-shrink: 0;
    margin: 0 8px;
}

.wp-ai-ca-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.user-message .wp-ai-ca-avatar {
    background: #10b981;
}

.ai-message .wp-ai-ca-avatar {
    background: #6b7280;
}

.wp-ai-ca-message-content {
    max-width: 70%;
}

.user-message .wp-ai-ca-message-content {
    text-align: left;
}

.ai-message .wp-ai-ca-message-content {
    text-align: right;
}

.wp-ai-ca-message-content p {
    margin: 0;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 14px;
}

.user-message .wp-ai-ca-message-content p {
    background: #10b981;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message .wp-ai-ca-message-content p {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

/* بخش ورودی پیام */
.wp-ai-ca-chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.wp-ai-ca-typing-indicator {
    text-align: center;
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 8px;
}

.wp-ai-ca-input-wrapper {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 4px;
}

.wp-ai-ca-chat-input {
    flex: 1;
    border: none;
    background: none;
    padding: 12px 16px;
    outline: none;
    font-size: 14px;
}

.wp-ai-ca-send-btn {
    background: #10b981;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.wp-ai-ca-send-btn:hover {
    background: #059669;
}

.wp-ai-ca-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* استایل برای موبایل */
@media (max-width: 768px) {
    .wp-ai-ca-chat-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .wp-ai-ca-chat-container {
        width: calc(100vw - 40px);
        height: 70vh;
        right: 0;
        bottom: 80px;
    }
}

/* اسکرول بار سفارشی */
.wp-ai-ca-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.wp-ai-ca-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.wp-ai-ca-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.wp-ai-ca-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}


/* اضافه کردن به انتهای فایل chat-widget.css */

/* هشدار محدودیت درخواست */
.wp-ai-ca-rate-limit-warning {
    background: #fef3cd;
    border: 1px solid #fde047;
    border-radius: 8px;
    padding: 10px 15px;
    margin: 10px 0;
    text-align: center;
}

.wp-ai-ca-rate-limit-warning p {
    margin: 0;
    color: #92400e;
    font-size: 12px;
    font-weight: 500;
}

/* نمایش محدودیت در هدر */
.wp-ai-ca-rate-limit {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 5px;
}

/* انیمیشن برای پیام‌های جدید */
.wp-ai-ca-message {
    animation: wp-ai-ca-message-appear 0.3s ease;
}

@keyframes wp-ai-ca-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* وضعیت اتصال */
.wp-ai-ca-connection-status {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    margin-right: 10px;
}

.wp-ai-ca-connection-status.connected::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    margin-left: 5px;
}

.wp-ai-ca-connection-status.disconnected::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
    margin-left: 5px;
}

/* نمایش محصولات در چت */
.wp-ai-ca-product-suggestion {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    margin: 8px 0;
    gap: 12px;
}

.wp-ai-ca-product-suggestion img {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    object-fit: cover;
}

.wp-ai-ca-product-info {
    flex: 1;
}

.wp-ai-ca-product-info h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 600;
}

.wp-ai-ca-product-price {
    color: #10b981;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 5px;
}

.wp-ai-ca-product-link {
    background: #10b981;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    transition: background 0.2s;
}

.wp-ai-ca-product-link:hover {
    background: #059669;
    color: white;
}

/* اسکرول بار سفارشی بهبود یافته */
.wp-ai-ca-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.wp-ai-ca-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.wp-ai-ca-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.wp-ai-ca-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* رسپانسیو بهبود یافته */
@media (max-width: 480px) {
    .wp-ai-ca-chat-container {
        width: calc(100vw - 20px);
        height: 80vh;
        right: 10px;
        bottom: 70px;
    }
    
    .wp-ai-ca-product-suggestion {
        flex-direction: column;
        text-align: center;
    }
    
    .wp-ai-ca-product-suggestion img {
        width: 80px;
        height: 80px;
    }
}
