

<?php $__env->startSection('content'); ?>
<!-- Stats Cards -->
<div class="grid grid-cols-2 lg:grid-cols-5 gap-fluid mb-fluid">
    <a href="<?php echo e(route('licenses.index')); ?>" class="block bg-white dark:bg-gray-900 rounded-fluid p-fluid shadow-sm border border-gray-100 dark:border-gray-700 card-hover transition-all duration-300 hover:border-purple-300">
        <div class="flex items-center justify-between">
            <div>
                <p class="text-fluid-sm text-gray-500 dark:text-gray-400 mb-fluid-sm">Total</p>
                <p class="text-fluid-xl font-bold text-gray-800 dark:text-gray-100"><?php echo e($stats['total']); ?></p>
            </div>
            <div class="w-10 h-10 bg-purple-100 dark:bg-purple-900 rounded-lg flex items-center justify-center">
                <svg class="w-5 h-5 text-purple-600 dark:text-purple-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"></path>
                </svg>
            </div>
        </div>
    </a>

    <a href="<?php echo e(route('licenses.index', ['status' => 'active'])); ?>" class="block bg-white dark:bg-gray-900 rounded-fluid p-fluid shadow-sm border border-gray-100 dark:border-gray-700 card-hover transition-all duration-300 hover:border-green-300">
        <div class="flex items-center justify-between">
            <div>
                <p class="text-fluid-sm text-gray-500 dark:text-gray-400 mb-fluid-sm">Active</p>
                <p class="text-fluid-xl font-bold text-green-600 dark:text-green-400"><?php echo e($stats['active']); ?></p>
            </div>
            <div class="w-10 h-10 bg-green-100 dark:bg-green-900 rounded-lg flex items-center justify-center">
                <svg class="w-5 h-5 text-green-600 dark:text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                </svg>
            </div>
        </div>
    </a>

    <a href="<?php echo e(route('licenses.index', ['status' => 'expired'])); ?>" class="block bg-white dark:bg-gray-900 rounded-fluid p-fluid shadow-sm border border-gray-100 dark:border-gray-700 card-hover transition-all duration-300 hover:border-red-300">
        <div class="flex items-center justify-between">
            <div>
                <p class="text-fluid-sm text-gray-500 dark:text-gray-400 mb-fluid-sm">Expired</p>
                <p class="text-fluid-xl font-bold text-red-600 dark:text-red-400"><?php echo e($stats['expired']); ?></p>
            </div>
            <div class="w-10 h-10 bg-red-100 dark:bg-red-900 rounded-lg flex items-center justify-center">
                <svg class="w-5 h-5 text-red-600 dark:text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                </svg>
            </div>
        </div>
    </a>

    <a href="<?php echo e(route('licenses.index', ['status' => 'suspended'])); ?>" class="block bg-white dark:bg-gray-900 rounded-fluid p-fluid shadow-sm border border-gray-100 dark:border-gray-700 card-hover transition-all duration-300 hover:border-yellow-300">
        <div class="flex items-center justify-between">
            <div>
                <p class="text-fluid-sm text-gray-500 dark:text-gray-400 mb-fluid-sm">Suspended</p>
                <p class="text-fluid-xl font-bold text-yellow-600 dark:text-yellow-400"><?php echo e($stats['suspended']); ?></p>
            </div>
            <div class="w-10 h-10 bg-yellow-100 dark:bg-yellow-900 rounded-lg flex items-center justify-center">
                <svg class="w-5 h-5 text-yellow-600 dark:text-yellow-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
                </svg>
            </div>
        </div>
    </a>

    <a href="<?php echo e(route('licenses.index', ['status' => 'revoked'])); ?>" class="block bg-white dark:bg-gray-900 rounded-fluid p-fluid shadow-sm border border-gray-100 dark:border-gray-700 card-hover transition-all duration-300 hover:border-gray-300">
        <div class="flex items-center justify-between">
            <div>
                <p class="text-fluid-sm text-gray-500 dark:text-gray-400 mb-fluid-sm">Revoked</p>
                <p class="text-fluid-xl font-bold text-gray-600 dark:text-gray-400"><?php echo e($stats['revoked']); ?></p>
            </div>
            <div class="w-10 h-10 bg-gray-100 dark:bg-gray-700 rounded-lg flex items-center justify-center">
                <svg class="w-5 h-5 text-gray-600 dark:text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"></path>
                </svg>
            </div>
        </div>
    </a>
</div>

<!-- Search and Actions -->
<div class="bg-white dark:bg-gray-900 rounded-fluid p-fluid mb-fluid">
    <div class="flex flex-col lg:flex-row gap-fluid justify-between items-start lg:items-center">
        <form method="GET" class="flex flex-col lg:flex-row gap-fluid w-full lg:w-auto">
            <div class="relative">
                <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search..." 
                    class="w-full lg:w-64 pl-9 pr-4 py-2 border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent text-fluid-base">
                <svg class="w-4 h-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
                </svg>
            </div>
            <select name="status" class="px-4 py-2 border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent text-fluid-base">
                <option value="">All Status</option>
                <option value="active" <?php echo e(request('status') == 'active' ? 'selected' : ''); ?>>Active</option>
                <option value="expired" <?php echo e(request('status') == 'expired' ? 'selected' : ''); ?>>Expired</option>
                <option value="suspended" <?php echo e(request('status') == 'suspended' ? 'selected' : ''); ?>>Suspended</option>
                <option value="revoked" <?php echo e(request('status') == 'revoked' ? 'selected' : ''); ?>>Revoked</option>
            </select>
            <button type="submit" class="px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors text-fluid-base">
                Filter
            </button>
        </form>
        <a href="<?php echo e(route('licenses.create')); ?>" class="px-4 py-2 gradient-bg text-white rounded-lg hover:opacity-90 transition-opacity flex items-center gap-2 text-fluid-base">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
            </svg>
            <span>New</span>
        </a>
    </div>
</div>

<!-- Licenses Table -->
<div class="bg-white dark:bg-gray-900 rounded-fluid shadow-sm border border-gray-100 dark:border-gray-700 overflow-hidden">
    <div class="overflow-x-auto">
        <table class="table">
            <thead class="bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600">
                <tr>
                    <th class="px-4 sm:px-6 py-3 text-left text-fluid-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">License Key</th>
                    <th class="px-4 sm:px-6 py-3 text-left text-fluid-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider hidden md:table-cell">Name</th>
                    <th class="px-4 sm:px-6 py-3 text-left text-fluid-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider hidden lg:table-cell">Status</th>
                    <th class="px-4 sm:px-6 py-3 text-left text-fluid-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider hidden sm:table-cell">Devices</th>
                    <th class="px-4 sm:px-6 py-3 text-left text-fluid-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider hidden md:table-cell">Expires</th>
                    <th class="px-4 sm:px-6 py-3 text-left text-fluid-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Actions</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-gray-100 dark:divide-gray-700">
                <?php $__empty_1 = true; $__currentLoopData = $licenses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $license): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr class="hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors">
                    <td class="px-4 sm:px-6 py-4">
                        <div class="flex items-center">
                            <code class="text-fluid-sm font-mono text-purple-600 dark:text-purple-400 bg-purple-50 dark:bg-purple-900 px-2 py-1 rounded"><?php echo e($license->key); ?></code>
                        </div>
                    </td>
                    <td class="px-4 sm:px-6 py-4 hidden md:table-cell">
                        <div class="text-fluid-sm text-gray-900 dark:text-gray-100"><?php echo e($license->name ?? '-'); ?></div>
                        <div class="text-fluid-xs text-gray-500 dark:text-gray-400"><?php echo e($license->email ?? ''); ?></div>
                    </td>
                    <td class="px-4 sm:px-6 py-4 hidden lg:table-cell">
                        <?php
                            $statusColors = [
                                'active' => 'bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300',
                                'expired' => 'bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300',
                                'suspended' => 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300',
                                'revoked' => 'bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300',
                            ];
                        ?>
                        <span class="px-2 py-1 text-fluid-xs font-medium rounded-full <?php echo e($statusColors[$license->status] ?? 'bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300'); ?>">
                            <?php echo e(ucfirst($license->status)); ?>

                        </span>
                    </td>
                    <td class="px-4 sm:px-6 py-4 hidden sm:table-cell">
                        <div class="text-fluid-sm text-gray-900 dark:text-gray-100">
                            <span class="<?php echo e($license->current_devices >= $license->max_devices ? 'text-red-600 dark:text-red-400' : 'text-green-600 dark:text-green-400'); ?>">
                                <?php echo e($license->current_devices); ?>

                            </span>
                            <span class="text-gray-400">/ <?php echo e($license->max_devices); ?></span>
                        </div>
                    </td>
                    <td class="px-4 sm:px-6 py-4 hidden md:table-cell">
                        <div class="text-fluid-sm text-gray-600 dark:text-gray-400">
                            <?php if($license->expires_at): ?>
                                <?php echo e($license->expires_at->format('M d, Y')); ?>

                                <?php if($license->isExpired()): ?>
                                    <span class="text-red-500 dark:text-red-400 text-fluid-xs block">Expired</span>
                                <?php elseif($license->expires_at->diffInDays() < 7): ?>
                                    <span class="text-yellow-500 dark:text-yellow-400 text-fluid-xs block">Expiring soon</span>
                                <?php endif; ?>
                            <?php else: ?>
                                <span class="text-gray-400">Never</span>
                            <?php endif; ?>
                        </div>
                    </td>
                    <td class="px-4 sm:px-6 py-4">
                        <div class="flex items-center gap-2">
                            <a href="<?php echo e(route('licenses.show', $license->id)); ?>" class="p-2 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors" title="View">
                                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
                                </svg>
                            </a>
                            <a href="<?php echo e(route('licenses.edit', $license->id)); ?>" class="p-2 text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors" title="Edit">
                                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
                                </svg>
                            </a>
                            <button type="button" class="p-2 text-gray-400 hover:text-red-600 dark:hover:text-red-400 transition-colors delete-btn" 
                                    title="Delete" 
                                    data-license-id="<?php echo e($license->id); ?>"
                                    data-license-key="<?php echo e($license->key); ?>"
                                    data-license-name="<?php echo e($license->name ?? 'N/A'); ?>"
                                    data-license-email="<?php echo e($license->email ?? 'N/A'); ?>">
                                    <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
                                    </svg>
                                </button>
                        </div>
                    </td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="6" class="px-4 sm:px-6 py-12 text-center text-gray-500 dark:text-gray-400">
                        <svg class="w-12 h-12 mx-auto text-gray-300 dark:text-gray-600 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"></path>
                        </svg>
                        <p>No licenses found</p>
                    </td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
    
    <!-- Pagination -->
    <div class="px-4 sm:px-6 py-4 border-t border-gray-100 dark:border-gray-700">
        <?php echo e($licenses->links()); ?>

    </div>
</div>

<!-- Delete Confirmation Modal -->
<div id="deleteModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
    <div class="bg-white dark:bg-gray-800 rounded-fluid shadow-xl max-w-md w-full p-fluid border border-transparent dark:border-gray-700 transform transition-all duration-300 scale-100" id="deleteModalContent">
        <div class="flex items-center justify-center mb-4">
            <div class="w-12 h-12 bg-red-100 dark:bg-red-900 rounded-full flex items-center justify-center">
                <svg class="w-6 h-6 text-red-600 dark:text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
                </svg>
            </div>
        </div>
        <h3 class="text-fluid-lg font-semibold text-gray-800 dark:text-gray-100 text-center mb-2">Delete License</h3>
        <p class="text-fluid-sm text-gray-600 dark:text-gray-400 text-center mb-6">Are you sure you want to delete this license? This action cannot be undone.</p>
        
        <div class="bg-gray-50 dark:bg-gray-700 rounded-lg p-4 mb-6">
            <div class="grid grid-cols-2 gap-2 text-fluid-sm">
                <div class="text-gray-500 dark:text-gray-400">License Key:</div>
                <div class="text-gray-800 dark:text-gray-200 font-mono" id="deleteLicenseKey">-</div>
                <div class="text-gray-500 dark:text-gray-400">Name:</div>
                <div class="text-gray-800 dark:text-gray-200" id="deleteLicenseName">-</div>
                <div class="text-gray-500 dark:text-gray-400">Email:</div>
                <div class="text-gray-800 dark:text-gray-200" id="deleteLicenseEmail">-</div>
            </div>
        </div>
        
        <form id="deleteForm" method="POST" class="flex justify-end gap-fluid-sm">
            <?php echo csrf_field(); ?>
            <?php echo method_field('DELETE'); ?>
            <button type="button" onclick="closeDeleteModal()"
                class="px-4 py-2 border border-gray-200 dark:border-gray-600 text-gray-600 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-fluid-base transition-colors">
                Cancel
            </button>
            <button type="submit" class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 text-fluid-base transition-colors flex items-center gap-2">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
                </svg>
                Delete
            </button>
        </form>
    </div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    const deleteModal = document.getElementById('deleteModal');
    const deleteModalContent = document.getElementById('deleteModalContent');
    const deleteForm = document.getElementById('deleteForm');
    const deleteLicenseKey = document.getElementById('deleteLicenseKey');
    const deleteLicenseName = document.getElementById('deleteLicenseName');
    const deleteLicenseEmail = document.getElementById('deleteLicenseEmail');
    
    // Add click handlers to all delete buttons
    document.querySelectorAll('.delete-btn').forEach(function(btn) {
        btn.addEventListener('click', function() {
            const licenseId = this.getAttribute('data-license-id');
            const licenseKey = this.getAttribute('data-license-key');
            const licenseName = this.getAttribute('data-license-name');
            const licenseEmail = this.getAttribute('data-license-email');
            
            // Update modal content
            deleteLicenseKey.textContent = licenseKey;
            deleteLicenseName.textContent = licenseName;
            deleteLicenseEmail.textContent = licenseEmail;
            
            // Set form action
            deleteForm.action = '/licenses/' + licenseId;
            
            // Show modal with animation
            deleteModal.classList.remove('hidden');
            deleteModalContent.classList.add('scale-100');
            deleteModalContent.classList.remove('scale-95', 'opacity-0');
        });
    });
    
    // Close modal when clicking outside
    deleteModal.addEventListener('click', function(e) {
        if (e.target === deleteModal) {
            closeDeleteModal();
        }
    });
    
    // Close modal on escape key
    document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape' && !deleteModal.classList.contains('hidden')) {
            closeDeleteModal();
        }
    });
});

function closeDeleteModal() {
    const deleteModal = document.getElementById('deleteModal');
    const deleteModalContent = document.getElementById('deleteModalContent');
    
    // Add fade out animation
    deleteModalContent.classList.add('scale-95', 'opacity-0');
    deleteModalContent.classList.remove('scale-100');
    
    // Hide modal after animation
    setTimeout(function() {
        deleteModal.classList.add('hidden');
    }, 300);
}
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\license-panel\resources\views/licenses/index.blade.php ENDPATH**/ ?>