/**
 * AI Chat Widget Styles
 * تنسيق شات المعلم الذكي
 */

/* الأيقونة العائمة */
.ai-float-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
    border: none;
}

.ai-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.6);
}

.ai-float-btn i {
    font-size: 24px;
    color: white;
}

.ai-float-btn .pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* نافذة الشات */
.ai-chat-widget {
    position: fixed;
    bottom: 100px;
    left: 24px;
    width: 380px;
    max-height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
}

.ai-chat-widget.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* الهيدر */
.ai-chat-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chat-header h5 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-header .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    opacity: 0.8;
}

.ai-chat-header .close-btn:hover {
    opacity: 1;
}

/* منطقة الرسائل */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ai-message.user {
    flex-direction: row-reverse;
}

.ai-message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-message.bot .avatar {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.ai-message.user .avatar {
    background: #e5e7eb;
    color: #6b7280;
}

.ai-message .bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.ai-message.bot .bubble {
    background: #f3f4f6;
    color: #374151;
    border-bottom-left-radius: 4px;
}

.ai-message.user .bubble {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* أزرار الإجراءات */
.ai-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    padding-right: 40px;
}

.ai-message-actions button {
    background: none;
    border: 1px solid #e5e7eb;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
}

.ai-message-actions button:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* منطقة الإدخال */
.ai-chat-input {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
}

.ai-chat-input textarea {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    max-height: 80px;
    font-family: inherit;
}

.ai-chat-input textarea:focus {
    outline: none;
    border-color: #6366f1;
}

.ai-chat-input .send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-chat-input .send-btn:hover {
    transform: scale(1.05);
}

.ai-chat-input .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* عداد الأحرف */
.ai-char-counter {
    font-size: 11px;
    color: #9ca3af;
    text-align: left;
    padding: 0 16px 8px;
}

.ai-char-counter.warning {
    color: #f59e0b;
}

.ai-char-counter.error {
    color: #ef4444;
}

/* حالة التحميل */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.ai-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ai-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* الحصة المتبقية */
.ai-quota-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* رسالة التسجيل للزوار */
.ai-guest-message {
    text-align: center;
    padding: 40px 20px;
}

.ai-guest-message i {
    font-size: 48px;
    color: #6366f1;
    margin-bottom: 16px;
}

.ai-guest-message h5 {
    margin-bottom: 8px;
    color: #374151;
}

.ai-guest-message p {
    color: #6b7280;
    margin-bottom: 16px;
}

.ai-guest-message .btn-register {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

/* Responsive */
@media (max-width: 480px) {
    .ai-chat-widget {
        width: calc(100vw - 32px);
        left: 16px;
        bottom: 90px;
    }

    .ai-float-btn {
        left: 16px;
        bottom: 16px;
        width: 52px;
        height: 52px;
    }
}

/* زر رفع الصورة */
.ai-chat-input .image-btn {
    width: 44px;
    height: 44px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-chat-input .image-btn:hover {
    background: #e5e7eb;
    color: #6366f1;
}

.ai-chat-input .image-btn.has-image {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #10b981;
    color: white;
}

/* معاينة الصورة */
.ai-image-preview {
    position: relative;
    margin: 8px 16px;
    padding: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.ai-image-preview img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.ai-image-preview .remove-image-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: transform 0.2s;
}

.ai-image-preview .remove-image-btn:hover {
    transform: scale(1.1);
}

/* صورة في الفقاعة */
.ai-message .bubble img.user-image {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: block;
}