@extends('layouts.admin')

@section('heading', 'Shops')
@section('subheading', 'All shops registered in the system.')

@section('actions')
  <a href="{{ route('superadmin.shops.create') }}" class="px-4 py-2 rounded-lg text-sm font-medium text-white" style="background:#C2185B;">+ Add shop</a>
@endsection

@section('content')

@if (session('status'))
  <div class="mb-4 text-sm rounded-lg px-4 py-3" style="background:#E1F5EE; color:#0F6E56;">
    {{ session('status') }}
  </div>
@endif

<div class="card p-6">
  <table class="w-full text-sm">
    <thead>
      <tr class="text-left" style="color:#a19a8f;">
        <th class="pb-3 font-medium text-xs">Shop</th>
        <th class="pb-3 font-medium text-xs">Owner</th>
        <th class="pb-3 font-medium text-xs">City</th>
        <th class="pb-3 font-medium text-xs">Phone</th>
        <th class="pb-3 font-medium text-xs">Status</th>
        <th class="pb-3 font-medium text-xs text-right">Actions</th>
      </tr>
    </thead>
    <tbody style="color:#1A1625;">
      @forelse($shops as $shop)
        <tr class="border-t" style="border-color:#f2ece0;">
          <td class="py-3 font-medium">{{ $shop->name }}</td>
          <td class="py-3">{{ $shop->owner_name ?? '—' }}</td>
          <td class="py-3">{{ $shop->city ?? '—' }}</td>
          <td class="py-3">{{ $shop->phone ?? '—' }}</td>
          <td class="py-3">
            @if($shop->is_active)
              <span class="text-xs px-2 py-1 rounded-full" style="background:#E1F5EE; color:#0F6E56;">Active</span>
            @else
              <span class="text-xs px-2 py-1 rounded-full" style="background:#FCEBEB; color:#791F1F;">Inactive</span>
            @endif
          </td>
          <td class="py-3 text-right">
            <a href="{{ route('superadmin.shops.edit', $shop) }}" class="text-xs font-medium" style="color:#5E35B1;">Edit</a>
            <form method="POST" action="{{ route('superadmin.shops.destroy', $shop) }}" class="inline" onsubmit="return confirm('Remove this shop?');">
              @csrf @method('DELETE')
              <button type="submit" class="text-xs font-medium ml-3" style="color:#C2185B;">Delete</button>
            </form>
          </td>
        </tr>
      @empty
        <tr><td colspan="6" class="py-6 text-center text-sm" style="color:#a19a8f;">No shops yet.</td></tr>
      @endforelse
    </tbody>
  </table>

  <div class="mt-4">{{ $shops->links() }}</div>
</div>

@endsection
