<div x-data="{ isOpen: true }" class="relative">
<!-- Button to open modal (if hidden) -->
<button
@click="isOpen = true"
class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 transition-colors duration-200 fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
>
Open Modal
</button>
<!-- Modal -->
<div
x-show="isOpen"
@click.away="isOpen = false"
class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4"
x-cloak
>
<div
class="bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 transform transition-all duration-300"
:class="{ 'scale-100': isOpen, 'scale-95': !isOpen }"
@click.stop
>
<!-- Modal Header -->
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-900 dark:text-gray-100">
<span class="block text-start">Modal Title</span>
</h2>
<button
@click="isOpen = false"
class="text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors duration-200"
>
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- Modal Content -->
<div class="text-gray-700 dark:text-gray-300 mb-6 text-start">
<p>This is a simple modal component built with Tailwind CSS and Alpine.js.</p>
<p>It supports dark mode and RTL direction for accessibility.</p>
</div>
<!-- Modal Footer -->
<div class="flex justify-end space-x-2 rtl:space-x-reverse">
<button
@click="isOpen = false"
class="px-4 py-2 bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 rounded-lg hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors duration-200"
>
Cancel
</button>
<button
@click="isOpen = false"
class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 transition-colors duration-200"
>
Confirm
</button>
</div>
</div>
</div>
</div>