@extends('layouts.frontend')

@section('title', 'Beranda')

@section('content')
<!-- 1. HERO SECTION START -->
<div class="container-fluid py-5 mb-5 hero-header">
    <div class="container py-5">
        <div class="row g-5 align-items-center">
            <div class="col-md-12 col-lg-7">
                <h4 class="mb-3 text-secondary">100% Organik & Segar</h4>
                <h1 class="mb-5 display-3 text-primary">Sayuran & Buah Desa <br>Langsung Petani</h1>
                <div class="position-relative mx-auto">
                    <a href="{{ route('shop') }}" class="btn btn-primary border-2 border-secondary py-3 px-5 rounded-pill text-white" style="box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
                        <i class="fa fa-shopping-bag me-2"></i> Belanja Sekarang
                    </a>
                </div>
            </div>
            <div class="col-md-12 col-lg-5">
                <div id="carouselId" class="carousel slide position-relative" data-bs-ride="carousel">
                    <div class="carousel-inner" role="listbox">
                        <div class="carousel-item active rounded">
                            <img src="{{ asset('template/frontend/img/hero-img-1.png') }}" class="img-fluid w-100 h-100 bg-secondary rounded" alt="Buah">
                            <a href="#" class="btn px-4 py-2 text-white rounded">Buah-buahan</a>
                        </div>
                        <div class="carousel-item rounded">
                            <img src="{{ asset('template/frontend/img/hero-img-2.jpg') }}" class="img-fluid w-100 h-100 rounded" alt="Sayur">
                            <a href="#" class="btn px-4 py-2 text-white rounded">Sayuran</a>
                        </div>
                    </div>
                    <button class="carousel-control-prev" type="button" data-bs-target="#carouselId" data-bs-slide="prev">
                        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                        <span class="visually-hidden">Previous</span>
                    </button>
                    <button class="carousel-control-next" type="button" data-bs-target="#carouselId" data-bs-slide="next">
                        <span class="carousel-control-next-icon" aria-hidden="true"></span>
                        <span class="visually-hidden">Next</span>
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- HERO SECTION END -->

<!-- 2. LAYANAN / FEATURES START (Biar terlihat profesional) -->
<div class="container-fluid featurs py-5">
    <div class="container py-5">
        <div class="row g-4">
            <div class="col-md-6 col-lg-3">
                <div class="featurs-item text-center rounded bg-light p-4">
                    <div class="featurs-icon btn-square rounded-circle bg-secondary mb-5 mx-auto">
                        <i class="fas fa-car-side fa-3x text-white"></i>
                    </div>
                    <div class="featurs-content text-center">
                        <h5>Gratis Ongkir</h5>
                        <p class="mb-0">Gratis untuk radius desa</p>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-lg-3">
                <div class="featurs-item text-center rounded bg-light p-4">
                    <div class="featurs-icon btn-square rounded-circle bg-secondary mb-5 mx-auto">
                        <i class="fas fa-user-shield fa-3x text-white"></i>
                    </div>
                    <div class="featurs-content text-center">
                        <h5>Transaksi Aman</h5>
                        <p class="mb-0">Pembayaran COD Terjamin</p>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-lg-3">
                <div class="featurs-item text-center rounded bg-light p-4">
                    <div class="featurs-icon btn-square rounded-circle bg-secondary mb-5 mx-auto">
                        <i class="fas fa-exchange-alt fa-3x text-white"></i>
                    </div>
                    <div class="featurs-content text-center">
                        <h5>Jaminan Kualitas</h5>
                        <p class="mb-0">Garansi produk segar</p>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-lg-3">
                <div class="featurs-item text-center rounded bg-light p-4">
                    <div class="featurs-icon btn-square rounded-circle bg-secondary mb-5 mx-auto">
                        <i class="fa fa-phone-alt fa-3x text-white"></i>
                    </div>
                    <div class="featurs-content text-center">
                        <h5>Support 24/7</h5>
                        <p class="mb-0">Hubungi kami kapan saja</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- PRODUK TERBARU -->
<div class="container-fluid py-5">
    <div class="container py-5">
        <div class="text-center mx-auto mb-5" style="max-width: 700px;">
            <h1 class="display-4">Produk Panen Terbaru</h1>
            <p>Pilihan hasil bumi terbaik yang baru saja dipanen oleh petani lokal.</p>
        </div>
        <div class="row g-4">
            @forelse($produks as $produk)
            <div class="col-md-6 col-lg-4 col-xl-3">
                <div class="rounded position-relative fruite-item border border-secondary">
                    <div class="fruite-img">
                        <img src="{{ $produk->foto_produk ? asset('storage/'.$produk->foto_produk) : asset('template/frontend/img/fruite-item-5.jpg') }}" 
                             class="img-fluid w-100 rounded-top" 
                             alt="{{ $produk->nama_produk }}"
                             style="height: 200px; object-fit: cover;">
                    </div>
                    <div class="text-white bg-secondary px-3 py-1 rounded position-absolute" style="top: 10px; left: 10px;">Segar</div>
                    <div class="p-4 border-top-0 rounded-bottom">
                        <h5>{{ $produk->nama_produk }}</h5>
                        <p class="text-muted">{{ Str::limit($produk->deskripsi, 45) }}</p>
                        <div class="d-flex justify-content-between flex-lg-wrap">
                            <p class="text-dark fs-5 fw-bold mb-0">Rp {{ number_format($produk->harga, 0, ',', '.') }} / kg</p>
                            <a href="{{ route('produk.detail', $produk->id) }}" class="btn border border-secondary rounded-pill px-3 text-primary">
                                <i class="fa fa-eye me-2 text-primary"></i> Detail
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            @empty
            <div class="col-12 text-center py-5">
                <div class="alert alert-warning d-inline-block">
                    <i class="fas fa-exclamation-triangle me-2"></i> Belum ada produk yang dijual saat ini.
                </div>
            </div>
            @endforelse
        </div>
        
        <div class="text-center mt-5">
            <a href="{{ route('shop') }}" class="btn btn-primary rounded-pill py-3 px-5 text-white">Lihat Semua Produk</a>
        </div>
    </div>
</div>

<!-- BANNER PROMO -->
<div class="container-fluid banner bg-secondary my-5">
    <div class="container py-5">
        <div class="row g-4 align-items-center">
            <div class="col-lg-6">
                <div class="py-4">
                    <h1 class="display-3 text-white">Buah Segar Eksotis</h1>
                    <p class="fw-normal display-3 text-dark mb-4">di Toko Kami</p>
                    <p class="mb-4 text-dark">Dapatkan harga spesial untuk pembelian grosir langsung dari kebun petani.</p>
                    <a href="{{ route('shop') }}" class="banner-btn btn border-2 border-white rounded-pill text-dark py-3 px-5">BELANJA SEKARANG</a>
                </div>
            </div>
            <div class="col-lg-6">
                <div class="position-relative">
                    <img src="{{ asset('template/frontend/img/baner-1.png') }}" class="img-fluid w-100 rounded" alt="">
                    <div class="d-flex align-items-center justify-content-center bg-white rounded-circle position-absolute" style="width: 140px; height: 140px; top: 0; left: 0;">
                        <h1 style="font-size: 50px;">%</h1>
                        <div class="d-flex flex-column">
                            <span class="h4 mb-0">Promo</span>
                            <span class="h6 text-muted mb-0">Minggu Ini</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection