<x-app-layout>
    <x-slot name="header">
        <div style="display: flex; justify-content: space-between; align-items: center;">
            <h2 class="serif" style="font-size: 1.3rem; color: var(--cream); font-weight: 400; letter-spacing: 0.05em;">
                {{ __('Admin / Hero Banners') }}
            </h2>
            <a href="{{ route('admin.banners.create') }}" class="serif" style="background: var(--amber); color: var(--charcoal); padding: 0.5rem 1.25rem; border-radius: 2px; font-size: 0.85rem; font-weight: 600; text-decoration: none; transition: background 0.2s;">
                + Add Banner
            </a>
        </div>
    </x-slot>

    <style>
        .admin-table-container {
            background: #fff;
            border-radius: 4px;
            border: 1px solid rgba(26,24,20,0.08);
            overflow: hidden;
        }
        .admin-table { width: 100%; border-collapse: collapse; text-align: left; }
        .admin-table th {
            background: var(--ivory);
            padding: 1rem 1.5rem;
            font-size: 0.65rem;
            letter-spacing: 0.15em;
            text-transform: uppercase;
            color: var(--warm-gray);
            font-weight: 600;
            border-bottom: 1px solid rgba(26,24,20,0.06);
        }
        .admin-table td {
            padding: 1.25rem 1.5rem;
            font-size: 0.9rem;
            color: var(--ink);
            border-bottom: 1px solid rgba(26,24,20,0.04);
            vertical-align: middle;
        }
        .banner-thumb {
            width: 100px;
            height: 40px;
            object-fit: cover;
            border-radius: 2px;
            background: var(--cream);
        }
        .status-badge {
            font-size: 0.65rem;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            font-weight: 600;
            padding: 0.25rem 0.6rem;
            border-radius: 2px;
        }
        .badge-active { background: rgba(74, 124, 89, 0.1); color: var(--success); }
        .badge-inactive { background: rgba(26, 24, 20, 0.05); color: var(--warm-gray); }

        .action-link {
            font-size: 0.75rem;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            font-weight: 600;
            text-decoration: none;
            margin-right: 1.5rem;
            transition: color 0.2s;
        }
        .edit-link { color: var(--sage); }
        .delete-btn {
            color: var(--terracotta);
            background: none;
            border: none;
            font-size: 0.75rem;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            font-weight: 600;
            cursor: pointer;
            padding: 0;
        }
    </style>

    <div style="padding: 4rem 0 8rem;">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            
            @if(session('success'))
                <div style="background: var(--success); color: #fff; padding: 1rem 1.5rem; border-radius: 2px; margin-bottom: 3rem; font-size: 0.9rem;">
                    {{ session('success') }}
                </div>
            @endif

            <div class="admin-table-container">
                <table class="admin-table">
                    <thead>
                        <tr>
                            <th style="width: 120px;">Preview</th>
                            <th>Title</th>
                            <th>Order</th>
                            <th>Status</th>
                            <th style="text-align: right;">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($banners as $banner)
                            <tr>
                                <td>
                                    @if($banner->image)
                                        <img src="{{ asset('storage/' . $banner->image) }}" class="banner-thumb">
                                    @else
                                        <div class="banner-thumb" style="display:flex;align-items:center;justify-content:center;color:var(--mist);font-size:0.6rem;">NO IMG</div>
                                    @endif
                                </td>
                                <td>
                                    <div style="font-weight: 600; color: var(--charcoal);">{{ $banner->title }}</div>
                                    <div style="font-size: 0.75rem; color: var(--mist);">{{ $banner->subtitle }}</div>
                                </td>
                                <td>{{ $banner->order }}</td>
                                <td>
                                    @if($banner->is_active)
                                        <span class="status-badge badge-active">Active</span>
                                    @else
                                        <span class="status-badge badge-inactive">Inactive</span>
                                    @endif
                                </td>
                                <td style="text-align: right;">
                                    <div style="display: flex; justify-content: flex-end; align-items: center;">
                                        <a href="{{ route('admin.banners.edit', $banner) }}" class="action-link edit-link">Edit</a>
                                        <form action="{{ route('admin.banners.destroy', $banner) }}" method="POST" onsubmit="return confirm('Delete this banner?')">
                                            @csrf
                                            @method('DELETE')
                                            <button type="submit" class="delete-btn">Delete</button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>

        </div>
    </div>
</x-app-layout>
