<template>
  <div>
    <!-- Page Header -->
    <div class="mb-8">
      <h1 class="text-2xl font-bold text-white">Jogosultság Kezelés</h1>
      <p class="text-slate-400 mt-1">Permissions Management — Role-based access control matrix</p>
    </div>

    <!-- Info Banner -->
    <div class="bg-indigo-500/10 border border-indigo-500/20 rounded-xl p-4 mb-8 flex items-start gap-3">
      <svg class="w-5 h-5 text-indigo-400 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
      </svg>
      <p class="text-sm text-indigo-300">
        This is the permissions management interface. The 3D Capability Matrix UI (Superadmin, Garages, and Packages toggles) will be implemented here in the next iteration.
      </p>
    </div>

    <!-- Permission Groups Grid -->
    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
      <!-- Superadmin Permissions -->
      <div class="bg-slate-800 rounded-xl border border-slate-700 p-6">
        <div class="flex items-center gap-3 mb-4">
          <div class="p-2 rounded-lg bg-purple-500/10 text-purple-400">
            <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="M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z" />
            </svg>
          </div>
          <h2 class="text-lg font-semibold text-white">Superadmin</h2>
        </div>
        <p class="text-sm text-slate-400 mb-4">Full system access — user management, billing, robots, and system configuration.</p>
        <div class="space-y-3">
          <div v-for="perm in superadminPerms" :key="perm.key" class="flex items-center justify-between py-2 border-b border-slate-700/50 last:border-0">
            <span class="text-sm text-slate-300">{{ perm.label }}</span>
            <span class="text-xs px-2 py-0.5 rounded-full" :class="perm.enabled ? 'bg-emerald-400/10 text-emerald-400' : 'bg-slate-700 text-slate-500'">
              {{ perm.enabled ? 'Enabled' : 'Disabled' }}
            </span>
          </div>
        </div>
        <div class="mt-4 pt-4 border-t border-slate-700">
          <button class="w-full px-4 py-2 text-sm bg-purple-600 hover:bg-purple-500 text-white rounded-lg transition">
            Configure Superadmin
          </button>
        </div>
      </div>

      <!-- Garage Permissions -->
      <div class="bg-slate-800 rounded-xl border border-slate-700 p-6">
        <div class="flex items-center gap-3 mb-4">
          <div class="p-2 rounded-lg bg-cyan-500/10 text-cyan-400">
            <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="M8.25 18.75a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m3 0h6m-9 0H3.375a1.125 1.125 0 01-1.125-1.125V14.25m17.25 4.5a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m3 0h1.125c.621 0 1.129-.504 1.09-1.124a17.902 17.902 0 00-3.213-9.193 2.056 2.056 0 00-1.58-.86H14.25M16.5 18.75h-2.25m0-11.177v-.958c0-.568-.422-1.048-.987-1.106a48.554 48.554 0 00-10.026 0 1.106 1.106 0 00-.987 1.106v7.635m12-6.677v6.677m0 4.5v-4.5m0 0h-12" />
            </svg>
          </div>
          <h2 class="text-lg font-semibold text-white">Garages</h2>
        </div>
        <p class="text-sm text-slate-400 mb-4">Garage-level access — vehicle management, service booking, customer data.</p>
        <div class="space-y-3">
          <div v-for="perm in garagePerms" :key="perm.key" class="flex items-center justify-between py-2 border-b border-slate-700/50 last:border-0">
            <span class="text-sm text-slate-300">{{ perm.label }}</span>
            <span class="text-xs px-2 py-0.5 rounded-full" :class="perm.enabled ? 'bg-emerald-400/10 text-emerald-400' : 'bg-slate-700 text-slate-500'">
              {{ perm.enabled ? 'Enabled' : 'Disabled' }}
            </span>
          </div>
        </div>
        <div class="mt-4 pt-4 border-t border-slate-700">
          <button class="w-full px-4 py-2 text-sm bg-cyan-600 hover:bg-cyan-500 text-white rounded-lg transition">
            Configure Garages
          </button>
        </div>
      </div>

      <!-- Package Permissions -->
      <div class="bg-slate-800 rounded-xl border border-slate-700 p-6">
        <div class="flex items-center gap-3 mb-4">
          <div class="p-2 rounded-lg bg-amber-500/10 text-amber-400">
            <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="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5m8.25 3v6.75m0 0l-3-3m3 3l3-3M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z" />
            </svg>
          </div>
          <h2 class="text-lg font-semibold text-white">Packages</h2>
        </div>
        <p class="text-sm text-slate-400 mb-4">Subscription package permissions — feature toggles per plan tier.</p>
        <div class="space-y-3">
          <div v-for="perm in packagePerms" :key="perm.key" class="flex items-center justify-between py-2 border-b border-slate-700/50 last:border-0">
            <span class="text-sm text-slate-300">{{ perm.label }}</span>
            <span class="text-xs px-2 py-0.5 rounded-full" :class="perm.enabled ? 'bg-emerald-400/10 text-emerald-400' : 'bg-slate-700 text-slate-500'">
              {{ perm.enabled ? 'Enabled' : 'Disabled' }}
            </span>
          </div>
        </div>
        <div class="mt-4 pt-4 border-t border-slate-700">
          <button class="w-full px-4 py-2 text-sm bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition">
            Configure Packages
          </button>
        </div>
      </div>
    </div>

    <!-- Placeholder for 3D Capability Matrix -->
    <div class="bg-slate-800/50 border-2 border-dashed border-slate-600 rounded-xl p-12 text-center">
      <svg class="w-12 h-12 mx-auto text-slate-600 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25" />
      </svg>
      <h3 class="text-lg font-semibold text-slate-400 mb-2">3D Capability Matrix</h3>
      <p class="text-sm text-slate-500 max-w-md mx-auto">
        The interactive permission matrix UI with toggles for Superadmin, Garages, and Packages will be rendered here in the next development phase.
      </p>
    </div>
  </div>
</template>

<script setup lang="ts">
definePageMeta({
  middleware: 'auth',
})

const superadminPerms = [
  { key: 'user_mgmt', label: 'User Management', enabled: true },
  { key: 'billing_admin', label: 'Billing Administration', enabled: true },
  { key: 'robot_config', label: 'Robot Configuration', enabled: true },
  { key: 'system_logs', label: 'System Logs Access', enabled: true },
  { key: 'api_keys', label: 'API Key Management', enabled: false },
]

const garagePerms = [
  { key: 'vehicle_crud', label: 'Vehicle CRUD', enabled: true },
  { key: 'service_booking', label: 'Service Booking', enabled: true },
  { key: 'customer_view', label: 'Customer Data View', enabled: true },
  { key: 'report_export', label: 'Report Export', enabled: false },
  { key: 'bulk_import', label: 'Bulk Import', enabled: false },
]

const packagePerms = [
  { key: 'premium_features', label: 'Premium Features', enabled: true },
  { key: 'analytics', label: 'Analytics Dashboard', enabled: true },
  { key: 'multi_garage', label: 'Multi-Garage Support', enabled: false },
  { key: 'white_label', label: 'White Label Branding', enabled: false },
  { key: 'api_access', label: 'API Access', enabled: true },
]
</script>
