/* ========================================
   Chatbot Styles - تصميم مطابق للصورة
   SEU Subject Search Bot
======================================== */

/* زر فتح الشات - في اليمين */
.chatbot-toggle {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%) !important;
    border: none !important;
    cursor: pointer !important;
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    z-index: 99999 !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(33, 150, 243, 0.5);
}

.chatbot-toggle i {
    font-size: 26px;
    color: white;
    transition: transform 0.3s ease;
}

.chatbot-toggle.active .fa-robot {
    display: none;
}

.chatbot-toggle .fa-times {
    display: none;
}

.chatbot-toggle.active .fa-times {
    display: block;
}

/* نافذة الشات الرئيسية */
.chatbot-container {
    position: fixed !important;
    bottom: 100px !important;
    right: 25px !important;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 130px);
    background: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998 !important;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-container.show {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* هيدر الشات */
.chatbot-header {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    min-height: 70px;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-direction: row-reverse;
}

.chatbot-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.chatbot-avatar img {
    width: 30px;
    height: 30px;
}

.chatbot-title-area {
    text-align: right;
}

.chatbot-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 3px;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    transition: all 0.3s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* منطقة الرسائل */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f5f7fa;
}

.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(33, 150, 243, 0.3);
    border-radius: 10px;
}

/* فقاعات الرسائل */
.chat-message {
    display: flex;
    gap: 10px;
    animation: message-fade-in 0.3s ease-out;
    align-items: flex-end;
}

@keyframes message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.bot {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.chat-message.user {
    flex-direction: row;
    justify-content: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-message.bot .message-avatar {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
}

.chat-message.user .message-avatar {
    background: #e0e0e0;
    color: #666;
}

.message-wrapper {
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.chat-message.bot .message-wrapper {
    align-items: flex-end;
}

.chat-message.user .message-wrapper {
    align-items: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    position: relative;
}

.chat-message.bot .message-content {
    background: white;
    color: #333;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    border-radius: 18px 18px 18px 4px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 8px;
}

/* الأزرار السريعة */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    justify-content: flex-end;
}

.quick-action-btn {
    background: white;
    border: 1.5px solid #2196F3;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #2196F3;
    font-weight: 500;
    font-family: 'Cairo', 'Tajawal', sans-serif;
}

.quick-action-btn:hover {
    background: #2196F3;
    color: white;
}

/* مؤشر الكتابة */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #2196F3;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

.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-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* منطقة الإدخال */
.chatbot-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    align-items: center;
    position: relative;
}

.chatbot-input {
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 25px;
    padding: 12px 18px;
    font-size: 14px;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    outline: none;
    transition: all 0.3s ease;
    background: #f5f7fa;
    text-align: right;
    direction: rtl;
    color: #000000;
}

.chatbot-input:focus {
    border-color: #2196F3;
    background: white;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    color: #000000;
}

.chatbot-input::placeholder {
    color: #9ca3af;
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    transition: all 0.3s ease;
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.chatbot-send:active {
    transform: scale(0.95);
}

/* تنسيق النص في الرسائل */
.message-content strong {
    font-weight: 600;
}

.message-content a {
    color: #2196F3;
    text-decoration: underline;
}

.chat-message.user .message-content a {
    color: white;
}

/* رسالة الترحيب المميزة */
.welcome-bubble {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 8px;
}

.welcome-bubble .welcome-text {
    font-size: 15px;
    color: #333;
    line-height: 1.7;
    text-align: right;
}

.welcome-bubble .welcome-text .emoji {
    font-size: 18px;
}

/* استجابة للشاشات الصغيرة */
@media (max-width: 480px) {
    .chatbot-container {
        width: calc(100vw - 20px) !important;
        right: 10px !important;
        left: 10px !important;
        bottom: 85px !important;
        height: calc(100vh - 110px) !important;
        max-height: none !important;
        border-radius: 12px !important;
    }
    
    .chatbot-toggle {
        width: 55px !important;
        height: 55px !important;
        bottom: 20px !important;
        right: 15px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .chatbot-toggle i {
        font-size: 22px !important;
        display: block !important;
    }
    
    .chatbot-header {
        padding: 14px 16px;
    }
    
    .chatbot-messages {
        padding: 12px;
    }
    
    .message-content {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .quick-action-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* تأثير pulse للزر */
@keyframes pulse-ring {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 15px rgba(33, 150, 243, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
    }
}

.chatbot-toggle:not(.active) {
    animation: pulse-ring 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}

/* ==================== اقتراحات الكتابة ==================== */
.chatbot-suggestions {
    position: absolute;
    bottom: 100%;
    right: 0;
    left: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 10;
}

.chatbot-suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
    font-size: 13px;
    text-align: right;
}

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

.suggestion-item:hover {
    background: #f5f7fa;
}

.suggestion-item i {
    color: #2196F3;
    margin-left: 8px;
}

/* تحسينات الجوال */
@media (max-width: 768px) {
    .chatbot-container {
        width: calc(100vw - 16px) !important;
        right: 8px !important;
        left: 8px !important;
        bottom: 80px !important;
        height: calc(100vh - 100px) !important;
        max-height: calc(100vh - 100px) !important;
    }
    
    .chatbot-toggle {
        width: 56px !important;
        height: 56px !important;
        bottom: 18px !important;
        right: 14px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .chatbot-header {
        padding: 12px;
    }
    
    .chatbot-avatar {
        width: 38px;
        height: 38px;
    }
    
    .chatbot-title {
        font-size: 14px;
    }
    
    .chatbot-input-area {
        padding: 10px 12px;
    }
    
    .chatbot-input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .chatbot-send {
        width: 40px;
        height: 40px;
    }
    
    .message-wrapper {
        max-width: 85%;
    }
    
    .quick-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .quick-action-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* شاشات صغيرة جداً */
@media (max-width: 380px) {
    .chatbot-container {
        right: 4px !important;
        left: 4px !important;
        width: calc(100vw - 8px) !important;
        bottom: 70px !important;
    }
    
    .chatbot-toggle {
        width: 52px !important;
        height: 52px !important;
        bottom: 14px !important;
        right: 12px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .chatbot-toggle i {
        font-size: 20px !important;
        display: block !important;
    }
    
    .message-content {
        font-size: 12px;
        padding: 8px 12px;
    }
}
