@extends('backoffice.layouts.app')

@section('contents')
    <div class="container-fluid mt-4">
        <h4 class="mb-4">User Profile</h4>
          <div class="table-responsive">
        <table class="table table-bordered table-striped">
            <thead class="table-dark">
                <tr>
                    <th>User</th>
                    <th>Details</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>User Name</td>
                    <td>{{ $user->real_name ?? '' }}</td>
                </tr>
                <tr>
                    <td>Nick Name</td>
                    <td>{{ $user->nickname ?? '' }}</td>
                </tr>
                <tr>
                    <td>Phone</td>
                    <td>{{ $user->phone_country_code ?? '' }} {{ $user->phone_number ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Gender</td>
                    <td>{{ $user->gender ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Country</td>
                    <td>{{ $user->country ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Address</td>
                    <td>{{ $user->address ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>City</td>
                    <td>{{ $user->city ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Profile Photo</td>
                    <td>
                        @if (!empty($user->profile_photo))
                            <img src="{{ asset('website/uploads/profile_images/' . $user->profile_photo) }}"
                                alt="Profile Photo" width="80">
                        @else
                            N/A
                        @endif
                    </td>
                </tr>
                <tr>
                    <td>Verification Status</td>
                    <td>{{ $user->verification_status ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Book Name</td>
                    <td>{{ $user->book_name ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Author Name</td>
                    <td>{{ $user->author_name ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Short Description</td>
                    <td>{{ $user->short_description ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Favorite Quotes</td>
                    <td>{{ $user->favorite_quotes ?? 'N/A' }}</td>
                </tr>
                <tr>
                    <td>Book Cover</td>
                    <td>
                        @if (!empty($user->book_cover))
                            <img src="{{ asset('website/uploads/book_covers/' . $user->book_cover) }}" alt="Book Cover"
                                width="80">
                        @else
                            N/A
                        @endif
                    </td>
                </tr>
                <tr>
                    <td>Profile Likes</td>
                    <td>{{ $user->prfile_likes ?? '0' }}</td>
                </tr>
                <tr>
                    <td>Book Likes</td>
                    <td>{{ $user->book_likes ?? '0' }}</td>
                </tr>
            </tbody>
        </table>
          </div>
        <hr>
        <h4>User Subscriptions</h4>
        <table class="table table-bordered">
            <thead class="table-secondary">
                <tr>
                    <th>Plan Name</th>
                    <th>Start Date</th>
                    <th>End Date</th>
                </tr>
            </thead>
            <tbody>
                @if ($subscriptions->isEmpty())
                    <tr>
                        <td colspan="4">No subscriptions found.</td>
                    </tr>
                @else
                    @foreach ($subscriptions as $sub)
                        <tr>
                            <td>{{ Str::title($sub->subscription_type) ?? '-' }}</td>
                            <td>{{ $sub->subscription_start ? \Carbon\Carbon::parse($sub->subscription_start)->format('Y-m-d') : '-' }}
                            </td>
                            <td>{{ $sub->subscription_end ? \Carbon\Carbon::parse($sub->subscription_end)->format('Y-m-d') : '-' }}
                            </td>
                        </tr>
                    @endforeach
                @endif
            </tbody>
        </table>
    </div>
@endsection
