/* AI Chat Styles - ChatGPT Style - تصميم رفيع مثل Sidebar */
.ai-chat-container {
    position: fixed;
    right: 0; /* بجانب الـ sidebar */
    top: 0;
    width: 280px; /* نفس عرض الـ sidebar */
    height: 100vh;
    z-index: 1001; /* أعلى من sidebar (z-index: 1000) */
    display: none; 
    background: #fff;
    border-left: 1px solid #e5e7eb;
    box-shadow: -2px 0 8px rgba(0,0,0,0.05);
    flex-direction: column;
    transform: translateX(0);
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    text-align: right;
}

.ai-chat-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.ai-chat-close-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f9fafb;
    direction: rtl;
    min-height: 0;
}

.ai-chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    position: relative;
}

.ai-chat-input {
    flex: 1;
    min-height: 60px;
    max-height: 120px;
    padding: 10px 45px 10px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: "Cairo", system-ui, sans-serif;
    direction: rtl;
    text-align: right;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    line-height: 1.5;
    background: #f9fafb;
}

.ai-chat-input:focus {
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.ai-chat-input::placeholder {
    color: #9ca3af;
    font-size: 14px;
}

.ai-chat-send-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: absolute;
    left: 18px;
    bottom: 18px;
}

.ai-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ai-chat-send-btn:active {
    transform: scale(0.95);
}

.ai-chat-send-btn svg {
    width: 18px;
    height: 18px;
}

.chat-message {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.message-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.chat-message.bot .message-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.chat-message.user .message-icon {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.message-content {
    background: white;
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 13px;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Results Container - يظهر تحت الـ chat */
.search-box2 {
    margin-top: 0;
    padding-top: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .ai-chat-container {
        position: fixed;
        right: 0;
        top: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        border-radius: 0;
        transform: translateX(100%); /* مخفي افتراضياً */
        transition: transform 0.3s ease;
    }

    .ai-chat-container[style*="flex"] {
        transform: translateX(0); /* يظهر عند الفتح */
    }

    .ai-chat-header {
        padding: 12px;
    }

    .ai-chat-header h3 {
        font-size: 16px;
    }

    .ai-chat-messages {
        padding: 10px;
    }

    .ai-chat-input-wrapper {
        padding: 10px;
    }

    .ai-chat-input {
        font-size: 13px;
        padding: 8px 40px 8px 8px;
        min-height: 50px;
        max-height: 100px;
    }

    .ai-chat-send-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        left: 14px;
        bottom: 14px;
    }

    .ai-chat-send-btn svg {
        width: 16px;
        height: 16px;
    }

    .message-content {
        font-size: 12px;
        padding: 6px 10px;
    }

    .message-icon {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
}
