<?php $__env->startSection('title', __('Dashboard')); ?>
<?php $__env->startSection('active', 'dashboard'); ?>
<?php $__env->startSection('page_eyebrow', 'Dashboard'); ?>
<?php $__env->startSection('page_heading', 'Welcome back, '.Str::of(auth()->user()->name)->before(' ')); ?>

<?php $__env->startSection('content'); ?>
  <?php
    $statusClasses = [
      'completed' => 'bg-emerald-50 text-emerald-600',
      'review' => 'bg-amber-50 text-amber-600',
      'scanning' => 'bg-blue-50 text-blue-600',
      'scheduled' => 'bg-gray-100 text-gray-600',
    ];
    $reportClasses = [
      'ready' => 'text-[#4f6ef7]',
      'draft' => 'text-amber-600',
      'pending' => 'text-gray-400',
    ];
  ?>

  <div class="rounded-2xl border border-[#c7d3fc] bg-[#eff3fe] p-6 lg:p-8">
    <div class="flex flex-col gap-5 sm:flex-row sm:items-center sm:justify-between">
      <div>
        <p class="text-xs font-medium text-[#4f6ef7]"><?php echo e(__('AI-Powered Insights')); ?></p>
        <h2 class="mt-2 text-2xl font-bold tracking-tight lg:text-3xl" aria-label="<?php echo e($stats['needsReview']); ?> <?php echo e(__('findings need review.')); ?>"><span data-live="needsReview"><?php echo e($stats['needsReview']); ?></span> <?php echo e(__('findings need review.')); ?></h2>
        <p class="mt-2 max-w-xl text-sm leading-6 text-gray-500">
          <?php echo e(__(':count completed inspections this month, :reports reports ready, and :cost in estimated repair cost tracked.', ['count' => $stats['completedThisMonth'], 'reports' => $stats['readyReports'], 'cost' => 'Rp '.number_format($stats['estimatedCost'], 0, ',', '.')])); ?>

        </p>
      </div>
      <a href="<?php echo e(route('inspections.index')); ?>" class="flex h-11 items-center rounded-xl bg-[#4f6ef7] px-4 text-sm font-medium text-white shadow-sm hover:bg-[#3d5ce0]"><?php echo e(__('View Inspections')); ?></a>
    </div>
  </div>

  <div class="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
    <div class="panel rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
      <p class="text-sm font-medium text-gray-500"><?php echo e(__('Total Inspections')); ?></p>
      <p class="mt-2 text-2xl font-bold tracking-tight" data-live="totalInspections"><?php echo e(number_format($stats['totalInspections'])); ?></p>
      <p class="mt-2 text-xs font-medium text-emerald-500"><?php echo e(__(':count completed this month', ['count' => $stats['completedThisMonth']])); ?></p>
    </div>
    <div class="panel rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
      <p class="text-sm font-medium text-gray-500"><?php echo e(__('Detected Damages')); ?></p>
      <p class="mt-2 text-2xl font-bold tracking-tight" data-live="detectedDamages"><?php echo e(number_format($stats['detectedDamages'])); ?></p>
      <p class="mt-2 text-xs font-medium text-amber-500"><?php echo e(__(':count need review', ['count' => $stats['needsReview']])); ?></p>
    </div>
    <div class="panel rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
      <p class="text-sm font-medium text-gray-500"><?php echo e(__('Reports Ready')); ?></p>
      <p class="mt-2 text-2xl font-bold tracking-tight" data-live="readyReports"><?php echo e(number_format($stats['readyReports'])); ?></p>
      <p class="mt-2 text-xs font-medium text-[#4f6ef7]"><?php echo e(__('Generated from inspection reports')); ?></p>
    </div>
    <div class="panel rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
      <p class="text-sm font-medium text-gray-500"><?php echo e(__('Detection Accuracy')); ?></p>
      <p class="mt-2 text-2xl font-bold tracking-tight"><?php echo e(number_format($stats['averageAccuracy'], 1)); ?>%</p>
      <p class="mt-2 text-xs font-medium text-emerald-500"><?php echo e(__('Average AI confidence')); ?></p>
    </div>
  </div>

  <div class="grid gap-6 xl:grid-cols-[1.25fr_.75fr]">
    <div class="rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
      <div class="mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
        <div>
          <h3 class="text-base font-semibold tracking-tight"><?php echo e(__('Workspaces')); ?></h3>
          <p class="text-sm text-gray-400"><?php echo e(__('Separate reports by house, client, project, or inspection batch.')); ?></p>
        </div>
        <span class="rounded-full bg-[#eff3fe] px-2.5 py-1 text-xs font-medium text-[#4f6ef7]"><?php echo e(__(':count workspaces', ['count' => $workspaceSummaries->count()])); ?></span>
      </div>

      <div class="grid gap-3 md:grid-cols-2">
        <?php $__empty_1 = true; $__currentLoopData = $workspaceSummaries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $workspace): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
          <article class="rounded-xl border border-gray-100 bg-gray-50 p-4">
            <div class="flex items-start justify-between gap-3">
              <div class="min-w-0">
                <h4 class="truncate text-sm font-semibold text-gray-900"><?php echo e($workspace->name); ?></h4>
                <p class="mt-1 text-xs text-gray-500"><?php echo e(__(':collections collections', ['collections' => $workspace->collections_count])); ?> · <?php echo e(__(':count scans', ['count' => $workspace->inspections_count])); ?></p>
              </div>
              <a href="<?php echo e(route('inspections.index', ['workspace_id' => $workspace->id])); ?>" data-spa-link class="shrink-0 rounded-lg border border-[#c7d3fc] bg-white px-2.5 py-1 text-xs font-medium text-[#4f6ef7] hover:bg-[#eff3fe]"><?php echo e(__('Open')); ?></a>
            </div>
            <p class="mt-3 text-lg font-bold">Rp <?php echo e(number_format($workspace->estimated_cost_sum ?? 0, 0, ',', '.')); ?></p>
            <div class="mt-3 space-y-2">
              <?php $__empty_2 = true; $__currentLoopData = $workspace->collections->take(3); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $collection): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_2 = false; ?>
                <a href="<?php echo e(route('inspections.index', ['workspace_id' => $workspace->id, 'collection_id' => $collection->id])); ?>" data-spa-link class="flex items-center justify-between gap-3 rounded-lg bg-white px-3 py-2 text-xs hover:bg-[#eff3fe]">
                  <span class="truncate font-medium text-gray-700"><?php echo e($collection->displayName()); ?></span>
                  <span class="shrink-0 text-gray-400"><?php echo e($collection->inspections_count); ?> scan</span>
                </a>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_2): ?>
                <p class="rounded-lg border border-dashed border-gray-200 bg-white px-3 py-2 text-xs text-gray-400"><?php echo e(__('No collections yet.')); ?></p>
              <?php endif; ?>
            </div>
          </article>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
          <p class="rounded-xl border border-dashed border-gray-200 p-4 text-sm text-gray-400"><?php echo e(__('No workspaces yet.')); ?></p>
        <?php endif; ?>
      </div>
    </div>

    <div class="space-y-4">
      <div class="rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
        <h3 class="text-base font-semibold tracking-tight"><?php echo e(__('Create Workspace')); ?></h3>
        <form method="POST" action="<?php echo e(route('workspaces.store')); ?>" class="mt-4 space-y-3">
          <?php echo csrf_field(); ?>
          <input name="name" required maxlength="120" placeholder="<?php echo e(__('Example: Rumah Melati')); ?>" class="h-10 w-full rounded-xl border border-gray-200 bg-gray-50 px-3 text-sm outline-none focus:border-[#4f6ef7] focus:bg-white">
          <select name="default_currency" class="h-10 w-full rounded-xl border border-gray-200 bg-gray-50 px-3 text-sm outline-none focus:border-[#4f6ef7] focus:bg-white">
            <option value="IDR">Rupiah (IDR)</option>
            <option value="USD">US Dollar (USD)</option>
          </select>
          <button type="submit" class="h-10 w-full rounded-xl bg-[#4f6ef7] px-4 text-sm font-medium text-white hover:bg-[#3d5ce0]"><?php echo e(__('Save Workspace')); ?></button>
        </form>
      </div>

      <div class="rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
        <h3 class="text-base font-semibold tracking-tight"><?php echo e(__('Move Collection')); ?></h3>
        <p class="mt-1 text-sm text-gray-400"><?php echo e(__('Move a room/house collection into another workspace without changing its inspection history.')); ?></p>
        <form method="POST" action="<?php echo e(route('collections.move')); ?>" class="mt-4 space-y-3">
          <?php echo csrf_field(); ?>
          <select name="collection_id" required class="h-10 w-full rounded-xl border border-gray-200 bg-gray-50 px-3 text-sm outline-none focus:border-[#4f6ef7] focus:bg-white">
            <option value=""><?php echo e(__('Choose collection')); ?></option>
            <?php $__currentLoopData = $allCollections; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $collection): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <option value="<?php echo e($collection->id); ?>"><?php echo e($collection->displayName()); ?> · <?php echo e($collection->workspace?->name); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
          </select>
          <select name="workspace_id" required class="h-10 w-full rounded-xl border border-gray-200 bg-gray-50 px-3 text-sm outline-none focus:border-[#4f6ef7] focus:bg-white">
            <option value=""><?php echo e(__('Move to workspace')); ?></option>
            <?php $__currentLoopData = $workspaceSummaries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $workspace): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <option value="<?php echo e($workspace->id); ?>"><?php echo e($workspace->name); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
          </select>
          <button type="submit" class="h-10 w-full rounded-xl border border-[#c7d3fc] bg-[#eff3fe] px-4 text-sm font-medium text-[#4f6ef7] hover:bg-white"><?php echo e(__('Move Collection')); ?></button>
        </form>
      </div>
    </div>
  </div>

  <div class="grid gap-6 xl:grid-cols-[1.4fr_.8fr]">
    <div class="rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
      <div class="mb-4 flex items-center justify-between">
        <h3 class="text-base font-semibold tracking-tight"><?php echo e(__('Recent inspections')); ?></h3>
        <span class="text-sm font-medium text-[#4f6ef7]"><?php echo e(__(':count shown', ['count' => $recentInspections->count()])); ?></span>
      </div>
      <div class="overflow-x-auto">
        <table class="w-full text-left text-sm">
          <thead class="text-xs uppercase text-gray-400">
            <tr>
              <th class="px-3 py-3"><?php echo e(__('Property')); ?></th>
              <th class="px-3 py-3"><?php echo e(__('Collection')); ?></th>
              <th class="px-3 py-3"><?php echo e(__('Status')); ?></th>
              <th class="px-3 py-3"><?php echo e(__('Findings')); ?></th>
              <th class="px-3 py-3"><?php echo e(__('Cost')); ?></th>
              <th class="px-3 py-3"><?php echo e(__('Report')); ?></th>
            </tr>
          </thead>
          <tbody class="divide-y divide-gray-100">
            <?php $__empty_1 = true; $__currentLoopData = $recentInspections; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $inspection): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
              <tr>
                <td class="px-3 py-3">
                  <p class="font-medium"><?php echo e($inspection->property_name); ?></p>
                  <p class="mt-0.5 text-xs text-gray-400"><?php echo e($inspection->property_address); ?></p>
                </td>
                <td class="px-3 py-3">
                  <p class="font-medium"><?php echo e($inspection->collection?->displayName() ?? __('Unbatched')); ?></p>
                  <p class="mt-0.5 text-xs text-gray-400"><?php echo e(Str::headline($inspection->collection?->collection_type ?? 'single scan')); ?></p>
                </td>
                <td class="px-3 py-3">
                  <span class="rounded-lg px-2 py-1 text-xs font-medium <?php echo e($statusClasses[$inspection->status] ?? 'bg-gray-100 text-gray-600'); ?>">
                    <?php echo e(Str::headline($inspection->status)); ?>

                  </span>
                </td>
                <td class="px-3 py-3"><?php echo e($inspection->damage_findings_count ?? $inspection->damageFindings->count()); ?></td>
                <td class="px-3 py-3"><?php echo e($inspection->estimated_cost_label ?? 'Rp '.number_format($inspection->estimated_cost, 0, ',', '.')); ?></td>
                <td class="px-3 py-3 <?php echo e($reportClasses[$inspection->report?->status] ?? 'text-gray-400'); ?>">
                  <?php echo e(Str::headline($inspection->report?->status ?? 'No report')); ?>

                </td>
              </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
              <tr>
                <td colspan="6" class="px-3 py-8 text-center text-sm text-gray-400"><?php echo e(__('No inspections yet.')); ?></td>
              </tr>
            <?php endif; ?>
          </tbody>
        </table>
      </div>
    </div>

    <div class="space-y-6">
      <div class="rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
        <h3 class="text-base font-semibold tracking-tight"><?php echo e(__('Damage severity')); ?></h3>
        <div class="mt-4 space-y-3 text-sm">
          <?php $__currentLoopData = ['high' => __('High'), 'medium' => __('Medium'), 'low' => __('Low')]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php
              $total = (int) ($damageBreakdown[$key] ?? 0);
              $width = $stats['detectedDamages'] > 0 ? max(8, ($total / $stats['detectedDamages']) * 100) : 0;
            ?>
            <div>
              <div class="flex justify-between gap-4">
                <span class="text-gray-500"><?php echo e($label); ?></span>
                <span class="font-medium text-gray-900"><?php echo e($total); ?></span>
              </div>
              <div class="mt-2 h-2 overflow-hidden rounded-full bg-gray-100">
                <div class="h-full rounded-full bg-[#4f6ef7]" style="width: <?php echo e($width); ?>%"></div>
              </div>
            </div>
          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
      </div>

      <div class="rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
        <div class="mb-6">
          <h3 class="text-base font-semibold tracking-tight"><?php echo e(__('Collection breakdown')); ?></h3>
          <div class="mt-4 space-y-3 text-sm">
            <?php $__empty_1 = true; $__currentLoopData = $collectionSummaries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $collection): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
              <a href="<?php echo e(route('inspections.index', ['workspace_id' => $collection->inspection_workspace_id, 'collection_id' => $collection->id])); ?>" data-spa-link class="block rounded-xl border border-gray-100 bg-gray-50 p-3 hover:border-[#c7d3fc] hover:bg-[#eff3fe]">
                <div class="flex items-center justify-between gap-3">
                  <span class="font-medium text-gray-900"><?php echo e($collection->displayName()); ?></span>
                  <span class="text-xs font-medium text-[#4f6ef7]"><?php echo e(__(':count scans', ['count' => $collection->inspections_count])); ?></span>
                </div>
                <p class="mt-1 text-xs text-gray-500"><?php echo e($collection->workspace?->name); ?> · <?php echo e(Str::headline($collection->collection_type)); ?> · Rp <?php echo e(number_format($collection->inspections_sum_estimated_cost ?? 0, 0, ',', '.')); ?></p>
              </a>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
              <p class="rounded-xl border border-dashed border-gray-200 p-3 text-sm text-gray-400"><?php echo e(__('No collections yet.')); ?></p>
            <?php endif; ?>
          </div>
        </div>

        <h3 class="text-base font-semibold tracking-tight"><?php echo e(__('Account')); ?></h3>
        <div class="mt-4 space-y-3 text-sm">
          <div class="flex justify-between gap-4">
            <span class="text-gray-500"><?php echo e(__('Name')); ?></span>
            <span class="font-medium text-gray-900"><?php echo e(auth()->user()->name); ?></span>
          </div>
          <div class="flex justify-between gap-4">
            <span class="text-gray-500"><?php echo e(__('Email')); ?></span>
            <span class="font-medium text-gray-900"><?php echo e(auth()->user()->email); ?></span>
          </div>
          <div class="flex justify-between gap-4">
            <span class="text-gray-500"><?php echo e(__('Role')); ?></span>
            <span class="font-medium text-gray-900"><?php echo e(auth()->user()->role); ?></span>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div class="rounded-2xl border border-gray-100 bg-white p-5 shadow-sm">
    <div class="flex items-center justify-between">
      <div>
        <h3 class="text-base font-semibold"><?php echo e(__('Live Workspace Pulse')); ?></h3>
        <p class="text-sm text-gray-400"><?php echo e(__('Last synced at')); ?> <span data-live-updated-at>--:--:--</span></p>
      </div>
      <div class="flex items-center gap-2 rounded-xl bg-emerald-50 px-3 py-2 text-xs font-medium text-emerald-600">
        <span class="h-2 w-2 rounded-full bg-emerald-500 pulse-dot"></span>
        <?php echo e(__('Live update active')); ?>

      </div>
    </div>
  </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\ariqa\Documents\matkul\smster 4\data sains\prj\homeinspector\resources\views\dashboard.blade.php ENDPATH**/ ?>