<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <title>Monitoring Lahan Sederhana</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light p-4">
    <div class="container">
        <h2 class="mb-4">Monitoring Lahan</h2>

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

        <div class="card mb-4">
            <div class="card-header">Tambah Data Lahan</div>
            <div class="card-body">
                <form action="{{ route('lahan.store') }}" method="POST">
                    @csrf
                    <div class="row g-2">
                        <div class="col-md-3">
                            <input type="text" name="nama_lahan" class="form-control" placeholder="Nama Lahan" required>
                        </div>
                        <div class="col-md-3">
                            <input type="number" step="0.01" name="luas_m2" class="form-control" placeholder="Luas (m²)" required>
                        </div>
                        <div class="col-md-3">
                            <input type="text" name="lokasi" class="form-control" placeholder="Lokasi/Desa" required>
                        </div>
                        <div class="col-md-3">
                            <button type="submit" class="btn btn-primary w-100">Simpan Data</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div class="card">
            <div class="card-header">Daftar Lahan</div>
            <div class="card-body">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>No</th>
                            <th>Nama Lahan</th>
                            <th>Luas (m²)</th>
                            <th>Lokasi</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($lahans as $index => $item)
                        <tr>
                            <td>{{ $index + 1 }}</td>
                            <td>{{ $item->nama_lahan }}</td>
                            <td>{{ $item->luas_m2 }}</td>
                            <td>{{ $item->lokasi }}</td>
                            <td><span class="badge bg-success">{{ $item->status }}</span></td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>