<x-app-layout>
    <x-slot name="header">
        <style>
            .dash-header-title {
                font-weight: 700;
                font-size: 1.5rem;
                letter-spacing: -0.01em;
                color: #000000;
            }
        </style>
        <h2 class="dash-header-title">Brand</h2>
    </x-slot>

    <style>
        /* Reset and base styles - no custom fonts */
        .brand-wrap { 
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
        }

        .brand-inner {
            max-width: 1000px;
            margin: 0 auto;
            padding: 40px 24px;
        }

        /* ── TOP BAR ── */
        .brand-topbar {
            display: flex;
            align-items: flex-end;
            justify-content: space-between;
            margin-bottom: 32px;
        }

        .brand-title {
            font-size: 1.5rem;
            font-weight: 700;
            color: #000000;
            letter-spacing: -0.01em;
        }

        .brand-add-btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: #000000;
            color: #fff;
            font-family: inherit;
            font-size: 0.7rem;
            font-weight: 700;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            text-decoration: none;
            padding: 10px 22px;
            border-radius: 30px;
            transition: background 0.2s;
            white-space: nowrap;
        }

        .brand-add-btn:hover { background: #333; }

        .brand-add-btn-plus {
            font-size: 1.1rem;
            font-weight: 400;
            line-height: 1;
        }

        /* ── FLASH ── */
        .brand-flash {
            margin-bottom: 20px;
            padding: 12px 18px;
            border-left: 3px solid #000000;
            background: #f5f5f5;
            border-radius: 8px;
            font-size: 0.8rem;
            color: #000000;
            font-weight: 500;
        }

        /* ── TABLE WRAP ── */
        .brand-table-wrap {
            background: #fff;
            border: 1px solid #ebebeb;
            border-radius: 12px;
            overflow: hidden;
        }

        .brand-table {
            width: 100%;
            border-collapse: collapse;
        }

        .brand-table thead th {
            padding: 14px 28px;
            font-size: 0.65rem;
            font-weight: 700;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: #000000;
            background: #fafafa;
            border-bottom: 1px solid #f0f0f0;
            text-align: left;
        }

        .brand-table thead th.center { text-align: center; }
        .brand-table thead th.right { text-align: right; }

        .brand-table tbody tr {
            border-bottom: 1px solid #f5f5f5;
            transition: background 0.15s;
        }

        .brand-table tbody tr:last-child { border-bottom: none; }
        .brand-table tbody tr:hover { background: #fafafa; }

        .brand-table td {
            padding: 18px 28px;
            vertical-align: middle;
        }

        /* ── LOGO ── */
        .brand-logo-img {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            object-fit: contain;
            background: #f5f5f5;
            border: 1px solid #ebebeb;
        }

        .brand-logo-placeholder {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            background: #000000;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.85rem;
            font-weight: 700;
            letter-spacing: 0.02em;
            flex-shrink: 0;
        }

        /* ── NAME ── */
        .brand-name {
            font-size: 0.95rem;
            font-weight: 700;
            color: #000000;
        }

        /* ── DESC ── */
        .brand-desc {
            font-size: 0.85rem;
            font-weight: 500;
            color: #666666;
            max-width: 280px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* ── STATUS BADGE ── */
        .brand-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 12px;
            font-size: 0.65rem;
            font-weight: 700;
            letter-spacing: 0.02em;
            text-transform: uppercase;
            border-radius: 30px;
        }

        .brand-badge-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
        }

        .badge-active { background: #e8f5e9; color: #2e7d32; }
        .badge-active .brand-badge-dot { background: #2e7d32; }
        .badge-inactive { background: #f5f5f5; color: #999999; }
        .badge-inactive .brand-badge-dot { background: #bbbbbb; }

        /* ── ACTIONS (SAMA DENGAN KATEGORI) ── */
        .brand-actions {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 12px;
        }

        .brand-edit-link {
            display: inline-block;
            font-size: 0.7rem;
            font-weight: 700;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: #ffffff;
            text-decoration: none;
            padding: 8px 20px;
            border-radius: 30px;
            background: #000000;
            transition: all 0.2s;
            text-align: center;
        }

        .brand-edit-link:hover { 
            background: #000000;
            color: #ffffff;
        }

        .brand-delete-btn {
            font-size: 0.7rem;
            font-weight: 700;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: #ffffff;
            background: #dc2626;
            border: none;
            cursor: pointer;
            padding: 8px 20px;
            border-radius: 30px;
            font-family: inherit;
            transition: all 0.2s;
            text-align: center;
        }

        .brand-delete-btn:hover { 
            background: #b91c1c;
        }

        /* ── EMPTY STATE ── */
        .brand-empty {
            padding: 72px 28px;
            text-align: center;
        }

        .brand-empty-title {
            font-size: 1.1rem;
            font-weight: 700;
            color: #000000;
            margin-bottom: 8px;
        }

        .brand-empty-desc {
            font-size: 0.8rem;
            font-weight: 500;
            color: #666666;
            letter-spacing: 0.02em;
            margin-bottom: 24px;
        }

        .brand-empty-btn {
            display: inline-block;
            background: #000000;
            color: #fff;
            font-family: inherit;
            font-size: 0.7rem;
            font-weight: 700;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            text-decoration: none;
            padding: 10px 24px;
            border-radius: 30px;
            transition: background 0.2s;
        }

        .brand-empty-btn:hover { background: #333; }

        /* ── PAGINATION ── */
        .brand-pagination { margin-top: 20px; }
    </style>

    <div class="brand-wrap">
        <div class="brand-inner">

            {{-- Top Bar --}}
            <div class="brand-topbar">
                <div class="brand-title">Daftar Brand</div>
                <a href="{{ route('admin.brands.create') }}" class="brand-add-btn">
                    <span class="brand-add-btn-plus">+</span> Tambah Brand
                </a>
            </div>

            {{-- Flash --}}
            @if(session('success'))
                <div class="brand-flash">{{ session('success') }}</div>
            @endif

            {{-- Table --}}
            <div class="brand-table-wrap">
                <table class="brand-table">
                    <thead>
                        <tr>
                            <th style="width: 80px;">Logo</th>
                            <th>Nama Brand</th>
                            <th>Deskripsi</th>
                            <th class="center">Status</th>
                            <th class="right">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($brands as $brand)
                        <tr>
                            <td>
                                @if($brand->logo)
                                    <img src="{{ asset('storage/' . $brand->logo) }}" alt="{{ $brand->name }}" class="brand-logo-img">
                                @else
                                    <div class="brand-logo-placeholder">{{ strtoupper(substr($brand->name, 0, 1)) }}</div>
                                @endif
                            </td>
                            <td>
                                <div class="brand-name">{{ $brand->name }}</div>
                            </td>
                            <td>
                                <div class="brand-desc" title="{{ $brand->description }}">
                                    {{ $brand->description ? Str::limit($brand->description, 60) : '—' }}
                                </div>
                            </td>
                            <td style="text-align:center;">
                                @if($brand->is_active)
                                    <span class="brand-badge badge-active"><span class="brand-badge-dot"></span>Aktif</span>
                                @else
                                    <span class="brand-badge badge-inactive"><span class="brand-badge-dot"></span>Nonaktif</span>
                                @endif
                            </td>
                            <td>
                                <div class="brand-actions">
                                    <a href="{{ route('admin.brands.edit', $brand->id) }}" class="brand-edit-link">Edit</a>
                                    <form action="{{ route('admin.brands.destroy', $brand->id) }}" method="POST" class="inline" onsubmit="return confirm('Hapus brand \'{{ $brand->name }}\'?')">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="brand-delete-btn">Hapus</button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                        @empty
                        <tr>
                            <td colspan="5">
                                <div class="brand-empty">
                                    <div class="brand-empty-title">Belum ada brand</div>
                                    <div class="brand-empty-desc">Mulai dengan menambahkan brand pertama Anda</div>
                                    <a href="{{ route('admin.brands.create') }}" class="brand-empty-btn">+ Tambah Brand</a>
                                </div>
                            </td>
                        </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>

            {{-- Pagination --}}
            @if($brands->hasPages())
            <div class="brand-pagination">
                {{ $brands->links() }}
            </div>
            @endif

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