@props([
    'subtotal' => 0,
    'total' => 0,
    'savings' => session('use_point'),
    'tax' => 0,
    'showEdit' => false,
    'editUrl' => null,
    'showItems' => false,
    'items' => [],
])

<div class="bg-body-tertiary rounded-5 p-4 mb-3">
    <div class="p-sm-2 p-lg-0 p-xl-2">
        <div class="border-bottom pb-4 mb-4">
            <div class="d-flex align-items-center justify-content-between mb-4">
                <h5 class="mb-0">{{ __('cart_summary.title') }}</h5>
                @if ($showEdit && $editUrl)
                    <div class="nav">
                        <a class="nav-link text-decoration-underline p-0"
                            href="{{ $editUrl }}">{{ __('cart_summary.edit') }}</a>
                    </div>
                @endif
            </div>
            @if ($showItems && count($items) > 0)
                <a class="d-flex align-items-center gap-2 text-decoration-none" href="#orderPreview"
                    data-bs-toggle="offcanvas">
                    @foreach ($items->take(3) as $item)
                        <div class="ratio ratio-1x1" style="max-width: 64px">
                            <img src="{{ $item->image_url ?? '/img/shop/electronics/thumbs/08.png' }}"
                                class="d-block p-1" alt="{{ $item->name ?? 'Product' }}">
                        </div>
                    @endforeach
                    <i class="ci-chevron-right text-body fs-xl p-0 ms-auto"></i>
                </a>
            @endif
        </div>
        <ul class="list-unstyled fs-sm gap-3 mb-0">
            <li class="d-flex justify-content-between">
                <div>{{ __('cart_summary.subtotal') }} ({{ __('cart_summary.items_count', ['count' => auth()->check() ? \App\Repositories\Member\Cart\MemberCartRepository::getCount() : 0]) }})</div>
                <span class="text-dark-emphasis fw-medium" id="cart-subtotal">Rp
                    {{ number_format($subtotal, 0, ',', '.') }}</span>
            </li>
            <li class="d-flex justify-content-between">
                {{ __('cart_summary.savings') }}:
                <span class="text-danger fw-medium">Rp {{ number_format($savings, 0, ',', '.') }}</span>
            </li>
            {{-- <li class="d-flex justify-content-between" id="tax-row"
                @if ($tax <= 0) style="display: none;" @endif>
                {{ __('cart_summary.tax_collected') }}:
                <span class="text-dark-emphasis fw-medium">Rp {{ number_format($tax, 0, ',', '.') }}</span>
            </li> --}}
            <li class="d-flex justify-content-between" id="shipping-row">
                {{ __('cart_summary.shipping') }}:
                <span class="text-dark-emphasis fw-medium">{{ __('cart_summary.calculated_at_checkout') }}</span>
            </li>
        </ul>
        <div class="border-top pt-4 mt-4">
            <div class="d-flex justify-content-between mb-3">
                <span class="fs-sm">{{ __('cart_summary.estimated_total') }}:</span>
                <span class="h5 mb-0" id="cart-estimated-total">Rp {{ number_format($total, 0, ',', '.') }}</span>
            </div>

        </div>
    </div>
</div>
