# Development Phases & Roadmap

## Phase 1: Environment & Core Setup [COMPLETED]
- [x] Initialized Laravel 13 framework.
- [x] Configured MySQL / SQLite database connectivity with socket support (`/tmp/mysql.sock`).
- [x] Installed & configured Filament v3 Multi-Panel (`AdminPanelProvider.php` & `VendorPanelProvider.php`).
- [x] Set up dev environment scripts in `composer.json` (`composer run dev`).

## Phase 2: Database Models & Migrations [COMPLETED]
- [x] Created `products` table migration (with `user_id`, `is_active`, and `is_featured` flags) and `Product` Eloquent model.
- [x] Created `users` table migration (with `role` and `is_approved` flags) and `User` Eloquent model with `FilamentUser` implementation.
- [x] Created `orders` table migration and `Order` Eloquent model with `$guarded = []` and `product()` relation.
- [x] Seeded initial Admin (`admin@admin.com`), Vendor (`vendor@vendor.com`), and Customer (`customer@customer.com`) users.

## Phase 3: Admin & Vendor Panels (Filament Resources) [COMPLETED]
- [x] Generated `ProductResource` (`php artisan make:filament-resource Product`) for Admin & Vendor panels.
- [x] Created dedicated Vendor Panel (`php artisan make:filament-panel vendor`) accessible at `/vendor` with Emerald theme (`#10B981`).
- [x] Built custom Vendor Overview widgets: `VendorStatsOverview` (Total Earnings, Prompts Sold, Active Listings, Pending Approvals), `VendorRevenueChart` (Monthly Sales Revenue Trend Chart), and `VendorRecentSales` (Recent Transactions Table).
- [x] Created dedicated Vendor resources: `App\Filament\Vendor\Resources\ProductResource` and `VendorSalesResource` (Sales & Earnings transaction history).
- [x] Created `VendorRegister` page (`/vendor/register`) for vendor self-registration with automatic `vendor` role assignment.
- [x] Implemented custom dark-themed split-screen login page (`resources/views/auth/custom-login.blade.php`) using Tailwind CSS CDN for zero-dependency styling.
- [x] Implemented `canAccessPanel(Panel $panel)` strict panel access control in `User.php` and `canViewAny()` in `UserResource.php`.
- [x] Implemented strict vendor query scoping in `ProductResource::getEloquentQuery()` and `VendorSalesResource::getEloquentQuery()` (`where('user_id', auth()->id())`).

## Phase 4: Controllers & Web Routing [COMPLETED]
- [x] Updated `ProductController@index` to query 4 distinct sections (`$featuredPrompts`, `$trendingPrompts`, `$newestPrompts`, `$popularPrompts`).
- [x] Created `ProductController` with `index`, `show`, `checkout`, `success`, and `reveal` methods.
- [x] Implemented `AuthController` methods `showAdminLoginForm()`, `showVendorLoginForm()`, `adminLogin()`, and `vendorLogin()`.
- [x] Defined named Filament login routes in `routes/web.php` (`filament.admin.auth.login` and `filament.vendor.auth.login`) to ensure seamless Filament logout & session timeout compatibility.
- [x] Created `StripeWebhookController` for handling async `checkout.session.completed` events.
- [x] Defined clean RESTful web routes in `routes/web.php`.

## Phase 5: Blade Frontend Views & PromptBase UI Redesign [COMPLETED]
- [x] Created `layouts/app.blade.php` (PromptBase dark header `#0B0F19`, Categories dropdown, navigation, Upgrade CTA button).
- [x] Created `products/index.blade.php` (Hero section, search bar, social proof, 4 quick access cards, and 4 sectioned prompt collections: Featured, Trending, Newest, Most Popular).
- [x] Created `products/show.blade.php` (2-Column sticky sidebar layout for product details & Stripe payment form).
- [x] Created `products/reveal.blade.php` (Dark terminal box for prompt reveal with 1-click copy button).

## Phase 6: Stripe Payment Integration [COMPLETED]
- [x] Installed `stripe/stripe-php` package via Composer.
- [x] Configured `STRIPE_KEY`, `STRIPE_SECRET`, and `STRIPE_WEBHOOK_SECRET` in `.env` and `config/services.php`.
- [x] Implemented Checkout Session creation and webhook signature validation.

## Phase 7: Vendor Settings, Billing & Withdrawal System [COMPLETED]
- [x] Created `vendor_settings` migration and `VendorSetting` Eloquent model for personal, location, and NID/passport details.
- [x] Created `vendor_payouts` migration and `VendorPayout` Eloquent model for payout request tracking.
- [x] Built Vendor Settings page (`/vendor/settings`) with country, city, address, zip code, NID number, and date of birth form fields. *(Later removed — these fields now live in the `Personal & Location` tab of the `/vendor/profile` singleton; `VendorSettings.php` was deleted in the Phase 25/30 cleanup.)*
- [x] Built Vendor Billing & Payouts page (`/vendor/billing`) with payment destination setup (Bank Transfer, bKash/Nagad, PayPal, Crypto USDT Wallet).
- [x] Integrated real-time earnings & available balance calculations (`available_balance = total_sales - total_requested_payouts`).
- [x] Implemented **Initiate Withdrawal** action modal with minimum-threshold validation. *($50 at the time; now `MARKETPLACE_MIN_WITHDRAWAL` env, default $20 via `config/marketplace.php`.)*
- [x] Built Payout History Filament table on Vendor Billing page.
- [x] Generated Admin Payout Management resource (`PayoutResource` at `/admin/payouts`) with approval & rejection actions and vendor identity preview modals.
- [x] Integrated `Settings` (`heroicon-o-cog-6-tooth`) and `Billing & Payouts` (`heroicon-o-banknotes`) into `VendorPanelProvider.php` top-right profile dropdown menu (`userMenuItems`).

## Phase 8: Database Connection Fix & Schema Synchronization [COMPLETED]
- [x] Fixed MySQL database connection (`DB_PORT=3306` and cleared obsolete `.env` socket configs).
- [x] Cleared Laravel configuration cache (`php artisan config:clear`).
- [x] Executed fresh database migrations & seeders (`php artisan migrate:fresh --seed`), restoring `is_featured`, `is_active`, `user_id`, and vendor verification table schemas.
- [x] Verified marketplace listing queries (`Product::where('is_featured', true)`) and seeded 50 prompt products and 3 system users.

## Phase 9: PHP Extension Configuration & Runtime Setup [COMPLETED]
- [x] Configured PHP `intl` extension in XAMPP `php.ini` to fix `Number::format` exception in Filament tables.
- [x] Enabled `gd`, `zip`, and `fileinfo` PHP extensions for full Filament and Laravel asset handling compatibility.
- [x] Verified runtime CLI & web server compatibility under PHP 8.2 / 8.3.

## Phase 10: Vendor Panel Route Restructuring & UI Enhancements [COMPLETED]
- [x] Created custom Vendor Dashboard page (`App\Filament\Vendor\Pages\Dashboard`) registered at `/vendor/dashboard` with `$routePath = '/dashboard'` and `$slug = 'dashboard'`.
- [x] Added automatic route redirection from `/vendor` to `/vendor/dashboard` in `routes/web.php`.
- [x] Preserved dedicated vendor routes intact: `/vendor/products`, `/vendor/sales-and-earnings`, `/vendor/billing`, `/vendor/vendor-profile`.
- [x] Configured collapsible/toggleable sidebar navigation via `->sidebarCollapsibleOnDesktop()`.
- [x] Enforced native dark theme via `->darkMode(...)` across Admin and Vendor panels (automatically hiding theme switcher and enforcing Filament dark engine). *(Current state: Admin = `isForced: true` + forced `.dark` render hook; Vendor = `isForced: false` — see Phase 33.)*
- [x] Created complete dark theme stylesheet (`public/css/filament/theme.css`) covering all stats widgets, cards, charts, forms, inputs, tables, dropdowns, and modals in `#0B0F19` background, `#111827` surface cards, and `#10B981` Emerald accents.
- [x] Updated `resources/views/filament/vendor/pages/vendor-billing.blade.php` to full `#111827` / `#1F2937` dark theme classes.

## Phase 11: Community Engagement & Seller Mapping [COMPLETED]
- [x] Created database migrations for `follows`, `favorites`, and `reviews` tables.
- [x] Created Eloquent models: `Follow`, `Favorite`, `Review` with relationship methods and scopes.
- [x] Updated `User` model with `followers()`, `following()`, `favoriteProducts()`, `reviewsGiven()`, `reviewsReceived()`, `averageVendorRating()`, and `isFollowedBy()`.
- [x] Updated `Product` model with `reviews()`, `favoritedBy()`, `averageRating()`, and `reviewsCount()`.
- [x] Created `EngagementController` and registered AJAX routes for follow/unfollow, favorite/wishlist, and review submissions.
- [x] Enhanced public seller profile (`/seller/{user}`) with dynamic follower count, AJAX follow button, average rating stars, and tabs for Prompts Collection & Customer Reviews.
- [x] Built reusable product card partial (`product-card.blade.php`) with heart wishlist buttons and average star rating badges across all catalog grids.
- [x] Enhanced single product view (`/product/{slug}`) with favorite toggle button and customer reviews breakdown section with 1-5 star submission form.
- [x] Added **Total Followers** and **Average Rating** metrics to Vendor Dashboard (`VendorStatsOverview`).
- [x] Built **My Followers** table page (`VendorFollowers`) in Vendor Panel.
- [x] Built **Customer Reviews** table resource (`VendorReviewResource`) in Vendor Panel.
- [x] Added Seller/Creator avatar column and direct profile action link to Admin `ProductResource`.
- [x] Built Admin Review Moderation resource (`ReviewResource`) with quick approve/reject actions.

## Phase 12: Customer Dashboard & Profile Management [COMPLETED]
- [x] Created database migration `add_user_id_to_orders_table` and updated `Order` and `User` models with `user()` and `orders()` relationships.
- [x] Updated `ProductController::checkout` to link `user_id` when authenticated users purchase prompts.
- [x] Created `CustomerController` with `library()`, `favorites()`, `following()`, `profile()`, and `updateProfile()` methods.
- [x] Registered customer dashboard routes in `routes/web.php` with `auth` middleware.
- [x] Built interactive Navbar User Profile Dropdown in `layouts/app.blade.php` using Alpine.js.
- [x] Built Customer Purchased Library page (`/my-library`) with prompt reveal keys and 1-5 star review submission dialogs.
- [x] Built Saved Favorites page (`/my-favorites`) with instant wishlist heart toggle.
- [x] Built Followed Sellers page (`/following`) with creator cards and AJAX unfollow action.
- [x] Built Customer Account Settings & Profile page (`/customer/profile`) with avatar upload and password change form.

## Phase 13: Vendor Dashboard Interactive Card Navigation [COMPLETED]
- [x] Added dedicated **Pending Prompts** overview card counting prompts with `status = 'pending'`.
- [x] Made all overview cards on `/vendor/dashboard` clickable with direct URL routing & table filters:
  - **Total Earnings**: Navigates to Sales & Earnings (`VendorSalesResource`).
  - **Total Prompts Sold**: Navigates to completed transactions filtered by `status = 'paid'`.
  - **Active Prompts**: Navigates to approved & live prompts (`status = 'approved'`).
  - **Pending Prompts**: Navigates to prompts pending review (`status = 'pending'`).
  - **Total Followers**: Navigates to My Followers page (`VendorFollowers`).
  - **Average Rating**: Navigates to Customer Reviews (`VendorReviewResource`).
- [x] Added `Tables\Actions\ViewAction` to `ProductResource` for instant prompt details inspection.
- [x] Added smooth hover styling and emerald glow transitions in `theme.css` for clickable stat cards.

## Phase 14: Performance Optimization & Dedicated Upload Prompt Portal [COMPLETED]
- [x] Created performance index migration `add_performance_indexes_to_tables` adding composite indexes on `orders`, `products`, `reviews`, `follows`, `favorites`, and `vendor_payouts`.
- [x] Enabled Lazy Loading (`protected static bool $isLazy = true;`) on all dashboard widgets.
- [x] Consolidated database aggregates and applied `Cache::remember()` caching in `VendorStatsOverview` and `VendorRevenueChart`.
- [x] Eliminated N+1 queries in `VendorRecentSales` via eager loading `with(['product', 'user'])`.
- [x] Added database columns `ai_model`, `category`, `instructions`, and `preview_video` to `products` table.
- [x] Created dedicated Prompt Upload page `App\Filament\Vendor\Pages\UploadPrompt` registered at `/vendor/upload` with icon `heroicon-o-plus-circle`.
- [x] Built multi-section form with real-time slug generator, model/category selection, encrypted prompt payload, usage instructions, cover image editor, and video preview.
- [x] Configured auto-assignment of `user_id = auth()->id()`, initial `status = 'pending'`, `is_active = false`, and redirect with success notification to `/vendor/products`.

## Phase 15: Product Code (Item ID) & SEO-Friendly Slug System [COMPLETED]
- [x] Added `product_code` column (`VARCHAR(50)`, unique, indexed) to `products` table and backfilled all existing products with unique `PRD-XXXXXX` IDs.
- [x] Implemented `creating` & `updating` model lifecycle hooks in `Product.php` to auto-generate unique `PRD-XXXXXX` codes and clean SEO slugs.
- [x] Integrated `product_code` with copyable badge and global search in Admin `ProductResource`.
- [x] Integrated `product_code` with copyable badge and search in Vendor `ProductResource`.
- [x] Updated Frontend Search in `ProductController@index` to search across `product_code`, `title`, `description`, `category`, and `ai_model`.
- [x] Implemented Smart Route Resolution via `Product::resolveRouteBinding()` allowing lookups by both slug (`/product/slug`) and Product Code (`/product/PRD-XXXXXX`).
- [x] Displayed copyable Item ID badges on Product Details page (`show.blade.php`) and Customer Library (`library.blade.php`).

## Phase 16: Support Ticket System & Real-Time Notification Bell [COMPLETED]
- [x] Created `tickets` and `ticket_messages` database tables and migrated Laravel database `notifications` table.
- [x] Created `Ticket` and `TicketMessage` Eloquent models with automatic `TCK-XXXXXX` ID generation and User relationships.
- [x] Built Vendor Support Ticket Resource (`/vendor/tickets`) with List View, Open Ticket creation form, and interactive conversational thread UI (`ViewTicket.php`).
- [x] Built Admin Support Management Resource (`/admin/tickets`) with global view, priority filtering, and administrative response dispatching.
- [x] Configured real-time Header Notification Bell (`->databaseNotifications()->databaseNotificationsPolling('30s')`) in both `VendorPanelProvider.php` and `AdminPanelProvider.php`.
- [x] Implemented real-time notification dispatching on Admin replies, prompt approvals/rejections, KYC verification updates, and payout processing.
- [x] Refined Support Ticket View UI with soft badge pills, dark message cards (`#111827` / `#131d33`), elimination of harsh white borders, and smart Ticket ID URL routing (`/vendor/tickets/TCK-XXXXXX`).

## Phase 17: Real-Time Event Observers & Dynamic Sidebar Badges System [COMPLETED]
- [x] Migrated `last_read_sales_at`, `last_read_reviews_at`, and `last_read_followers_at` timestamp tracking columns to `users` table.
- [x] Created Model Observers:
  - `FollowObserver`: Dispatches instant notification when a customer follows a vendor.
  - `OrderObserver`: Dispatches instant sale alert when a customer buys a prompt (`status === 'paid'`).
  - `ReviewObserver`: Dispatches notification when a customer reviews a prompt or vendor profile.
  - `ProductObserver`: Dispatches notifications when a prompt is submitted for review, approved, or rejected.
  - `TicketMessageObserver`: Dispatches notifications on administrative and vendor responses.
- [x] Configured `AppServiceProvider.php` to register all 5 model observers.
- [x] Configured `QUEUE_CONNECTION=sync` for immediate, real-time database notification delivery.
- [x] Added dynamic unread badge counters to Vendor Panel navigation:
  - **My Prompts (`ProductResource`)**: Displays pending review prompt count with `warning` badge.
  - **Sales & Earnings (`VendorSalesResource`)**: Displays unviewed sale count with `success` badge.
  - **Support Tickets (`TicketResource`)**: Displays answered tickets awaiting vendor reply with `success` badge.
  - **Customer Reviews (`VendorReviewResource`)**: Displays unviewed review count with `warning` badge.
  - **My Followers (`VendorFollowers`)**: Displays unviewed new followers count with `primary` badge.
- [x] Implemented View-to-Clear auto-reset mechanism across `ListProducts`, `ListVendorSales`, `ViewTicket`, `ListVendorReviews`, and `VendorFollowers` pages.
- [x] Enforced post-creation and post-edit automatic redirection (`getRedirectUrl()`) back to index across `CreateProduct`, `EditProduct`, `UploadPrompt`, and `CreateTicket`.
- [x] Enforced default descending latest-first sorting (`defaultSort('created_at'/'updated_at', 'desc')`) across all Vendor & Admin panel resource tables.
- [x] Added serial / row index numbering (`#`) across My Prompts, Sales & Earnings, Tickets, and Followers tables for clear sequential item counting.
- [x] Redesigned Vendor Followers page (`/vendor/vendor-followers`) with borderless dark surface aesthetic, vibrant gradient `Total Followers` badge with sparkle animation, and sequential `#` row index.

## Phase 18: Cloudflare R2 Object Storage (S3-Compatible) Integration [COMPLETED]
- [x] Installed and configured `league/flysystem-aws-s3-v3` package.
- [x] Defined `r2` disk configuration in `config/filesystems.php` (`key`, `secret`, `bucket`, `endpoint`, `url`, `region => 'auto'`).
- [x] Added `CLOUDFLARE_R2_*` environment variables template in `.env` and `.env.example`.
- [x] Configured Livewire temporary upload storage to `'local'` disk in `config/livewire.php` to prevent browser pre-signed upload failures.
- [x] Applied S3 CORS policy (`AllowedOrigins: *`, `GET, HEAD, PUT, POST, DELETE`) on Cloudflare R2 bucket for seamless FilePond preview rendering.
- [x] Updated all Filament `FileUpload` components across `ProductResource`, `UploadPrompt`, `VendorProfile`, `UserResource`, and `TicketResource` to direct to R2 / public storage with structured directories (`prompts/covers`, `prompts/videos`, `users/avatars`, `users/documents`, `tickets/attachments`) and public visibility.
- [x] Implemented smart public URL model accessors (`$product->cover_image_url`, `$product->preview_video_url`, `$user->avatar_url`, `$user->id_document_url`, `$ticketMessage->attachment_url`) to deliver CDN-backed assets with graceful fallback.
- [x] Updated Blade templates across Explore, Product Details, Library, Seller Profiles, and Ticket conversation threads.

## Phase 19: Table UX, Title Truncation & Dedicated Actions Column [COMPLETED]
- [x] Enforced 3-word title truncation (`->words(3)`) on Prompt Title columns across Vendor Products (`/vendor/products`), Vendor Sales (`/vendor/sales-and-earnings`), and Admin Products (`/admin/products`).
- [x] Added hover tooltips (`->tooltip()`) to truncated title columns for full visibility without table layout breaking.
- [x] Added clean inline icon action buttons (`ViewAction`, `EditAction`, `DeleteAction` with tooltips and right-alignment) to Vendor Products table (`ProductResource.php`).
- [x] Added clean inline icon action buttons (`ViewAction`, `EditAction`, Quick `Approve`, Quick `Reject`, and `DeleteAction` with confirmation modals and right-alignment) to Admin Products table (`ProductResource.php`).
- [x] Disabled accidental row-clicking by setting `->recordUrl(null)` and `->recordAction(null)` so that operations strictly execute only on clicking explicit action icons.

## Phase 20: All-in-One Financial & Order Management Hub (`/vendor/sales-and-earnings`) [COMPLETED]
- [x] Streamlined `/vendor/sales-and-earnings` into a clean, full-width dedicated Orders & Earnings table.
- [x] Embedded scoped Orders table (`whereHas('product', fn($q) => $q->where('user_id', auth()->id()))`) with columns:
  - Row Index (`#`)
  - Order ID (`#ORD-XXXX`) with badge, copyable, and searchable
  - Product Item ID (`PRD-XXXXXX`) & Prompt Title (3-word truncated with tooltip)
  - Buyer Info (Customer name & email)
  - Total Amount ($)
  - Net Vendor Cut (80% net earnings badge)
  - Status badge (`paid`, `pending`, `failed`)
  - Transaction Date (`M d, Y • h:i A`)
- [x] Disabled accidental row-clicking with `recordUrl(null)` and right-aligned View Action button.
- [x] Verified zero redundant "Orders" links in vendor sidebar navigation, establishing `/vendor/sales-and-earnings` as the single unified financial center.

## Phase 21: Engaging Dashboard Charts & Visual Analytics [COMPLETED]
- [x] Embedded dynamic mini sparkline trend charts across all 6 `VendorStatsOverview` cards (Total Earnings, Total Prompts Sold, Active Prompts, Pending Prompts, Total Followers, Average Rating).
- [x] Upgraded `VendorRevenueChart` to an area chart with dual metrics: Gross Sales ($) and 80% Net Vendor Cut ($).
- [x] Created `VendorSalesDistributionChart` (Doughnut Chart) displaying sales & inventory distribution across AI Models (Midjourney, ChatGPT, Gemini, DALL-E, Claude, Veo, Flux).
- [x] Structured side-by-side balanced 2-column grid layout beneath the metric cards on `/vendor/dashboard`.

## Phase 22: Flexible Profile Management & Enhanced KYC Verification Reminders [COMPLETED]
- [x] Made Location (Tab 2) and KYC Identity Verification (Tab 3) fields optional during general profile saves, removing blocking validation constraints so vendors can create, update, and save their profile (Name, Avatar, Headline, Bio, Social links) instantly.
- [x] Preserved verification states seamlessly during profile updates without resetting verified sellers to pending.
- [x] Streamlined top status banner on `/vendor/vendor-profile`: automatically hides when verification is complete (`isVerified`), displaying action/reminder banners only for unverified/pending/rejected accounts.
- [x] Added official verified checkmark badge (`heroicon-s-check-badge`) overlaid directly on the profile avatar/icon for verified sellers.
- [x] Implemented `HasAvatar` interface on `User` model to integrate avatars seamlessly into Filament navigation and user menus.
## Phase 23: Dynamic Real-Time Public Seller Profile Filtering & Sorting (`/seller/{id}`) [COMPLETED]
- [x] Implemented real-time dynamic filter and sorting toolbar for the "Prompts by Vendor" tab on public seller profiles (`/seller/{id}` and `/seller/{username}`).
- [x] Added Sort By dropdown supporting `newest` (default), `oldest`, `popular` (total sales count), `top_rated` (avg review rating), `price_low`, and `price_high`.
- [x] Added Pricing Type filter pills (`All`, `Paid`, `Free`).
- [x] Added Category and AI Model filter dropdowns with dynamic multi-category filtering (Art & Design, Marketing, Coding, Photography, 3D, Anime, etc.).
- [x] Added debounce instant search input with clear button.
- [x] Built seamless AJAX partial grid rendering (`sellers/partials/prompts-grid.blade.php`) and Alpine.js async updates without page reloads, preserving browser URL history with `pushState`.
- [x] Created empty state card with filter reset button when no prompts match.

## Phase 24: Seller Unique ID (`VND-XXXXXX`), Topbar Verified Avatar Badge & Admin Panel KYC Dynamics [COMPLETED]
- [x] Streamlined `/vendor/vendor-profile` header: kept only the "View Public Profile" button along with the Seller Unique ID, removing redundant preview cards.
- [x] Placed an official emerald verified checkmark tick badge (`✓`) directly on the top navigation bar user menu avatar (`.fi-avatar`) for verified vendors.
- [x] Created automatic unique **Seller ID** (`seller_code` in format `VND-XXXXXX`) generated for every user/vendor in `User` model booted hook.
- [x] Added `seller_code` database migration and backfilled all existing sellers/users with unique IDs.
- [x] Updated route model binding on `User` to resolve seller profiles via both numeric ID (`/seller/2`) and Seller ID (`/seller/VND-334901`).
- [x] Configured `/vendor/vendor-profile/{id}` and `/vendor/vendor-profile/{seller_code}` route parameters on `VendorProfile` page with auto-binding and security scoping to the authenticated vendor. *(Superseded in Phase 25 — the page is now the parameterless singleton `Profile` at `/vendor/profile`.)*
- [x] Fully integrated dynamic User/Vendor management into the Admin panel (`UserResource.php`):
  - Searchable, sortable, copyable Seller ID column.
  - Quick "Public Profile" link action.
  - "View ID" modal action with inline document viewer (NID/Passport) and direct download.
  - One-click "Approve KYC" and "Reject KYC" (with rejection reason note) actions triggering database notifications.

## Phase 25: Clean Vendor Profile Singleton (`/vendor/profile`) & Public Username Routing (`/seller/{user:username}`) [COMPLETED]
- [x] Converted the Vendor Profile page into a clean singleton custom Filament page (`App\Filament\Vendor\Pages\Profile.php`) with `protected static ?string $slug = 'profile';`.
- [x] Removed numeric ID parameters completely from vendor private profile URLs (access now directly via `/vendor/profile`).
- [x] Form automatically binds directly to `auth()->user()` without requiring URL parameters.
- [x] Added `username` database migration and auto-generation in `User::booted()` (slugged from user name e.g. `demo-vendor`, `john-doe-2`).
- [x] Backfilled all existing users with unique indexed usernames.
- [x] Updated public creator storefront route in `routes/web.php` to `Route::get('/seller/{user:username}', [SellerController::class, 'show'])->name('seller.show');`.
- [x] Updated follow and review routes to `{user:username}`.
- [x] Updated user menu items in `VendorPanelProvider.php` and notice widgets to use `Profile::getUrl()`.

## Phase 26: PromptBase-Style Hover & Quick Preview Modal Integration [COMPLETED]
- [x] Added global Alpine.js Quick Preview Modal component (`x-data="quickPreviewModal()"`) in `layouts/app.blade.php`.
- [x] Implemented backdrop blur overlay (`bg-black/80 backdrop-blur-md`) and perfectly balanced floating dark preview popover card (`max-w-[320px]`).
- [x] Integrated smooth 2-second hover flow (`@mouseenter.debounce.2000ms`) with 1000ms cubic-bezier transition animation (`cubic-bezier(0.16, 1, 0.3, 1) duration-1000`) for gradual, elegant popover opening.
- [x] Integrated top-right action buttons: Wishlist Heart (AJAX favorite toggle), External Product Page Link, and ESC/X Close button.
- [x] Integrated high-resolution preview image container with AI Model badge overlay.
- [x] Integrated floating bottom translucent pill box container (`absolute bottom-3 left-3 right-3`) displaying small cover thumbnail, title, AI model, price tag (`$X.XX`), and coral "View Details" CTA button.
- [x] Updated `resources/views/products/partials/product-card.blade.php` with 2-second mouse pointer hover trigger (`@mouseenter.debounce.2000ms`), top-right Favorite Heart Button (`top-2.5 right-2.5`), and Quick View overlay button.
- [x] Redesigned marketplace catalog grid (`products/index.blade.php`, `sellers/partials/prompts-grid.blade.php`) to 5-6 responsive columns (`grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4`) with compact card paddings (`p-3.5`) and refined typography matching PromptBase aesthetic.

## Phase 27: Vendor Free & Paid Prompt Pricing and Prompt Attachment Upload Support [COMPLETED]
- [x] Added `prompt_file` column migration and updated `prompt_text` column to nullable in `products` table.
- [x] Updated `Product` model with `isFree()`, `hasPromptFile()`, `hasPromptText()`, and `getPromptFileUrlAttribute()`.
- [x] Updated `UploadPrompt.php` and Filament Vendor/Admin `ProductResource.php` to support $0.00 prices and prompt package file uploads (.zip, .txt, .json, .pdf, .docx, .rar, .7z up to 100MB).
- [x] Updated `ProductController@checkout` to bypass Stripe for $0.00 free prompts, providing instant tokenized access.
- [x] Implemented secure tokenized file download route `/prompt/download/{token}` (`ProductController@downloadFile`).
- [x] Updated UI in `product-card.blade.php`, `show.blade.php`, `index.blade.php`, `app.blade.php`, `reveal.blade.php`, and `library.blade.php` to display `FREE 🎁` badges, instant claim buttons, and prompt file attachment download links.

## Phase 28: Roadmap Backlog [MOVED — see Phase 31]
- [x] Superseded by the documented phases below (29–30); the remaining backlog item moved to **Phase 31**.

## Phase 29: Nested Categories, Site Settings, Live Chat & Account Moderation [COMPLETED — documented retroactively]
- [x] Created the `categories` table (`parent_id`, `type`, `name`, `slug`, `icon`, `description`, `is_active`, `sort_order`) with the `Category` model and seeded ~1,500 rows via `CategorySeeder`.
- [x] Built Admin `CategoryResource` (`/admin/categories`, "Marketplace" group, `heroicon-o-tag`) with auto-slug generation and a Category Level (`type`) selector.
- [x] Built the Vendor `CategoryResource` plus inline category creation from product forms (`+` action creates and selects the new category instantly). *(Vendor resource removed in Phase 31 — categories are admin-only.)*
- [x] Added `products.sub_category` and `products.class_category`, wired into `ProductController@index` filters (`?sub_category=`, `?class_category=`) and the Admin/Vendor product forms.
- [x] Added `products.gallery_images` (array cast) with FileUpload support in `UploadPrompt` and both `ProductResource` copies.
- [x] Created the `site_settings` key/value table with `SiteSetting::get()/set()` and the **Community & Social Links** admin page (`ManageSiteSettings`, `/admin/site-settings`) storing `telegram_link`, `discord_link`, `community_title`, `community_description`.
- [x] Added the live-chat API (`SupportChatController` + `/chat/messages`, `/chat/send`) which finds or creates a `Ticket`, appends `TicketMessage` rows and notifies admins through `TicketMessageObserver`.
- [x] Added account moderation: `users.is_banned` + `ban_reason`, `User::isBanned()` checks in all three `AuthController` login flows, and `UserResource` ban toggle / column / filter / Ban action.
- [x] Extended KYC capture with `users.id_document_back` and `users.id_document_selfie`.
- [x] Added `VendorKycNoticeWidget` (top-of-dashboard KYC reminder) and `CustomLogoutResponse` (Filament logout → `/login`).
- [x] Added the `EnsureVendorIsVerified` middleware (restricts unverified vendors to `/vendor/profile`). *(Originally defined but unregistered; now registered in `VendorPanelProvider::authMiddleware()` — see Phase 33.)*

## Phase 30: Routing & Documentation Consolidation [COMPLETED — 2026-09-28]
- [x] Confirmed canonical storefront routing is `/seller/{user:username}`; numeric-ID (`/seller/2`) and Seller-Code (`/seller/VND-334901`) URLs return `404` (HTTP-verified).
- [x] Confirmed `/vendor/vendor-profile` 302-redirects to the singleton `/vendor/profile`; the parameterized variant was removed in Phase 25.
- [x] Audited every project document against the code and refreshed `README.md`, `architecture.md`, `database.md`, `security.md`, `error-handling.md`, `prompts.md` and this file (PHP/extension facts, route table, new tables/columns, platform notes).
- [x] Verified the runtime end-to-end: `composer run dev` boots serve/queue/pail/vite, `GET /` → `200`, `GET /seller/demo-vendor` → `200`, `php artisan test` → 2 passed.

## Phase 31: Vendor Panel Cleanup — Categories Made Admin-Only [COMPLETED — 2026-09-28]
- [x] Removed `app/Filament/Vendor/Resources/CategoryResource.php` and its `ManageCategories` page, eliminating the `/vendor/categories` route so category management now exists **only** in the admin panel (`/admin/categories`).
- [x] Verified through tinker that the vendor panel now discovers only `ProductResource`, `TicketResource`, `VendorReviewResource` and `VendorSalesResource`, while the admin panel still discovers `CategoryResource`.
- [x] Confirmed nothing referenced the removed class — inline category creation uses `Category::firstOrCreate` inside `UploadPrompt`, and the vendor product form only reads `Category::main()/sub()/class()` options — so prompt upload/edit flows are unaffected.
- [x] HTTP-verified after the change: `/vendor/categories` → `404`, `/admin/categories` → `302` (guest → login), `/vendor/dashboard` & `/vendor/upload` → `302`, `/` & `/admin/login` → `200`.

## Phase 32: Future Enhancements [IN PROGRESS]
- [ ] Implement advanced analytics reporting.
- [x] ~~Register/enable `EnsureVendorIsVerified` (or decide to drop it) once KYC is enforced everywhere.~~ Registered in `VendorPanelProvider::authMiddleware()` in Phase 33.
- [ ] Move `FILESYSTEM_DISK` to `r2` in production and document the required CORS policy.

## Phase 33: International Hardening, Coupons & Orders/Refunds [COMPLETED — 2026-09-29]
- [x] Added hardening migration `2026_09_28_000001_vendor_panel_international_hardening`: `products` (`rejection_reason`, `views_count`, `compare_price`, `license_type`, `is_original_confirmed`, `last_reviewed_at`), `reviews` (`vendor_reply`, `replied_at`), `orders` commission snapshot (`commission_rate`, `vendor_earning`, `platform_fee`) + extended status enum (`refunded`, `partially_refunded`, `disputed`), `vendor_settings` storefront columns (`store_banner`, `announcement`, `vacation_mode`, `refund_policy`, `license_policy`), and the new `coupons` table.
- [x] Added migration `2026_09_28_000002_add_coupon_columns_to_orders` (`coupon_code`, `discount_amount` on `orders`). All 30 migrations verified applied (`php artisan migrate:status` → 30 Ran / 0 Pending).
- [x] Built vendor **Coupons** resource (`/vendor/coupons`, `CouponResource`, "Marketing" group) with percent/fixed discounts, min-order, usage limit, expiry — scoped to `where('user_id', auth()->id())`.
- [x] Wired coupon validation into `ProductController@checkout` (owner match + `Coupon::isValid()`), persisted `coupon_code`/`discount_amount` on orders, and increment `used_count` on payment (checkout + Stripe webhook).
- [x] Built admin **Orders & Refunds** resource (`/admin/orders`, `OrderResource`, "Financials" group) with Mark Paid / Open Dispute / Refund actions and commission snapshots.
- [x] Added `config/marketplace.php` single source of truth: `vendor_commission` (0.80), `min_withdrawal` (`MARKETPLACE_MIN_WITHDRAWAL`, default $20), payout SLA text, private `kyc_disk`.
- [x] Moved vendor-side KYC uploads to the private `local` disk (`kyc-documents/`, `visibility('private')`) and added owner-or-admin `KycPreviewController` (`/vendor/kyc/preview/{file}`) for secure delivery.
- [x] Added vendor public review replies (`vendor_reply` / `replied_at`) in `VendorReviewResource`, rendered on the public storefront; product view counter (`views_count`) and duplicate-product detection in vendor `ProductResource`.
- [x] Added CSV sales export (`VendorSalesExporter` via `ExportBulkAction` on `VendorSalesResource`).
- [x] Registered `EnsureVendorIsVerified` in `VendorPanelProvider::authMiddleware()` (unverified vendors are contained to `/vendor/profile`); expanded the Profile page to **5 tabs** (added Storefront + Security).
- [x] Fixed duplicate-link accessibility finding on `/vendor/profile`: the topbar user-menu item now reads **"Verification Status (Verified/Pending/Rejected/Unverified)"** (distinct from the sidebar's "Profile & Verification"); live render verified — sidebar label ×1, dropdown "Profile & Verification (" ×0, `optimize:clear` run.
- [x] Synced all documentation (`README.md`, `architecture.md`, `database.md`, `prompts.md`, `security.md`, `error-handling.md`, `phases.md`): 30 migrations, `coupons` table (§I, later sections re-lettered), coupon/refund flows, KYC private disk, `MARKETPLACE_*` env keys, dark-mode split, and a new drift-checklist item for nav/user-menu labels.
- [x] Verified the runtime after the changes: `php artisan test` → 2 passed; `GET /vendor/profile` → 200.

## Phase 34: 10-Page Modular Vendor Panel Restructuring & Clean Navigation Architecture [COMPLETED — 2026-09-29]
- [x] Restructured the Vendor Panel navigation into a clean 10-page modular architecture divided into 4 logical navigation groups:
  - **Main**:
    1. **Dashboard** (`/vendor/dashboard`, `heroicon-o-home`, sort: 1)
    2. **Upload Prompt** (`/vendor/upload`, `heroicon-o-plus-circle`, sort: 2)
  - **Shop Management**:
    3. **My Prompts** (`/vendor/products`, `heroicon-o-sparkles`, sort: 1)
    4. **Coupons** (`/vendor/coupons`, `heroicon-o-ticket`, sort: 2)
    5. **Profile & Verification** (`/vendor/profile`, `heroicon-o-identification`, sort: 3)
  - **Finances**:
    6. **Sales & Earnings** (`/vendor/sales-and-earnings`, `heroicon-o-banknotes`, sort: 1)
    7. **Withdraw & Payouts** (`/vendor/payouts`, `heroicon-o-credit-card`, sort: 2)
  - **Community & Support**:
    8. **Customer Reviews** (`/vendor/reviews`, `heroicon-o-star`, sort: 1)
    9. **My Followers** (`/vendor/followers`, `heroicon-o-user-group`, sort: 2)
    10. **Support Tickets** (`/vendor/tickets`, `heroicon-o-chat-bubble-left-right`, sort: 3)
- [x] Enforced `defaultSort('created_at', 'desc')` across all 7 Vendor Panel tables (`ProductResource`, `VendorSalesResource`, `CouponResource`, `VendorBilling`, `VendorReviewResource`, `VendorFollowers`, `TicketResource`).
- [x] Configured clean URL slugs: `/vendor/payouts`, `/vendor/reviews`, `/vendor/followers` with backward-compatible 302 redirects for legacy URLs (`/vendor/billing`, `/vendor/vendor-followers`, `/vendor/vendor-reviews`, `/vendor/my-prompts`).
- [x] Enhanced follower table with direct profile links and public store preview actions (`heroicon-o-arrow-top-right-on-square`).
- [x] Registered all 10 pages, resources, and navigation groups explicitly in `VendorPanelProvider.php`.
- [x] Audited and unified Admin Panel tables: confirmed all 7 Admin resources have pagination enabled (default 10 per page, options `[5, 10, 25, 50, "all"]`), added `Joined Date` column and `defaultSort('created_at', 'desc')` to `UserResource`, aligned `TicketResource` to `defaultSort('created_at', 'desc')`, preserving `sort_order asc` for `CategoryResource`.
- [x] Created automated test suites `tests/Feature/VendorPanelNavigationTest.php` and `tests/Feature/AdminPanelTablesTest.php` asserting all routes, pagination, and sorting (7 passing tests, 69 assertions).

## Phase 35: Admin Panel Phase 1: Critical Hardening & Security Foundations [COMPLETED — 2026-09-30]
- [x] **Financial Integrity**: Modified `orders.product_id` and `products.user_id` foreign keys to `restrictOnDelete()` preventing catastrophic cascade deletions.
- [x] **Soft Deletes & Data Recovery**: Added `deleted_at` to `products`, `users`, `reviews`, `coupons`, `categories`, `tickets`, `payout_methods` with Filament `TrashedFilter`, `RestoreAction`, and `ForceDeleteAction`.
- [x] **Polymorphic Immutable Audit Trail**: Built `audit_logs` table, `Auditable` model trait, and `AuditLogResource` with JSON diff inspection modal and compliance tracking.
- [x] **In-House RBAC**: Created `roles`, `permissions`, `permission_role`, `role_user` tables without third-party dependencies, registered global `Gate::before` hook, and built `RoleResource`.
- [x] **Admin Login Hardening & Session Revalidation**: Created `RevalidateAdminSession` middleware verifying banned/role state on every admin request, added `RateLimiter` lockout (5 attempts) with automated alerts.
- [x] **Real Stripe Refund Service**: Built `StripeRefundService` calling `Stripe\Refund::create()`, recording `stripe_refund_id`, updating order status, debiting vendor wallet transaction ledger, and notifying the vendor.
- [x] **Webhook Ledger & Idempotency**: Built `webhook_events` table and `WebhookEventResource` with duplicate-prevention and event replay capabilities.
- [x] **Wallet Transaction Ledger**: Created `wallet_transactions` table maintaining an append-only balance history for sales, refunds, and withdrawals.

## Phase 36: Admin Panel Phase 2: Operations, System Monitoring & Platform Governance [COMPLETED — 2026-09-30]
- [x] **9 Production Admin Dashboard Widgets**:
  - `AdminStatsOverview`: 8 real-time platform KPIs (GMV, platform revenue, vendor payable liability, today's orders with 7-day sparkline, moderation queue count, pending payouts, open high-priority tickets, KYC backlog).
  - `AdminRevenueChart`: 6-month GMV vs platform revenue line chart (Emerald `#10B981` & Cyan `#06B6D4`).
  - `AdminOrderStatusChart`: Doughnut chart of all order status categories.
  - `AdminTopVendorsChart`: Top 5 vendors by GMV horizontal bar chart.
  - `AdminModerationQueue`: Pending prompt moderation table with 1-click approve/reject actions and notifications.
  - `AdminRecentOrders`: Recent platform transaction table with customer details and Stripe payment status.
  - `AdminPendingPayoutsQueue`: Pending withdrawal requests with approval, bank reference number input, and rejection.
  - `AdminSystemHealth`: Infrastructure health card displaying database latency, queue backlog, failed jobs, local disk writability, active sessions, and runtime versions.
  - `AdminAuditTrail`: Security and audit event stream widget with interactive diff inspection modal.
- [x] **System Monitoring Resources**:
  - `JobResource` (`/admin/system/jobs`): Active queue monitor with raw payload inspector and job purge action.
  - `FailedJobResource` (`/admin/system/failed-jobs`): Failed queue management with retry action (`queue:retry`), exception stack trace viewer, and forget actions.
  - `SessionResource` (`/admin/system/sessions`): Active database sessions monitor with client device details and instant force-termination action.
- [x] **Scheduled Maintenance Tasks (`routes/console.php`)**:
  - `audit:prune`: Daily compliance data retention pruning (standard logs older than 6 months, sensitive logs older than 24 months).
  - `coupons:expire`: Daily promotional coupon deactivation upon expiration date.
  - `queue:prune-failed --hours=168`: Weekly cleanup of resolved failed jobs.
- [x] **Business & Governance Resources**:
  - `CouponResource` (`/admin/coupons`): Promotional coupon oversight, usage tracking, emergency kill-switch toggle, and bulk disable action.
  - `PayoutMethodResource` (`/admin/payout-methods`): PII masked account display (`getMaskedIdentifierAttribute`), verification approval action, and credential inspector.
  - `VendorSettingResource` (`/admin/vendor-settings`): Storefront announcement and policy moderation, and administrative vacation mode override.
- [x] **Operational Bulk Actions**:
  - `ProductResource`: Added `BulkApprove`, `BulkReject` (with required reason modal), and `BulkFeature`.
  - `PayoutResource`: Replaced hard deletion with `BulkMarkCompleted` (with bank batch reference number input and wallet ledger debiting).
  - `ReviewResource`: Added `BulkApprove` and `BulkReject`.
  - `UserResource`: Added `BulkBan`, `BulkUnban`, and `BulkVerify`.
- [x] **Support & Category Operations**:
  - `TicketResource`: Assignee assignment, SLA first-response countdown badge, confidential staff internal notes, and "Assign to Me" header action on `ViewTicket`.
  - `CategoryMergeService` & `CategoryResource`: Intelligent taxonomy merging propagating product string tags across main/sub/class levels, child reparenting, cache flushing, and CSV taxonomy import action on `ManageCategories`.
- [x] **Platform Settings Expansion (`/admin/site-settings`)**:
  - Emergency incident kill-switches (`disable_registrations`, `disable_checkout`, `maintenance_banner`, `maintenance_message`).
  - Financial commission and payout limits (`vendor_commission_rate`, `min_payout_withdrawal`, `kyc_required_for_payout`).
- [x] **Comprehensive Test Verification**:
  - Created `tests/Feature/AdminDashboardWidgetsTest.php` and `tests/Feature/AdminSystemMonitoringTest.php`.
  - Expanded `tests/Feature/AdminPanelTablesTest.php` to cover all 32 admin routes and 16 table resources.
  - Entire application test suite verified: **35 passed (254 assertions)**!

---

## Phase 37: Analytics, Growth, Queued Exports & Go-Live Final Checks [COMPLETED]
- [x] **Traffic & Conversion Analytics Engine**:
  - Created `product_view_logs` table migration (`product_id`, `user_id`, `ip_hash`, `referrer`, timestamps; compound indexes on `[product_id, created_at]` and `[ip_hash, product_id, created_at]`).
  - Created `ProductViewLog` model and attached `viewLogs()` relationship to `Product`.
  - Implemented 24-hour SHA-256 IP & user deduplication in `ProductController@show`, incrementing `products.views_count` accurately without duplicate spam.
- [x] **Analytics & Growth Intelligence Dashboard (`/admin/analytics`)**:
  - Created `AnalyticsDashboard` Filament page (`app/Filament/Pages/AnalyticsDashboard.php`) guarded by `analytics.view` permission.
  - Interactive multi-period date-range filtering (`7d`, `30d`, `90d`, `1y`, `all`).
  - **Full-Funnel Visitor Conversion Pipeline**: Visual progress bars tracking Views -> Checkout Intent -> Settled Paid Orders with step completion and drop-off metrics.
  - **Vendor Leaderboard**: Top 10 vendors ranked by GMV, net vendor payout earnings, order count, refund rate %, and average review rating ⭐.
  - **Category Performance Report**: Views, paid orders, gross volume, and view-to-sale conversion % per category.
  - **Coupon ROI & Promotion Impact Report**: Promo codes, redemptions count, concession discounts, gross volume generated, and average order value (AOV).
- [x] **Scalable Queued Exports (Filament 3 Actions)**:
  - Created `exports` table migration (`vendor/filament/actions` standard schema).
  - Built 4 dedicated Exporter classes in `app/Filament/Exports/`:
    - `OrdersExporter`: Order ID, item code, prompt title, buyer & vendor info, financial amounts, coupon codes, and Stripe refund IDs.
    - `PayoutsExporter`: Payout reference no, vendor details, amount, method, status, admin notes, and dates.
    - `UsersExporter`: User ID, full name, username, email, role, KYC status, verified badge, and balance.
    - `CouponsExporter`: Code, discount type & value, usage limit, redemptions count, min order, and active status.
  - Integrated `ExportAction` (header) and `ExportBulkAction` (bulk) across `OrderResource`, `PayoutResource`, `UserResource`, and `CouponResource` with strict RBAC permission gates.
- [x] **Automated SLA Monitoring & System Alerts (`routes/console.php`)**:
  - `products:moderation-sla-alert`: Hourly console command detecting prompt submissions pending review for > 48 hours and alerting platform administrators via Filament database notifications.
  - `payouts:stale-reminder`: Daily console command detecting vendor withdrawal requests pending for > 7 days and alerting finance managers and administrators.
- [x] **Comprehensive Testing & Verification**:
  - Created `tests/Feature/AdminAnalyticsTest.php` covering view tracking deduplication, analytics authorization, Livewire component filters, SLA console alert commands, and exporter configurations.
  - Full test suite verified green: **41 tests passed (293 assertions, 0 failures, 0 errors)**!

---

## Phase 38: Post-Implementation Admin Audit & Security Hardening (২০২৬-১০-০৪) [COMPLETED]
- [x] লাইভ প্রোব: `/admin/login` 200, `/up` 200, ৩৩ admin রুট, 46 টেস্ট পাস।
- [x] ভুল চেকলিস্ট সংশোধন: 2FA ও min-12 পাসওয়ার্ড বাস্তবে **অনুপস্থিত**।
- [x] **P0 সম্পন্ন:** TOTP 2FA + recovery codes, পাসওয়ার্ড 12+, webhook unsigned fallback শুধু local/testing, `.env.production.example`।
- [x] **P1 সম্পন্ন (কোড):** `SecurityHeaders`, `AdminSecurityGate` (idle timeout, IP allowlist), secure session ডিফল্ট, `go-live:check`, `admin:reset-2fa`।
- [ ] **ইনফ্রা পেন্ডিং:** production `.env` প্রয়োগ, queue worker, SMTP/Redis।
- [ ] **P2 পেন্ডিং:** IP allowlist, WCAG 2.2 AA অডিট, ব্যাকআপ/DR, Sentry, GDPR টুলিং।
- বিস্তারিত: `admin-panel-blueprint.md` §7।

---

## Phase 39: Role-Based Hybrid Two-Factor Authentication (TOTP & Email OTP) (২০২৬-১০-০৪) [COMPLETED]
- [x] **Database Migration & User Schema Enhancement**:
  - `2026_10_04_000002_add_email_otp_and_preferred_method_to_users_table.php` মাইগ্রেশন সম্পন্ন (`email_otp_code`, `email_otp_expires_at`, `preferred_2fa_method`)।
  - `User.php` মডেলে `casts` আপডেট (`email_otp_expires_at` => `datetime`) এবং ক্রিপ্টোগ্রাফিক ওটিপি হেল্পার মেথড যোগ (`generateEmailOtp()`, `sendEmailOtp()`, `verifyEmailOtp()`, `hasTotpEnabled()`, `hasEmailOtpEnabled()`, `preferredTwoFactorMethod()`)।
- [x] **SendEmailOtpNotification**:
  - `App\Notifications\SendEmailOtpNotification` তৈরি, ডার্ক-ফ্রেন্ডলি মেইলে ৬-ডিজিটের কোড ও ১০-মিনিট মেয়াদ সম্বলিত নোটিফিকেশন।
- [x] **Role-Based Multi-Tier Enforcement (Middleware & Gateways)**:
  - **Admin Panel (`/admin`)**: শুধুমাত্র Authenticator App (TOTP) বাধ্যতামূলক। সেটআপ না থাকলে `/admin-security/2fa/setup`-এ কিউআর কোড অনবোর্ডিং, সেশনে যাচাই না হওয়া পর্যন্ত ড্যাশবোর্ড লকড (`AdminSecurityGate`)।
  - **Vendor Panel (`/vendor`)**: Email OTP ডিফল্টভাবে বাধ্যতামূলক; পাসওয়ার্ড মিললেই ওটিপি ডিসপ্যাচ ও চ্যালেঞ্জ স্ক্রিনে রিডাইরেক্ট (`TwoFactorMiddleware`)। Authenticator App (TOTP) ঐচ্ছিক; সক্রিয় থাকলে চ্যালেঞ্জ স্ক্রিনে TOTP ও Email OTP-এর মধ্যে সুইচ করার সুবিধা।
  - **Customer Frontend (`/customer/profile`)**: উভয় মেথডই ঐচ্ছিক। কাস্টমার প্রোফাইল সেটিংস থেকে Email OTP ও Authenticator App স্বাধীনভাবে কনফিগার করতে পারেন; সেশনে যাচাই নিশ্চিত না করে প্রোটেক্টেড রুটে ঢুকতে বাধা (`TwoFactorMiddleware`)।
- [x] **Universal 2FA Challenge & Modern UI**:
  - ডার্ক থিম প্যালেট (`#0B0F19`, `#111827`, `#10B981`) সম্বলিত রেসপনসিভ চ্যালেঞ্জ স্ক্রিন (`resources/views/auth/two-factor/challenge.blade.php`)।
  - ৬-ডিজিটের ক্লিয়ার ইনপুট, Alpine.js দিয়ে ৬০ সেকেন্ডের লাইভ কাউন্টডাউন টাইমার সহ Resend Email OTP অ্যাকশন, মেথড সুইচার, এবং ইমার্জেন্সি রিকভারি কোড সাপোর্ট।
- [x] **Profile 2FA Management**:
  - Vendor Profile (`/vendor/profile`): Filament Security ট্যাবে Email OTP স্ট্যাটাস কার্ড, লাইভ কিউআর কোড সহ TOTP সংযোগ ফর্ম, এবং প্রেফারেন্স রেডিও।
  - Customer Profile (`/customer/profile`): 2FA কার্ডে Email OTP টগল, কিউআর কোড ড্রয়ার, ৬-ডিজিটের অ্যাক্টিভেশন ফিল্ড, এবং ব্যাকআপ রিকভারি কোড গ্রিড।
- [x] **Comprehensive Testing & Verification**:
  - `tests/Feature/HybridTwoFactorTest.php` তৈরি (১১টি টেস্ট, ৪০টি assertion)।
  - সম্পূর্ণ টেস্ট স্যুট ১০০% গ্রিন: **৫৭টি টেস্টই সফলভাবে উত্তীর্ণ (৩৫৯টি assertion, 0 failure)**।

---

## Phase 40: Single Centralized Authentication System & Decommissioned Panel Logins (২০২৬-১০-১৮) [COMPLETED]
- [x] **Unified Central Login Page (`/login`)**:
  - `resources/views/auth/login.blade.php` কে Filament `/admin/login`-এর অনুরূপ ডিপ চারকোল ডার্ক থিমে (`#0B0F19` ব্যাকগ্রাউন্ড, `#111827` সেন্ট্রাল কার্ড, `border-gray-800`, 'PB' ব্র্যান্ড আইকন, এমারেল্ড অ্যাকসেন্ট বাটন) রূপান্তর করা হয়েছে।
  - কাস্টমার এবং ভেন্ডর উভয়ের জন্য 'Create an Account', 'Become a Vendor', এবং 'Forgot password?' লিংক অক্ষুণ্ণ রাখা হয়েছে।
  - `resources/views/auth/custom-login.blade.php` কে ইউনিফাইড ভিউতে ফরোয়ার্ড করা হয়েছে।
- [x] **Role-Based Post-Login Redirection & 2FA Preservation**:
  - `AuthController::login` এ স্ট্যান্ডার্ড ওয়েব গার্ড (`Auth::attempt()`) ও `$request->session()->regenerate()` এনফোর্স করা হয়েছে।
  - **Admin**: অ্যাডমিন লগইনে `admin_2fa_passed` ক্লিয়ার করে `/admin` এ পাঠানো হয়, যা তাৎক্ষণিকভাবে `RevalidateAdminSession` ও TOTP 2FA এনফোর্সমেন্ট ট্রিগার করে।
  - **Vendor**: অনুমোদিত ভেন্ডর ট্রাস্টেড ডিভাইসে (৩০ দিনের কুকি) থাকলে সরাসরি `/vendor/dashboard` এ রিডাইরেক্ট হয়; অচেনা ডিভাইস বা অনির্ভরযোগ্য অবস্থায় Email OTP / TOTP চ্যালেঞ্জে (`2fa.challenge`) ইন্টারসেপ্ট হয়।
  - **Customer**: কাস্টমার 2FA সক্রিয় থাকলে ওটিপি চ্যালেঞ্জে রিডাইরেক্ট হয়, অন্যথায় `intended('/')` বা হোমপেজে যায়।
- [x] **Safely Decommissioned `/admin/login` & `/vendor/login`**:
  - `AdminPanelProvider` ও `VendorPanelProvider` থেকে `->login(...)` কল অপসারিত এবং উভয়ে `->authGuard('web')` শেয়ার করে।
  - `App\Http\Middleware\RedirectToCentralLogin` তৈরি ও উভয় প্যানেলে রেজিস্ট্রেশন, যা আনঅথেন্টিকেটেড রিকোয়েস্টকে স্বয়ংক্রিয়ভাবে `route('login')` এ পাঠায়।
  - `routes/web.php` এ `/admin/login` ও `/vendor/login` গেস্টদের জন্য `/login` এ এবং অলরেডি লগইন থাকা ইউজারদের ড্যাশবোর্ডে নিরাপদে রিডাইরেক্ট করে।
- [x] **Unified Logout Handling**:
  - `CustomLogoutResponse` ও `AuthController::logout` এর মাধ্যমে অ্যাডমিন, ভেন্ডর ও কাস্টমার সব প্যানেল থেকেই লগআউট করলে সেশনের সকল 2FA ভেরিফিকেশন স্টেট মুছে দিয়ে ক্লিয়ারলি `/login` এ রিডাইরেক্ট নিশ্চিত করা হয়েছে।
- [x] **Automated Testing & Verification**:
  - `tests/Feature/UnifiedCentralLoginTest.php` তৈরি (৯টি টেস্ট, ৫২টি assertion)।
  - সম্পূর্ণ অথেনটিকেশন ও সিকিউরিটি টেস্ট স্যুট ১০০% গ্রিন: **৩৫টি টেস্ট ও ১৬১টি assertion সফলভাবে উত্তীর্ণ (0 Failures, 0 Errors)**।

---

## Phase 41: Prompts.chat Open-Source Importer & Interactive Prompt Engine (২০২৬-১০-২৪) [COMPLETED]
- [x] **Artisan Command (`php artisan prompts:import-community`)**:
  - `App\Console\Commands\ImportPromptsChatCommand` তৈরি করা হয়েছে, যা প্রাইমারি সোর্স `https://prompts.chat/prompts.json` (মেটাডেটা, ক্যাটাগরি, ট্যাগ, মিডিয়া URL ও প্রম্পট টাইপ) এবং ফলব্যাক/মার্জ সোর্স `https://raw.githubusercontent.com/f/prompts.chat/main/prompts.csv` থেকে পুরো ওপেন-সোর্স লাইব্রেরি ফেচ করে।
  - অফিসিয়াল ভেরিফায়েড সিস্টেম ভেন্ডর অ্যাকাউন্ট (`Prompts.chat Community`, username: `promptschat`, `role = vendor`, `is_verified = true`) স্বয়ংক্রিয়ভাবে তৈরি ও অ্যাসাইন করা হয়েছে।
  - ইন-মেমরি ম্যাপ ও চাঙ্কড `Product::upsert` ডিডুপ্লিকেশন (`slug` বা `title` ভিত্তিক) যুক্ত করা হয়েছে, যাতে বারবার কমান্ড রান করলেও কোনো ডুপ্লিকেট প্রম্পট তৈরি না হয়।
  - ইউনিক `PRD-XXXXXX` কোড জেনারেশন, `price = 0.00` (ফ্রি বা কাস্টম `--price`), `status = 'approved'`, `is_active = true`, অটোমেটিক ক্যাটাগরি ম্যাপিং (`Coding`, `Writing`, `Photography`, `Marketing`, `Roleplay`, ইত্যাদি) এবং AI Model ডিটেকশন (`ChatGPT`, `Claude`, `Gemini`, `Midjourney`, `DALL-E`, `Flux`, `Veo`, `Stable Diffusion`) বাস্তবায়ন করা হয়েছে।
  - `--download-images` ও `--fast` ফ্ল্যাগ সাপোর্ট এবং ইমেজবিহীন টেক্সট প্রম্পটগুলোর জন্য ডার্ক-মোড (`#111827`) ক্যাটাগরি SVG কভার প্লেসহোল্ডার জেনারেশন ও টার্মিনাল প্রোগ্রেস বার যুক্ত করা হয়েছে।
- [x] **Admin 1-Click Import Action (`/admin/products`)**:
  - `app/Filament/Resources/ProductResource/Pages/ListProducts.php`-এ `'Import from Prompts.chat'` (`heroicon-o-cloud-arrow-down`) হেডার অ্যাকশন বাটন ও মডাল যুক্ত করা হয়েছে (Import Limit: `50`, `100`, `500`, `1000`, `all`; Default Price; Target Seller/Vendor; Download Images টগল ও Filament সাকসেস নোটিফিকেশন সহ)।
- [x] **Interactive Prompt Engine & Playground (`show.blade.php` & `reveal.blade.php`)**:
  - `resources/views/products/partials/interactive-prompt-engine.blade.php` তৈরি করা হয়েছে, যা ফ্রি (`$0.00`) এবং আনলকড প্রম্পটগুলোর জন্য সক্রিয় হয় (পেইড আনপারচেজড প্রম্পটের লকড সিকিউরিটি শতভাগ অক্ষুণ্ণ রেখে)।
  - **Dynamic Variable Parser**: প্রম্পট টেক্সটের ভেতরের `${variable:default}`, `${variable}` এবং `[Variable]` টোকেনগুলো অটোমেটিক পার্স করে `#111827` ডার্ক-থিমড ইনপুট ফিল্ড রেন্ডার করে এবং ইউজার টাইপ করার সাথে সাথে রিয়েল-টাইমে প্রম্পট টেক্সট আপডেট করে।
  - **1-Click Copy & 'Run in AI' Quick Launchers**: ইনস্ট্যান্ট টোস্ট ফিডব্যাকসহ `Copy Prompt` বাটন এবং ডাইনামিক্যালি পূরণকৃত প্রম্পটসহ সরাসরি `'Open in ChatGPT'`, `'Open in Claude'`, ও `'Open in Perplexity'` বাটন যুক্ত করা হয়েছে।
- [x] **Automated Feature Testing**:
  - `tests/Feature/PromptsChatImportAndInteractiveEngineTest.php` তৈরি ও যাচাইকৃত (৩টি টেস্ট, ৬০টি assertion সফলভাবে উত্তীর্ণ)।

---

## Phase 42: Vendor 2FA Session Persistence, 30-Day Trusted Device Cookie & One-Time Email Verification (২০২৬-১০-৩১) [COMPLETED]
- [x] **Session Persistence (Verify Once Per Session)**:
  - ভেন্ডর একবার Email OTP বা TOTP যাচাই করলে সেশনে `session(['2fa_verified' => true, 'vendor_2fa_passed' => true])` সংরক্ষণ করা হয়েছে।
  - `TwoFactorMiddleware` সেশন ফ্ল্যাগ চেক করে পুরো সেশনে `/vendor/*` এর সকল পেজে পুনরায় OTP চ্যালেঞ্জ ছাড়াই নির্বিঘ্ন নেভিগেশন নিশ্চিত করে।
- [x] **'Trust this device for 30 days' Encrypted Cookie (`trusted_device_{user_id}`)**:
  - `/2fa/challenge` স্ক্রিনে *"Trust this device for 30 days"* চেকবক্স যুক্ত করা হয়েছে।
  - চেক করা থাকলে ৪৩,২০০ মিনিট (৩০ দিন) মেয়াদী এনক্রিপ্টেড HTTP-only কুকি (`trusted_device_{user_id}`) এবং `users.trusted_devices` JSON তালিকায় হ্যাশড টোকেন সংরক্ষণ করা হয়।
  - পরবর্তীতে একই ব্রাউজার/ডিভাইস থেকে লগইন করলে (যদি আলাদাভাবে TOTP 2FA এনফোর্স করা না থাকে) সম্পূর্ণভাবে Email OTP বাইপাস করে সরাসরি `/vendor/dashboard`-এ প্রবেশ করানো হয়।
- [x] **One-Time Account Email Verification**:
  - প্রথমবার সফলভাবে OTP যাচাইয়ের সাথে সাথে `users.email_verified_at = now()` সেট করা হয়।

---

## Phase 43: End-to-End Withdrawal Request & Payout Management System (`/vendor/payouts` & `/admin/payouts`) (২০২৬-১০-৩১) [COMPLETED]
- [x] **Enhanced `vendor_payouts` Schema (`2026_10_16_000001_enhance_vendor_payouts_for_withdrawal_system.php`)**:
  - `reference_id` (ইউনিক কোড `WDR-XXXXXX`), `payout_method_id` (nullable FK to `payout_methods`), `payout_details` (রিকোয়েস্টের সময় পেমেন্ট মেথডের অপরিবর্তনীয় JSON স্ন্যাপশট), `vendor_note`, `rejection_reason`, `admin_notes`, `processed_at`, এবং `status` (`pending`, `processing`, `completed`, `rejected`) কলাম যুক্ত করা হয়েছে।
- [x] **Real-Time Balance Calculation & Concurrency Locking**:
  - `User` মডেলে `available_balance = total_earnings - (pending + processing + completed payouts)`, `pending_withdrawal_balance`, এবং `withdrawn_total` অ্যাক্সেসর যুক্ত করা হয়েছে যাতে পেন্ডিং/প্রসেসিং রিকোয়েস্টের ব্যালেন্স তাৎক্ষণিকভাবে লক থাকে।
  - `VendorBilling::submitWithdrawalRequest()` এ `DB::transaction()` ও `User::lockForUpdate()` ব্যবহৃত হয়েছে যাতে ডাবল-উইথড্রয়াল বা রেস কন্ডিশন অসম্ভব হয়।
- [x] **Vendor Payouts Portal (`/vendor/payouts`)**:
  - ৪টি ফিনটেক ব্যালেন্স কার্ড, কুইক অ্যামাউন্ট পিল (`$20`, `$50`, `$100`, `MAX`) সহ **Request Withdrawal Modal**, এবং স্ট্যাটাস ব্যাজ ও রিজেকশন টুলটিপসহ **Withdrawal History Table** তৈরি করা হয়েছে।
- [x] **Admin Payout Management (`/admin/payouts` — `PayoutResource`)**:
  - `Mark as Processing`, `Complete & Mark Paid`, এবং `Reject & Refund Balance` (যা স্বয়ংক্রিয়ভাবে ভেন্ডরের `available_balance` ফিরিয়ে দেয় ও নোটিফিকেশন পাঠায়) অ্যাকশন যুক্ত করা হয়েছে।
- [x] **Automated Feature Testing**:
  - `tests/Feature/VendorWithdrawalSystemTest.php` তৈরি ও যাচাইকৃত (৭টি টেস্ট সফলভাবে উত্তীর্ণ)।

---

## Phase 44: Unified `#0B0F19` FinTech Vendor Profile & Verification Redesign (`/vendor/profile`) (২০২৬-১০-৩১) [COMPLETED]
- [x] **Unified Dark FinTech Header & 4 KPI Cards (`resources/views/filament/vendor/pages/profile.blade.php`)**:
  - `/vendor/profile` পেজটি ভেন্ডর প্যানেলের অন্যান্য পেজের (`Dashboard`, `Payouts`) সাথে শতভাগ সামঞ্জস্যপূর্ণ `#0B0F19` / `#111827` ডার্ক ফিনটেক থিমে রিডিজাইন করা হয়েছে।
  - উপরে গ্রেডিয়েন্ট আইডেন্টিটি ব্যানার, কপিযোগ্য `VND-XXXXXX` ব্যাজ, ৪টি KPI ওভারভিউ কার্ড (`Store Identity`, `KYC Status`, `Storefront Status`, `2FA Security`), এবং সরাসরি ৫-ট্যাব সেটিংস ফর্ম ও `Storefront Preview` টগল যুক্ত করা হয়েছে।

---

## Phase 45: Decoupled Instant Vendor Access & 3-Step First-Time Vendor Onboarding Survey Wizard (`/vendor/onboarding`) (২০২৬-১০-৩১) [COMPLETED]
- [x] **Database Migration (`2026_10_31_000001_add_vendor_onboarding_and_survey_columns.php`)**:
  - `users` এবং `vendor_settings` টেবিলে `store_name`, `phone`, `country`, `address`, `city`, `postal_code`, `primary_ai_models` (JSON), `focus_categories` (JSON), `experience_level`, `referral_source`, এবং `onboarding_completed_at` কলাম যুক্ত করা হয়েছে।
- [x] **Instant Vendor Access (Decoupled from KYC / Admin Approval)**:
  - `User::canAccessPanel()`, `AuthController::login()`, এবং `EnsureVendorIsVerified` হালনাগাদ করা হয়েছে যাতে যেকোনো সক্রিয় ভেন্ডর (`role === 'vendor'`, `is_suspended = false`, `is_banned = false`) রেজিস্ট্রেশন ও অনবোর্ডিং শেষ করার সাথে সাথেই অ্যাডমিন অ্যাপ্রুভালের অপেক্ষা ছাড়াই `/vendor` প্যানেলের সকল ১০টি পেজে (প্রম্পট আপলোড, প্রম্পট ম্যানেজমেন্ট, কুপন, রিভিউ, টিকেট, পেআউট মেথড ইত্যাদি) সম্পূর্ণ অপারেশনাল অ্যাক্সেস পান।
  - শুধুমাত্র **Verified Seller Badge (`✓`)** ও KYC ট্রাস্ট ব্যাজ অ্যাডমিনের KYC অ্যাপ্রুভালের (`$user->isVerified()`) ওপর নির্ভরশীল রাখা হয়েছে।
- [x] **3-Step First-Time Vendor Onboarding Survey Wizard (`/vendor/onboarding`)**:
  - `EnsureVendorOnboardingCompleted` মিডলওয়্যার এবং `App\Filament\Vendor\Pages\VendorOnboarding` (`resources/views/filament/vendor/pages/vendor-onboarding.blade.php`) তৈরি করা হয়েছে।
  - প্রথমবার লগইন বা রেজিস্ট্রেশন করা ভেন্ডরকে (`onboarding_completed_at === null`) স্বয়ংক্রিয়ভাবে `/vendor/onboarding`-এ নিয়ে যাওয়া হয়, যেখানে ৩টি ধাপে তথ্য সংগ্রহ করা হয়:
    1. **Step 1 (Store & Identity)**: Store Name, `@username` (রিয়েল-টাইম অ্যাভেইলেবিলিটি চেকসহ), Profile Avatar ও Short Bio/Tagline।
    2. **Step 2 (Contact & Billing Location)**: Phone / WhatsApp Number, Country, Street Address, City / State ও Postal / ZIP Code।
    3. **Step 3 (Creator Survey)**: Primary AI Models (`Midjourney`, `ChatGPT`, `Claude`, `Gemini`, `Flux`, `Stable Diffusion`, `DALL-E`, `Sora`, `Cursor`), Focus Categories, Experience Level এবং Referral Source।
  - সাবমিট করার সাথে সাথে `onboarding_completed_at = now()` সেট হয় এবং ভেন্ডরকে সরাসরি `/vendor/dashboard`-এ রিডাইরেক্ট করা হয়।
- [x] **Admin 360° Vendor Inspection Integration (`/admin/vendors`)**:
  - `VendorResource` এর View এবং Edit পেজে **"Contact, Billing Location & Creator Onboarding Survey"** সেকশন যুক্ত করা হয়েছে, যাতে অ্যাডমিন ভেন্ডরের ফোন, ঠিকানা ও সার্ভে ডাটা এক নজরে দেখতে পারেন।
- [x] **Automated Feature Testing**:
  - `tests/Feature/VendorOnboardingAndAccessTest.php` তৈরি ও যাচাইকৃত (৭টি টেস্ট, ৪৭টি assertion সফলভাবে উত্তীর্ণ)।

---

## Development Environment (Current Workstation)

> Added 2026-09-28. Earlier phases (1–17 especially) were written during the Windows/XAMPP era; this section describes the machine the project actually runs on now.

- **OS / Shell**: Linux (Ubuntu) + **zsh**. `~/.zshrc` prepends `$HOME/.local/bin` to `PATH`.
- **PHP**: **8.5.4** CLI (`/usr/bin/php8.5`). `~/.local/bin/php` → `php85` are wrappers that load the extensions extracted into `~/.local/share/php85ext/` via `PHP_INI_SCAN_DIR`:
  `dom`, `xml`, `xmlreader`, `xmlwriter`, `simplexml`, `xsl`, `mbstring`, `curl`, `intl`, `mysqlnd`, `mysqli`, `pdo_mysql`, `pdo_sqlite`, `sqlite3`, `zip`, `gd`, `bcmath`, `gmp` (`LD_LIBRARY_PATH` also points at a locally bundled `libzip.so.5`).
  - ⚠️ Never run `sudo php ...` — the system PHP has no extensions and crashes with `Class "DOMDocument" not found`.
  - Permanent alternative: `sudo apt install php8.5-xml php8.5-mbstring php8.5-curl php8.5-intl php8.5-mysql php8.5-zip php8.5-sqlite3 php8.5-gd php8.5-bcmath php8.5-gmp`, then remove the wrappers and the `.zshrc` PATH line.
- **Database**: MySQL 8 through **XAMPP** (`/opt/lampp`) on `127.0.0.1:3306`, socket `/opt/lampp/var/mysql/mysql.sock`, user `root` with an empty password. Start/stop with `sudo /opt/lampp/lampp start|stop`. Databases: `promptery_db` (dev) and `promptery_test` (phpunit).
- **Toolchain**: Composer 2.10.3 (`/usr/local/bin/composer`), Node 22 / npm 9, Vite 8.2, Laravel 13.24, Filament 3.3.54.
- **Daily workflow**: `composer run dev` → http://127.0.0.1:8000 (Vite on 5173) · tests: `php artisan test` · production assets: `npm run build`.
- **Repo quirks on this machine**: `.npmrc` sets `ignore-scripts=true`; `node_modules` was originally copied from Windows so `chmod +x node_modules/.bin/*` (and `artisan`, `vendor/bin/*`) may be required; `public/storage` needs `php artisan storage:link` if the `public` disk is used.







