@extends('site.layouts.site-layout')

@section('title', 'آدرس های من')

@section('content')

<div class="bread-crumb pt-3">
    <div class="container-fluid">
        <div class="content-box">
            <div class="container-fluid">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb mb-0">
                        <li class="breadcrumb-item"><a href="{{ route('home') }}" class="font-14 text-muted">خانه</a></li>
                        <li class="breadcrumb-item"><a href="{{ route('panel.index') }}" class="font-14 text-muted">پنل کاربری</a></li>
                        <li class="breadcrumb-item active main-color-one-color font-14" aria-current="page">آدرس های من</li>
                    </ol>
                </nav>
            </div>
        </div>
    </div>
</div>

<div class="content">
    <div class="container-fluid">

        {{-- mobile sidebar --}}
        <div class="custom-filter d-lg-none d-block">
            <button class="btn btn-filter-float border-0 main-color-two-bg shadow-box px-4 rounded-3 position-fixed"
                style="z-index:999;bottom:80px;" type="button"
                data-bs-toggle="offcanvas" data-bs-target="#panelSideCanvas" aria-controls="panelSideCanvas">
                <i class="bi bi-list font-20 fw-bold text-white"></i>
                <span class="d-block font-14 text-white">منو</span>
            </button>
            <div class="offcanvas offcanvas-start" tabindex="-1" id="panelSideCanvas">
                <div class="offcanvas-header">
                    <h5 class="offcanvas-title">منو پنل</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
                </div>
                <div class="offcanvas-body">
                    <div class="panel-side">
                        <div class="content-box pb-0">
                            <div class="container-fluid">@include('panel._sidebar')</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="dashboard-panel">
            <div class="row gy-3">

                <div class="col-lg-3 d-lg-block d-none">
                    <div class="panel-side">
                        <div class="content-box pb-0">
                            <div class="container-fluid">@include('panel._sidebar')</div>
                        </div>
                    </div>
                </div>

                <div class="col-lg-9">

                    @if (session('success'))
                        <div class="alert alert-success alert-dismissible fade show mb-3" role="alert">
                            {{ session('success') }}
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                        </div>
                    @endif

                    <div class="content-box">
                        <div class="container-fluid">
                            <div class="title-panel d-flex align-items-center justify-content-between">
                                <h6 class="font-16">آدرس های من</h6>
                                <a href="{{ route('panel.addresses.create') }}"
                                   class="btn btn-sm border-0 main-color-one-bg waves-effect waves-light px-3">
                                    <i class="bi bi-plus-lg text-white me-1"></i>افزودن آدرس
                                </a>
                            </div>

                            @forelse ($addresses as $index => $addr)
                                <div class="address-card mb-3 p-3 border rounded-3 bg-light">
                                    <div class="d-flex align-items-start justify-content-between">
                                        <div class="d-flex align-items-center gap-2 mb-2">
                                            <span class="badge main-color-one-bg font-13">{{ $addr->name }}</span>
                                            <span class="text-muted font-13">
                                                <i class="bi bi-geo-alt me-1"></i>{{ $addr->province }} &ndash; {{ $addr->city }}
                                            </span>
                                        </div>
                                        <span class="text-muted font-12"># {{ $index + 1 }}</span>
                                    </div>
                                    <p class="mb-1 font-14 text-dark">{{ $addr->address }}</p>
                                    <div class="d-flex align-items-center gap-3 mt-2">
                                        <span class="font-13 text-muted">
                                            <i class="bi bi-mailbox me-1"></i>کد پستی: {{ $addr->postal_code }}
                                        </span>
                                    </div>
                                </div>
                            @empty
                                <div class="text-center py-5 text-muted">
                                    <i class="bi bi-pin-map font-40 d-block mb-2"></i>
                                    <p class="font-14 mb-0">هنوز آدرسی ثبت نکرده‌اید.</p>
                                </div>
                            @endforelse

                        </div>
                    </div>

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

    </div>
</div>

@endsection
