@extends('eliteadmin::layouts.app')

@section('title', 'My Account')

@section('content')
    <div class="page-header">
        <div>
            <h1 class="page-title">Welcome, {{ auth()->user()->name }}</h1>
            <nav class="breadcrumb">
                <span class="breadcrumb-item active">My Account</span>
            </nav>
        </div>
    </div>

    @if ($modules === [])
        <div class="alert alert-info">
            Your account is active, but no modules have been assigned yet. Please contact an administrator to grant access.
        </div>
    @else
        <div class="row g-4">
            @foreach ($modules as $module)
                <div class="col-md-6 col-xl-4">
                    <div class="card h-100">
                        <div class="card-body d-flex flex-column">
                            <div class="d-flex align-items-center gap-3 mb-3">
                                <div class="rounded-circle bg-primary-subtle text-primary d-flex align-items-center justify-content-center"
                                     style="width: 48px; height: 48px;">
                                    <i class="{{ $module['icon'] }} fs-5"></i>
                                </div>
                                <div>
                                    <h5 class="mb-0">{{ $module['name'] }}</h5>
                                    @if (! empty($module['description']))
                                        <p class="text-muted small mb-0">{{ Str::limit($module['description'], 80) }}</p>
                                    @endif
                                </div>
                            </div>
                            <div class="mt-auto">
                                <a href="{{ route($module['route']) }}" class="btn btn-primary btn-sm">
                                    Open {{ $module['name'] }}
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            @endforeach
        </div>
    @endif

    <div class="card mt-4">
        <div class="card-body d-flex flex-wrap justify-content-between align-items-center gap-2">
            <div>
                <h5 class="mb-1">Account settings</h5>
                <p class="text-muted small mb-0">Update your profile details or change your password.</p>
            </div>
            <a href="{{ route('profile.edit') }}" class="btn btn-outline-primary btn-sm">Manage Profile</a>
        </div>
    </div>
@endsection
