{{define "content"}}
<div class="max-w-2xl mx-auto">
  <div class="mb-8">
    <a href="/dashboard" class="inline-flex items-center text-sm text-gray-500 hover:text-gray-700">
      <svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
      </svg>
      Back to Dashboard
    </a>
    <h1 class="text-2xl font-bold text-gray-900 mt-4">Create New App</h1>
    <p class="text-gray-600 mt-1">Fill in the details to register your app on Mosis.</p>
  </div>

  <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
    <form hx-post="/apps" hx-target="#form-result" hx-swap="outerHTML" class="space-y-6">
      <div>
        <label for="name" class="block text-sm font-medium text-gray-700 mb-1">
          App Name <span class="text-red-500">*</span>
        </label>
        <input type="text" name="name" id="name" required
               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
               placeholder="My Awesome App"
               hx-post="/validate/name"
               hx-trigger="blur"
               hx-target="next .error-text">
        <span class="error-text text-sm text-red-600 mt-1"></span>
      </div>

      <div>
        <label for="package_id" class="block text-sm font-medium text-gray-700 mb-1">
          Package ID <span class="text-red-500">*</span>
        </label>
        <input type="text" name="package_id" id="package_id" required
               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
               placeholder="com.yourname.appname"
               hx-post="/validate/package-id"
               hx-trigger="blur"
               hx-target="next .error-text">
        <span class="error-text text-sm text-red-600 mt-1"></span>
        <p class="text-sm text-gray-500 mt-1">Unique identifier for your app. Cannot be changed later.</p>
      </div>

      <div>
        <label for="description" class="block text-sm font-medium text-gray-700 mb-1">
          Description
        </label>
        <textarea name="description" id="description" rows="4"
                  class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
                  placeholder="Describe what your app does..."></textarea>
        <p class="text-sm text-gray-500 mt-1">Up to 500 characters.</p>
      </div>

      <div>
        <label for="category" class="block text-sm font-medium text-gray-700 mb-1">
          Category
        </label>
        <select name="category" id="category"
                class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
          <option value="">Select a category</option>
          <option value="productivity">Productivity</option>
          <option value="communication">Communication</option>
          <option value="entertainment">Entertainment</option>
          <option value="utilities">Utilities</option>
          <option value="games">Games</option>
          <option value="education">Education</option>
          <option value="health">Health & Fitness</option>
          <option value="finance">Finance</option>
          <option value="other">Other</option>
        </select>
      </div>

      <div id="form-result"></div>

      <div class="flex justify-end space-x-4 pt-4 border-t border-gray-200">
        <a href="/dashboard" class="px-4 py-2 text-gray-700 hover:text-gray-900">
          Cancel
        </a>
        <button type="submit" class="px-6 py-2 bg-indigo-600 text-white font-medium rounded-lg hover:bg-indigo-700 transition-colors">
          Create App
        </button>
      </div>
    </form>
  </div>
</div>
{{end}}
