@extends('layouts.winemaker')

@section('title', 'Vineyard Rows')

@section('content')
<div class="card" style="background:#fff;border-radius:12px;padding:1.5rem;box-shadow:0 10px 30px rgba(0,0,0,0.08);">
    <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:1.5rem;">
        <h1 style="font-size:1.6rem;color:#1a365d;">Vineyard Rows</h1>
        <a href="{{ route('vineyard-rows.create') }}" style="background:#2563eb;color:#fff;padding:0.6rem 1.2rem;border-radius:8px;text-decoration:none;font-weight:600;">Add row</a>
    </div>

    <div style="overflow-x:auto;">
        <table style="width:100%;border-collapse:collapse;">
            <thead>
                <tr style="background:#f1f5f9;color:#1e293b;">
                    <th style="text-align:left;padding:0.75rem;">ID</th>
                    <th style="text-align:left;padding:0.75rem;">Location</th>
                    <th style="text-align:left;padding:0.75rem;">Vine count</th>
                    <th style="text-align:left;padding:0.75rem;">Status</th>
                    <th style="text-align:left;padding:0.75rem;">Variation</th>
                    <th style="text-align:left;padding:0.75rem;">Actions</th>
                </tr>
            </thead>
            <tbody>
                @forelse ($rows as $row)
                    <tr style="border-bottom:1px solid #e2e8f0;">
                        <td style="padding:0.75rem;">{{ $row->id }}</td>
                        <td style="padding:0.75rem;">{{ $row->location ?? '—' }}</td>
                        <td style="padding:0.75rem;">{{ $row->vine_count }}</td>
                        <td style="padding:0.75rem;text-transform:capitalize;">{{ $row->status }}</td>
                        <td style="padding:0.75rem;">
                            {{ $row->varietyVariation?->grapeVariety?->variety_name ?? 'Unassigned' }}
                        </td>
                        <td style="padding:0.75rem;">
                            <a href="{{ route('vineyard-rows.show', $row) }}" style="margin-right:0.5rem;color:#2563eb;text-decoration:none;">View</a>
                            <a href="{{ route('vineyard-rows.edit', $row) }}" style="color:#2563eb;text-decoration:none;">Edit</a>
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="6" style="padding:1.5rem;text-align:center;color:#64748b;">No rows available.</td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </div>

    <div style="margin-top:1.5rem;">
        {{ $rows->links() }}
    </div>
</div>
@endsection
