@extends('layouts.admin')

@section('heading', 'Good morning, ' . Auth::guard('admin')->user()->name)
@section('subheading', "Here's what's happening across your shop today.")



@section('content')

@php
  $shop = Auth::guard('admin')->user()->shop ?? null;
  $shopLogo = $shop?->logo ? asset('storage/' . $shop->logo) : null;
@endphp

<div style="position:relative;">

@if($shopLogo)
  <img src="{{ $shopLogo }}" alt=""
       style="position:absolute; top:-10px; right:-10px; width:260px; height:260px; object-fit:center; opacity:0.12; pointer-events:none; z-index:0;">
@endif

  <div style="position:relative; z-index:1;">

    <div class="grid grid-cols-4 gap-4 mb-8">
      <div class="card p-5">
        <p class="text-xs mb-2" style="color:#6b6470;">Orders today</p>
        <p class="font-display font-semibold text-2xl" style="color:#1A1625;">{{ $stats['orders_today'] }}</p>
      </div>
      <div class="card p-5">
        <p class="text-xs mb-2" style="color:#6b6470;">Pending delivery</p>
        <p class="font-display font-semibold text-2xl" style="color:#1A1625;">{{ $stats['pending_delivery'] }}</p>
      </div>
      <div class="card p-5">
        <p class="text-xs mb-2" style="color:#6b6470;">Revenue this month</p>
        <p class="font-display font-semibold text-2xl" style="color:#1A1625;">₹{{ number_format($stats['revenue_this_month'], 0) }}</p>
      </div>
      <div class="card p-5">
        <p class="text-xs mb-2" style="color:#6b6470;">Balance due (கடன்)</p>
        <p class="font-display font-semibold text-2xl" style="color:#1A1625;">₹{{ number_format($stats['balance_due'], 0) }}</p>
      </div>
    </div>

    <div class="card p-6 mb-8">
      <h3 class="font-display font-semibold text-base mb-6" style="color:#1A1625;">Order pipeline</h3>
      <div class="grid grid-cols-5 gap-4">
        @php
          $colors = [
            'received'  => ['bg' => '#EEEDFE', 'text' => '#5E35B1'],
            'cutting'   => ['bg' => '#FAECE7', 'text' => '#993C1D'],
            'stitching' => ['bg' => '#FBEAF0', 'text' => '#993556'],
            'finishing' => ['bg' => '#FAEEDA', 'text' => '#854F0B'],
            'ready'     => ['bg' => '#E1F5EE', 'text' => '#0F6E56'],
          ];
        @endphp
        @foreach($stats['pipeline'] as $stage => $count)
          <div class="flex flex-col items-center gap-2">
            <div class="w-14 h-14 rounded-full flex items-center justify-center font-display font-semibold"
                 style="background:{{ $colors[$stage]['bg'] }}; color:{{ $colors[$stage]['text'] }};">
              {{ $count }}
            </div>
            <span class="text-xs capitalize" style="color:#6b6470;">{{ $stage }}</span>
          </div>
        @endforeach
      </div>
    </div>

  </div>
</div>

@endsection
