<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>سطل زباله محصولات | ADINIKE</title>

    <style>
        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            font-family: Tahoma, Arial, sans-serif;
            background: #f5f5f5;
            color: #222;
        }

        header {
            background: #171717;
            color: white;
            padding: 18px 5%;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        header strong {
            color: #e52d50;
            font-size: 22px;
        }

        header a {
            color: white;
            text-decoration: none;
        }

        main {
            max-width: 1100px;
            margin: 35px auto;
            padding: 0 16px;
        }

        .top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            flex-wrap: wrap;
            margin-bottom: 22px;
        }

        h1 {
            font-size: 23px;
            margin: 0;
        }

        .btn {
            display: inline-block;
            border: 0;
            border-radius: 7px;
            padding: 10px 14px;
            text-decoration: none;
            cursor: pointer;
            font: inherit;
            font-size: 13px;
        }

        .back {
            background: #222;
            color: white;
        }

        .restore {
            background: #16834a;
            color: white;
        }

        .message {
            background: #e5f7eb;
            color: #176b36;
            padding: 13px;
            border-radius: 8px;
            margin-bottom: 18px;
        }

        .table-wrap {
            background: white;
            border-radius: 12px;
            overflow-x: auto;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            min-width: 650px;
        }

        th, td {
            padding: 15px 12px;
            text-align: right;
            border-bottom: 1px solid #eee;
            font-size: 13px;
        }

        th {
            background: #fafafa;
            color: #555;
        }

        .empty {
            text-align: center;
            padding: 35px;
            color: #777;
        }

        form {
            margin: 0;
        }

        @media(max-width:600px) {
            main {
                margin-top: 22px;
            }

            h1 {
                font-size: 19px;
            }

            header {
                padding: 15px;
            }
        }
    </style>
</head>

<body>

<header>
    <strong>ADINIKE</strong>
    <a href="{{ route('admin.dashboard') }}">بازگشت به داشبورد</a>
</header>

<main>

    <div class="top">
        <h1>سطل زباله محصولات</h1>

        <a class="btn back" href="{{ route('admin.products.index') }}">
            بازگشت به محصولات
        </a>
    </div>

    @if(session('success'))
        <div class="message">
            {{ session('success') }}
        </div>
    @endif

    <div class="table-wrap">

        <table>
            <thead>
                <tr>
                    <th>نام محصول</th>
                    <th>شناسه محصول</th>
                    <th>قیمت</th>
                    <th>تاریخ حذف</th>
                    <th>عملیات</th>
                </tr>
            </thead>

            <tbody>

                @forelse($products as $product)

                    <tr>
                        <td>{{ $product->name }}</td>

                        <td>{{ $product->id }}</td>

                        <td>
                            {{ number_format($product->price) }}
                        </td>

                        <td>
                            {{ $product->deleted_at?->format('Y/m/d H:i') }}
                        </td>

                        <td>
                            <form method="POST"
                                  action="{{ route('admin.products.restore', $product->id) }}">

                                @csrf
                                @method('PATCH')

                                <button class="btn restore" type="submit">
                                    بازیابی محصول
                                </button>

                            </form>
                        </td>
                    </tr>

                @empty

                    <tr>
                        <td colspan="5" class="empty">
                            سطل زباله خالی است.
                        </td>
                    </tr>

                @endforelse

            </tbody>
        </table>

    </div>

    <div style="margin-top:20px">
        {{ $products->links() }}
    </div>

</main>

</body>
</html>