<?php $__env->startSection('title', 'Sources'); ?>
<?php $__env->startSection('page-title', 'RSS Sources'); ?>

<?php $__env->startSection('content'); ?>
<form method="GET" class="flex flex-wrap gap-3 mb-6">
  <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search sources…"
    class="bg-gray-800 border border-white/10 rounded-xl px-4 py-2 text-sm text-white w-56 focus:outline-none focus:border-blue-500">
  <select name="category" class="bg-gray-800 border border-white/10 rounded-xl px-4 py-2 text-sm text-gray-300 focus:outline-none">
    <option value="">All Categories</option>
    <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
      <option value="<?php echo e($cat->id); ?>" <?php echo e(request('category') == $cat->id ? 'selected' : ''); ?>><?php echo e($cat->name); ?></option>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
  </select>
  <select name="country" class="bg-gray-800 border border-white/10 rounded-xl px-4 py-2 text-sm text-gray-300 focus:outline-none">
    <option value="">All Countries</option>
    <?php $__currentLoopData = $countries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $country): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
      <option value="<?php echo e($country->id); ?>" <?php echo e(request('country') == $country->id ? 'selected' : ''); ?>>
        <?php echo e($country->flag_emoji); ?> <?php echo e($country->name); ?>

      </option>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
  </select>
  <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white text-sm px-4 py-2 rounded-xl">Filter</button>
  <a href="<?php echo e(route('admin.crawl.logs')); ?>" class="ml-auto text-sm text-gray-400 hover:text-white px-4 py-2 border border-white/10 hover:border-white/30 rounded-xl transition-colors">
    View Crawl Logs →
  </a>
</form>

<div class="bg-gray-900 rounded-2xl border border-white/10 overflow-hidden">
  <table class="w-full text-sm">
    <thead>
      <tr class="border-b border-white/10 text-xs text-gray-500 uppercase tracking-wider">
        <th class="text-left px-5 py-3">Source</th>
        <th class="text-left px-4 py-3 hidden lg:table-cell">Category</th>
        <th class="text-left px-4 py-3 hidden md:table-cell">Country</th>
        <th class="text-left px-4 py-3 hidden lg:table-cell">Articles</th>
        <th class="text-left px-4 py-3 hidden lg:table-cell">Last Crawled</th>
        <th class="text-left px-4 py-3">Status</th>
        <th class="px-4 py-3"></th>
      </tr>
    </thead>
    <tbody class="divide-y divide-white/5">
      <?php $__empty_1 = true; $__currentLoopData = $sources; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $source): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
      <tr class="hover:bg-white/3 transition-colors">
        <td class="px-5 py-3">
          <p class="text-white font-medium"><?php echo e($source->name); ?></p>
          <?php if($source->rss_url): ?>
            <a href="<?php echo e($source->rss_url); ?>" target="_blank" class="text-xs text-gray-600 hover:text-blue-400 truncate block max-w-xs">
              <?php echo e($source->rss_url); ?>

            </a>
          <?php endif; ?>
        </td>
        <td class="px-4 py-3 hidden lg:table-cell">
          <span class="text-xs bg-white/10 px-2 py-1 rounded-full text-gray-300"><?php echo e($source->category?->name); ?></span>
        </td>
        <td class="px-4 py-3 text-gray-400 hidden md:table-cell">
          <?php echo e($source->country?->flag_emoji); ?> <?php echo e($source->country?->name); ?>

        </td>
        <td class="px-4 py-3 text-gray-400 hidden lg:table-cell"><?php echo e(number_format($source->articles_fetched ?? 0)); ?></td>
        <td class="px-4 py-3 text-gray-500 text-xs hidden lg:table-cell">
          <?php echo e($source->last_crawled_at ? \Carbon\Carbon::parse($source->last_crawled_at)->diffForHumans() : 'Never'); ?>

        </td>
        <td class="px-4 py-3">
          <?php $statusColors = ['ok'=>'text-green-400','error'=>'text-red-400','blocked'=>'text-orange-400','empty'=>'text-gray-500']; ?>
          <div class="flex items-center gap-2">
            <span class="w-2 h-2 rounded-full <?php echo e($source->is_active ? 'bg-green-500' : 'bg-gray-600'); ?>"></span>
            <span class="text-xs <?php echo e($statusColors[$source->last_status ?? ''] ?? 'text-gray-500'); ?>">
              <?php echo e($source->last_status ?? 'pending'); ?>

            </span>
          </div>
        </td>
        <td class="px-4 py-3">
          <div class="flex items-center gap-2 justify-end">
            <form method="POST" action="<?php echo e(route('admin.sources.toggle', $source)); ?>" class="inline">
              <?php echo csrf_field(); ?>
              <button type="submit"
                class="text-xs <?php echo e($source->is_active ? 'text-yellow-400' : 'text-green-400'); ?> hover:underline px-2 py-1">
                <?php echo e($source->is_active ? 'Disable' : 'Enable'); ?>

              </button>
            </form>
            <form method="POST" action="<?php echo e(route('admin.sources.destroy', $source)); ?>" class="inline"
                  onsubmit="return confirm('Delete source?')">
              <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
              <button type="submit" class="text-xs text-gray-600 hover:text-red-400 transition-colors px-2 py-1">✕</button>
            </form>
          </div>
        </td>
      </tr>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
      <tr>
        <td colspan="7" class="px-5 py-12 text-center text-gray-500">No sources found.</td>
      </tr>
      <?php endif; ?>
    </tbody>
  </table>
</div>
<div class="mt-4"><?php echo e($sources->links()); ?></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/megablog/backend/resources/views/admin/sources/index.blade.php ENDPATH**/ ?>