@extends('layouts.web')

@section('content')
    <section class="py-5 " style="background-color: #f1f1f1;  min-height: 80vh">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-8 offset-md-2">
                    <div class="card">
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-5">
                                    <img src="{{ asset('img_assets/product/' . $product->image) }}" alt="phone"
                                        class="image-float img-fluid" style="margin-top: 0px; margin-bottom: 0px">
                                </div>
                                <div class="col-md-7">
                                    <form action="{{ route('cart.insert') }}" method="POST">
                                        @csrf @method('POST')
                                        <input type="hidden" name="product_id" value="{{ $product->id }}" />
                                        <h2 class="my-3">{{ $product->name }}</h2>
                                        <p>{{ $product->description }}</p>
                                        <div class="price" style="font-size: 17px">Stok :
                                            {{ number_format($product->stock) }}
                                        </div>
                                        @if ($product->is_discount)
                                            <label for="">Harga</label>
                                            <div class="d-flex align-items-center">
                                                <div class="price" style="font-size: 30px;">Rp.
                                                    {{ number_format($product->price * (1 - $product->discount_price / 100)) }}
                                                </div>
                                                <div class="price" style="text-decoration: line-through; padding-left: 10px; font-size: 12px">
                                                    Rp.
                                                    {{ number_format($product->price) }} </div>
                                                
                                            </div>
                                        @else
                                            <div class="price" style="font-size: 24px">Rp.
                                                {{ number_format($product->price) }}
                                            </div>
                                        @endif
                                        <div class="col-md-3 mt-4">
                                            <div class="d-flex align-items-center">
                                                <div class="input-group product-qty">
                                                    <span class="input-group-btn">
                                                        <button type="button"
                                                            style="border-top-right-radius: 0px; border-bottom-right-radius: 0px"
                                                            class="quantity-left-minus btn btn-danger btn-number"
                                                            data-type="minus">
                                                            -
                                                        </button>
                                                    </span>
                                                    <input type="text" style="width: 20px !important; margin: 0px 0px"
                                                        id="quantity" name="amount" class="form-control input-number"
                                                        value="1">
                                                    <span class="input-group-btn">
                                                        <button type="button"
                                                            style="border-top-left-radius: 0px; border-bottom-left-radius: 0px"
                                                            class="quantity-right-plus btn btn-success btn-number"
                                                            data-type="plus">
                                                            +
                                                        </button>
                                                    </span>
                                                </div>
                                            </div>
                                            
                                        </div>
                                        <div class="col-md-5">
                                          <div class="mt-4">
                                                <button class="w-100 btn btn-primary btn-md" type="submit">Masukkan
                                                    Keranjang
                                                    <iconify-icon icon="uil:shopping-cart"></button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
@endsection
