-- BGMI UID Verification & Gaming Platform
-- Complete Database Schema with Indexes, Foreign Keys, and Default Seed Data

SET FOREIGN_KEY_CHECKS = 0;

-- 1. Admins
CREATE TABLE IF NOT EXISTS `admins` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(100) NOT NULL,
  `username` VARCHAR(50) NOT NULL UNIQUE,
  `email` VARCHAR(150) NOT NULL UNIQUE,
  `password` VARCHAR(255) NOT NULL,
  `role` ENUM('super_admin', 'admin', 'moderator') DEFAULT 'admin',
  `is_active` TINYINT(1) DEFAULT 1,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_admin_user` (`username`),
  INDEX `idx_admin_email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 2. Admin Permissions
CREATE TABLE IF NOT EXISTS `admin_permissions` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `admin_id` INT UNSIGNED NOT NULL,
  `permission` VARCHAR(100) NOT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`admin_id`) REFERENCES `admins`(`id`) ON DELETE CASCADE,
  INDEX `idx_admin_perm` (`admin_id`, `permission`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 3. Users
CREATE TABLE IF NOT EXISTS `users` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(100) NOT NULL,
  `username` VARCHAR(50) NOT NULL UNIQUE,
  `email` VARCHAR(150) NOT NULL UNIQUE,
  `phone` VARCHAR(20) DEFAULT NULL,
  `password` VARCHAR(255) NOT NULL,
  `credits` INT NOT NULL DEFAULT 0,
  `is_active` TINYINT(1) DEFAULT 1,
  `email_verified` TINYINT(1) DEFAULT 0,
  `remember_token` VARCHAR(100) DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_users_username` (`username`),
  INDEX `idx_users_email` (`email`),
  INDEX `idx_users_credits` (`credits`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 4. Packages
CREATE TABLE IF NOT EXISTS `packages` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(100) NOT NULL,
  `description` TEXT DEFAULT NULL,
  `credits` INT UNSIGNED NOT NULL,
  `price` DECIMAL(10,2) NOT NULL,
  `currency` VARCHAR(10) NOT NULL DEFAULT 'INR',
  `badge` VARCHAR(50) DEFAULT NULL,
  `pack_type` VARCHAR(30) DEFAULT 'uc',
  `is_featured` TINYINT(1) DEFAULT 0,
  `is_active` TINYINT(1) DEFAULT 1,
  `sort_order` INT DEFAULT 0,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_package_status` (`is_active`, `sort_order`),
  INDEX `idx_package_type` (`pack_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 5. Orders
CREATE TABLE IF NOT EXISTS `orders` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `order_id` VARCHAR(50) NOT NULL UNIQUE,
  `user_id` INT UNSIGNED NOT NULL,
  `package_id` INT UNSIGNED NOT NULL,
  `payment_method` ENUM('cashfree', 'upi', 'paypal') NOT NULL,
  `amount` DECIMAL(10,2) NOT NULL,
  `currency` VARCHAR(10) NOT NULL DEFAULT 'INR',
  `credits` INT UNSIGNED NOT NULL,
  `status` ENUM('pending', 'processing', 'under_review', 'paid', 'failed', 'rejected', 'refunded', 'cancelled') NOT NULL DEFAULT 'pending',
  `gateway_order_id` VARCHAR(150) DEFAULT NULL,
  `transaction_id` VARCHAR(150) DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`package_id`) REFERENCES `packages`(`id`),
  INDEX `idx_orders_order_id` (`order_id`),
  INDEX `idx_orders_user` (`user_id`),
  INDEX `idx_orders_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 6. Payments
CREATE TABLE IF NOT EXISTS `payments` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `order_id` VARCHAR(50) NOT NULL,
  `user_id` INT UNSIGNED NOT NULL,
  `method` ENUM('cashfree', 'upi', 'paypal') NOT NULL,
  `gateway` VARCHAR(50) DEFAULT 'manual',
  `gateway_order_id` VARCHAR(150) DEFAULT NULL,
  `transaction_id` VARCHAR(150) DEFAULT NULL,
  `amount` DECIMAL(10,2) NOT NULL,
  `currency` VARCHAR(10) NOT NULL DEFAULT 'INR',
  `status` ENUM('pending', 'processing', 'under_review', 'paid', 'failed', 'rejected', 'refunded', 'cancelled') NOT NULL DEFAULT 'pending',
  `proof_file` VARCHAR(255) DEFAULT NULL,
  `utr` VARCHAR(100) DEFAULT NULL,
  `sender_email` VARCHAR(150) DEFAULT NULL,
  `admin_note` TEXT DEFAULT NULL,
  `failure_reason` TEXT DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  INDEX `idx_payments_order` (`order_id`),
  INDEX `idx_payments_user` (`user_id`),
  INDEX `idx_payments_utr` (`utr`),
  INDEX `idx_payments_txn` (`transaction_id`),
  INDEX `idx_payments_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 7. Credit Transactions (Ledger)
CREATE TABLE IF NOT EXISTS `credit_transactions` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT UNSIGNED NOT NULL,
  `type` ENUM('PURCHASE', 'VERIFICATION', 'REFUND', 'ADMIN_ADJUSTMENT', 'BONUS', 'REVERSAL') NOT NULL,
  `amount` INT NOT NULL,
  `balance_before` INT NOT NULL,
  `balance_after` INT NOT NULL,
  `reference_type` VARCHAR(50) DEFAULT NULL,
  `reference_id` VARCHAR(100) DEFAULT NULL,
  `description` TEXT DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  INDEX `idx_credit_user` (`user_id`),
  INDEX `idx_credit_type` (`type`),
  INDEX `idx_credit_ref` (`reference_type`, `reference_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 8. Verification Logs
CREATE TABLE IF NOT EXISTS `verification_logs` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT UNSIGNED DEFAULT NULL,
  `uid` VARCHAR(50) NOT NULL,
  `player_name` VARCHAR(100) DEFAULT NULL,
  `status` ENUM('success', 'failed', 'not_found', 'error') NOT NULL,
  `credits_used` INT DEFAULT 1,
  `api_provider` VARCHAR(50) DEFAULT 'bgmi_api',
  `response_data` TEXT DEFAULT NULL,
  `ip_address` VARCHAR(45) NOT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  INDEX `idx_verif_user` (`user_id`),
  INDEX `idx_verif_uid` (`uid`),
  INDEX `idx_verif_status` (`status`),
  INDEX `idx_verif_ip` (`ip_address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 9. API Logs
CREATE TABLE IF NOT EXISTS `api_logs` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `endpoint` VARCHAR(255) NOT NULL,
  `method` VARCHAR(10) NOT NULL DEFAULT 'GET',
  `request_data` TEXT DEFAULT NULL,
  `response_code` INT DEFAULT NULL,
  `response_time_ms` INT DEFAULT NULL,
  `response_data` TEXT DEFAULT NULL,
  `status` VARCHAR(50) DEFAULT 'success',
  `ip_address` VARCHAR(45) DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  INDEX `idx_api_endpoint` (`endpoint`),
  INDEX `idx_api_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 10. Contact Messages
CREATE TABLE IF NOT EXISTS `contact_messages` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(100) NOT NULL,
  `email` VARCHAR(150) NOT NULL,
  `subject` VARCHAR(200) NOT NULL,
  `message` TEXT NOT NULL,
  `status` ENUM('unread', 'read', 'replied') DEFAULT 'unread',
  `admin_reply` TEXT DEFAULT NULL,
  `ip_address` VARCHAR(45) NOT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_contact_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 11. Notifications
CREATE TABLE IF NOT EXISTS `notifications` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT UNSIGNED NOT NULL,
  `title` VARCHAR(200) NOT NULL,
  `message` TEXT NOT NULL,
  `type` ENUM('info', 'success', 'warning', 'danger') DEFAULT 'info',
  `is_read` TINYINT(1) DEFAULT 0,
  `link` VARCHAR(255) DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  INDEX `idx_notif_user` (`user_id`, `is_read`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 12. Password Resets
CREATE TABLE IF NOT EXISTS `password_resets` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `email` VARCHAR(150) NOT NULL,
  `token` VARCHAR(128) NOT NULL UNIQUE,
  `expires_at` DATETIME NOT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  INDEX `idx_reset_token` (`token`),
  INDEX `idx_reset_email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 13. Settings
CREATE TABLE IF NOT EXISTS `settings` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `setting_key` VARCHAR(100) NOT NULL UNIQUE,
  `setting_value` MEDIUMTEXT DEFAULT NULL,
  `category` VARCHAR(50) DEFAULT 'general',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_settings_cat` (`category`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 14. Pages (CMS)
CREATE TABLE IF NOT EXISTS `pages` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `slug` VARCHAR(100) NOT NULL UNIQUE,
  `title` VARCHAR(200) NOT NULL,
  `content` LONGTEXT NOT NULL,
  `meta_title` VARCHAR(255) DEFAULT NULL,
  `meta_description` TEXT DEFAULT NULL,
  `is_active` TINYINT(1) DEFAULT 1,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_pages_slug` (`slug`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 15. Admin Audit Logs
CREATE TABLE IF NOT EXISTS `admin_audit_logs` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `admin_id` INT UNSIGNED DEFAULT NULL,
  `action` VARCHAR(150) NOT NULL,
  `target_type` VARCHAR(50) DEFAULT NULL,
  `target_id` VARCHAR(50) DEFAULT NULL,
  `details` TEXT DEFAULT NULL,
  `ip_address` VARCHAR(45) NOT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  INDEX `idx_audit_admin` (`admin_id`),
  INDEX `idx_audit_action` (`action`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 16. Login Logs
CREATE TABLE IF NOT EXISTS `login_logs` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT UNSIGNED DEFAULT NULL,
  `user_type` ENUM('user', 'admin') DEFAULT 'user',
  `username` VARCHAR(150) NOT NULL,
  `status` ENUM('success', 'failed', 'blocked') NOT NULL,
  `ip_address` VARCHAR(45) NOT NULL,
  `user_agent` VARCHAR(255) DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  INDEX `idx_login_user` (`user_id`),
  INDEX `idx_login_ip` (`ip_address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 17. Webhook Events
CREATE TABLE IF NOT EXISTS `webhook_events` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `provider` VARCHAR(50) NOT NULL,
  `event_id` VARCHAR(150) NOT NULL UNIQUE,
  `event_type` VARCHAR(100) NOT NULL,
  `payload_hash` VARCHAR(64) NOT NULL,
  `payload` MEDIUMTEXT DEFAULT NULL,
  `processed` TINYINT(1) DEFAULT 0,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  INDEX `idx_webhook_event` (`event_id`),
  INDEX `idx_webhook_prov` (`provider`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 18. Rate Limits
CREATE TABLE IF NOT EXISTS `rate_limits` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `rate_key` VARCHAR(150) NOT NULL UNIQUE,
  `hits` INT UNSIGNED NOT NULL DEFAULT 1,
  `expires_at` INT UNSIGNED NOT NULL,
  INDEX `idx_rate_key` (`rate_key`),
  INDEX `idx_rate_exp` (`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 19. Support Tickets
CREATE TABLE IF NOT EXISTS `support_tickets` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `ticket_number` VARCHAR(50) NOT NULL UNIQUE,
  `user_id` INT UNSIGNED NOT NULL,
  `subject` VARCHAR(200) NOT NULL,
  `priority` ENUM('low', 'medium', 'high', 'urgent') DEFAULT 'medium',
  `status` ENUM('open', 'in_progress', 'answered', 'closed') DEFAULT 'open',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
  INDEX `idx_ticket_user` (`user_id`),
  INDEX `idx_ticket_num` (`ticket_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 20. Support Messages
CREATE TABLE IF NOT EXISTS `support_messages` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `ticket_id` INT UNSIGNED NOT NULL,
  `user_id` INT UNSIGNED NOT NULL,
  `is_admin` TINYINT(1) DEFAULT 0,
  `message` TEXT NOT NULL,
  `attachment` VARCHAR(255) DEFAULT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`ticket_id`) REFERENCES `support_tickets`(`id`) ON DELETE CASCADE,
  INDEX `idx_support_msg_ticket` (`ticket_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- =======================================================
-- DEFAULT SEED DATA
-- =======================================================

-- Default Settings
INSERT INTO `settings` (`setting_key`, `setting_value`, `category`) VALUES
('site_name', 'BGMI Verify', 'general'),
('site_tagline', 'Instant & Secure BGMI Player UID Verification', 'general'),
('site_description', 'High speed, secure Battlegrounds Mobile India player identity verification platform. Fast, accurate, and developer-friendly.', 'general'),
('currency', 'INR', 'general'),
('currency_symbol', '₹', 'general'),
('contact_email', 'support@bgmiverify.com', 'contact'),
('contact_phone', '+91 98765 43210', 'contact'),
('contact_address', 'Cyber City, Gurugram, Haryana, India', 'contact'),
('maintenance_mode', '0', 'general'),
('guest_verification_enabled', '1', 'verification'),
('guest_verification_daily_limit', '3', 'verification'),
('user_verification_rate_limit', '60', 'verification'),
('deduct_credit_rule', 'success_only', 'verification'),
('system_version', '1.0.0', 'system'),
('database_version', '1.0.0', 'system'),

-- Cashfree Settings
('cashfree_enabled', '0', 'cashfree'),
('cashfree_environment', 'sandbox', 'cashfree'),
('cashfree_app_id', '', 'cashfree'),
('cashfree_secret_key', '', 'cashfree'),
('cashfree_webhook_secret', '', 'cashfree'),
('cashfree_currency', 'INR', 'cashfree'),

-- Manual UPI Settings
('upi_enabled', '1', 'upi'),
('upi_id', 'paybgmi@upi', 'upi'),
('upi_account_name', 'BGMI Verification Desk', 'upi'),
('upi_qr_code', 'assets/images/default-qr.png', 'upi'),
('upi_instructions', 'Scan the QR code or pay to the UPI ID. Once paid, copy the 12-digit UTR/Transaction Reference Number and upload a screenshot of the payment receipt. Credits will be credited within 10-30 minutes upon review.', 'upi'),
('upi_min_amount', '10', 'upi'),
('upi_max_amount', '50000', 'upi'),
('upi_proof_required', '1', 'upi'),

-- Manual PayPal Settings
('paypal_enabled', '1', 'paypal'),
('paypal_email', 'payments@bgmiverify.com', 'paypal'),
('paypal_currency', 'USD', 'paypal'),
('paypal_instructions', 'Send payment as Friends & Family or Goods & Services to the PayPal email above. After completing payment, enter your PayPal Transaction ID, sender email, and upload the payment proof.', 'paypal'),
('paypal_min_amount', '1', 'paypal'),
('paypal_max_amount', '500', 'paypal'),
('paypal_proof_required', '1', 'paypal'),

-- BGMI API Settings
('bgmi_api_enabled', '1', 'bgmi_api'),
('bgmi_api_provider', 'sandbox', 'bgmi_api'),
('bgmi_api_url', 'https://api.bgmiverify.com/v1/player/lookup', 'bgmi_api'),
('bgmi_api_key', '', 'bgmi_api'),
('bgmi_api_auth_header', 'Authorization', 'bgmi_api'),
('bgmi_api_timeout', '10', 'bgmi_api'),

-- SEO Settings
('meta_title', 'BGMI UID Verification Platform | Fast Player Name Checker', 'seo'),
('meta_description', 'Instantly verify BGMI (Battlegrounds Mobile India) Player UIDs, retrieve official in-game character names, and check account authenticity.', 'seo'),
('meta_keywords', 'bgmi uid verify, battlegrounds mobile india player check, bgmi id search, bgmi player name lookup, pubg india id check', 'seo'),
('canonical_url', 'https://bgmiverify.com', 'seo'),
('og_title', 'BGMI Player UID Verification Platform', 'seo'),
('og_description', 'Check BGMI in-game names instantly with our reliable verification system.', 'seo'),
('og_image', 'assets/images/og-preview.jpg', 'seo'),
('google_verification', '', 'seo'),

-- SMTP Settings
('smtp_enabled', '0', 'smtp'),
('smtp_host', 'smtp.mailtrap.io', 'smtp'),
('smtp_port', '587', 'smtp'),
('smtp_username', '', 'smtp'),
('smtp_password', '', 'smtp'),
('smtp_encryption', 'tls', 'smtp'),
('smtp_from_email', 'noreply@bgmiverify.com', 'smtp'),
('smtp_from_name', 'BGMI Verify Platform', 'smtp'),

-- Security Settings
('login_max_attempts', '5', 'security'),
('login_lockout_minutes', '15', 'security'),
('rate_limit_api_per_minute', '30', 'security'),
('rate_limit_contact_per_hour', '5', 'security'),
('rate_limit_payment_per_hour', '10', 'security')
ON DUPLICATE KEY UPDATE `updated_at` = CURRENT_TIMESTAMP;

-- Default Packages (UC Top-Up Packs & Tournament Verification Passes)
INSERT INTO `packages` (`name`, `description`, `credits`, `price`, `currency`, `badge`, `pack_type`, `is_featured`, `is_active`, `sort_order`) VALUES
('12 UC + 1 Bonus UC', '12 UC plus 1 Bonus UC credited directly to your BGMI User ID', 13, 15.00, 'INR', '5% Off', 'uc', 0, 1, 1),
('24 UC + 2 Bonus UC', '24 UC plus 2 Bonus UC credited directly to your BGMI User ID', 26, 30.00, 'INR', 'Popular', 'uc', 0, 1, 2),
('60 UC + 6 Bonus UC', '60 UC plus 6 Bonus UC credited directly to your BGMI User ID', 66, 75.00, 'INR', 'Hot Seller', 'uc', 0, 1, 3),
('300 UC + 60 Bonus UC', '300 UC plus 60 Bonus UC credited directly to your BGMI User ID', 360, 380.00, 'INR', 'Royale Pass', 'uc', 0, 1, 4),
('600 UC + 120 Bonus UC', '600 UC plus 120 Bonus UC credited directly to your BGMI User ID', 720, 750.00, 'INR', 'Best Value', 'uc', 1, 1, 5),
('1500 UC + 450 Bonus UC', '1500 UC plus 450 Bonus UC credited directly to your BGMI User ID', 1950, 1900.00, 'INR', 'Bonus Deal', 'uc', 0, 1, 6),
('3000 UC + 1050 Bonus UC', '3000 UC plus 1050 Bonus UC credited directly to your BGMI User ID', 4050, 3800.00, 'INR', 'Pro Saver', 'uc', 0, 1, 7),
('6000 UC + 2400 Bonus UC', '6000 UC plus 2400 Bonus UC credited directly to your BGMI User ID', 8400, 7500.00, 'INR', 'Mega Bonus', 'uc', 0, 1, 8),
('13040 UC + 5140 Bonus UC', '13040 UC plus 5140 Bonus UC credited directly to your BGMI User ID', 18180, 16300.00, 'INR', 'Ultimate', 'uc', 0, 1, 9),
('Starter Pass', 'Perfect for casual gamers & tournament roster checks.', 25, 49.00, 'INR', 'Popular', 'verify', 0, 1, 10),
('Squad Pro', 'Ideal for clan leaders, scrim organizers & esports teams.', 100, 149.00, 'INR', 'Best Value', 'verify', 1, 1, 11),
('Tournament Master', 'Best for gaming leagues, tournament organizers & bulk lookups.', 300, 399.00, 'INR', 'Pro Gamer', 'verify', 0, 1, 12),
('Elite Syndicate', 'Maximum power with priority verification and enterprise lookups.', 1000, 999.00, 'INR', 'Ultimate', 'verify', 0, 1, 13)
ON DUPLICATE KEY UPDATE `updated_at` = CURRENT_TIMESTAMP;

-- Default CMS Pages
INSERT INTO `pages` (`slug`, `title`, `content`, `meta_title`, `meta_description`, `is_active`) VALUES
('about-us', 'About BGMI Verify', '<h2>Empowering the Esports & Gaming Community</h2><p>BGMI Verify is an independent, high-performance player identification and UID lookup platform built specifically for Battlegrounds Mobile India esports athletes, clan managers, tournament hosts, and gaming communities.</p><h3>Why Verification Matters</h3><p>In competitive esports and community scrims, verifying player rosters against fraudulent impersonations and fake IDs is paramount. Our automated platform guarantees accurate player verification within seconds, maintaining integrity across matches and tournaments.</p><h3>Our Guarantee</h3><p>We provide ultra-low latency verification, zero downtime, transaction-safe credit management, and enterprise-grade security for your data.</p>', 'About Us | BGMI UID Verification Platform', 'Learn about our mission to provide lightning-fast, authentic BGMI player verification for the esports community.', 1),

('privacy-policy', 'Privacy Policy', '<h2>Privacy Policy</h2><p>Last updated: October 2026</p><p>We value your privacy. This Privacy Policy details how BGMI Verify collects, uses, and safeguards your personal data when using our website and verification services.</p><h3>1. Information We Collect</h3><p>We collect your name, email, username, and payment records when you register or purchase credits. We do not store full credit card credentials or sensitive financial tokens.</p><h3>2. How We Use Data</h3><p>Your data is strictly utilized to process transactions, allocate credits, log verification history for your own dashboard view, and protect the integrity of our platform against malicious requests.</p><h3>3. Data Security</h3><p>All sensitive operations utilize cryptographic hashing, PDO prepared queries, CSRF validation, and SSL encryption.</p>', 'Privacy Policy | BGMI Verify', 'Read our complete Privacy Policy and data protection guidelines.', 1),

('terms-conditions', 'Terms & Conditions', '<h2>Terms & Conditions</h2><p>Last updated: October 2026</p><p>By accessing BGMI Verify, you acknowledge and agree to comply with the terms and conditions outlined below.</p><h3>1. Usage Terms</h3><p>Our platform provides BGMI player verification for legitimate roster management, clan validation, and esports community scrims. Any abuse, denial of service attempts, or unauthorized scraping will lead to immediate account termination.</p><h3>2. Credits & Balance</h3><p>Credits purchased on the platform are non-transferable digital vouchers intended exclusively for UID lookups. Credits are deducted per successful verification request according to the platform rules.</p><h3>3. Disclaimer</h3><p>BGMI Verify is an independent tool and is not officially affiliated with or endorsed by Krafton Inc. Battlegrounds Mobile India is a registered trademark of Krafton Inc.</p>', 'Terms & Conditions | BGMI Verify', 'Terms and Conditions governing the use of BGMI Verify services.', 1),

('refund-policy', 'Refund Policy', '<h2>Refund & Cancellation Policy</h2><p>Last updated: October 2026</p><h3>1. Digital Services & Credits</h3><p>Since our services consist of digital verification credits delivered instantaneously upon payment confirmation, standard purchases are non-refundable once credits have been utilized for player lookups.</p><h3>2. Unused Credit Refunds</h3><p>If you purchased credits and have not utilized any balance, you may submit a refund request to our support desk within 48 hours of purchase. Transaction fees charged by payment gateways (e.g., Cashfree or PayPal) may be non-refundable.</p><h3>3. Manual Payment Review Disputes</h3><p>If your manual UPI or PayPal payment is rejected due to invalid UTR or unreadable screenshot, no credits are deducted and you may resubmit with accurate proof. If funds were debited from your bank account without reaching our merchant desk, please contact your banking institution with the UTR.</p>', 'Refund Policy | BGMI Verify', 'Read our detailed Refund and Cancellation policy regarding digital verification credits.', 1),

('faq', 'Frequently Asked Questions', '<h2>Frequently Asked Questions</h2><div class=\"faq-block\"><h3>What is a BGMI UID?</h3><p>A BGMI UID (User Identification) is the unique 10 to 12 digit numerical identifier assigned to every player character in Battlegrounds Mobile India.</p><h3>How quickly is the player name verified?</h3><p>In most instances, our API resolves and verifies the player character name in under 1 second.</p><h3>When are credits deducted?</h3><p>Credits are deducted only when an active player name is successfully resolved and verified. If a UID is invalid or nonexistent, no credits are deducted from your balance.</p><h3>How do Manual UPI and PayPal payments work?</h3><p>Scan the QR code or transfer to our merchant UPI ID/PayPal email. Submit your UTR/Transaction ID along with a screenshot receipt. Our admin staff reviews and activates your package credits in 10-30 minutes.</p></div>', 'Frequently Asked Questions | BGMI Verify', 'Common questions and answers regarding BGMI UID verification, payment methods, and credits.', 1)
ON DUPLICATE KEY UPDATE `updated_at` = CURRENT_TIMESTAMP;

SET FOREIGN_KEY_CHECKS = 1;
