-- ============================================================
-- Seed Data for Visa Portal — Dummy Data for Testing
-- ============================================================
USE visa_portal;

-- ============================================================
-- 1. COUNTRIES (3 Active)
-- ============================================================
INSERT INTO countries (name, flag_emoji, is_active) VALUES
('United Arab Emirates', '🇦🇪', 1),
('Saudi Arabia', '🇸🇦', 1),
('United Kingdom', '🇬🇧', 1)
ON DUPLICATE KEY UPDATE name = VALUES(name);

-- ============================================================
-- 2. VISA TYPES (2-3 per country)
-- ============================================================
INSERT INTO visa_types (country_id, name, description, requirements, general_procedure, processing_time, is_active) VALUES
-- UAE (country_id = 1)
(1, 'Dubai 30 Days Tourist Visa',
 'Perfect for short visits, tourism, and family trips to Dubai. Single entry, valid for 30 days from date of issue.',
 '- Valid passport (minimum 6 months validity)\n- Recent passport-size photograph\n- Flight itinerary (round trip)\n- Hotel booking confirmation\n- Bank statement (last 3 months)\n- Travel insurance',
 '1. Submit online application with required documents\n2. Pay visa processing fee\n3. Application review (2-3 business days)\n4. Receive e-visa via email\n5. Print and carry upon arrival',
 '3-5 business days', 1),

(1, 'Dubai 90 Days Work Visa',
 'Ideal for professionals and skilled workers seeking employment in Dubai. Multiple entry, valid for 90 days.',
 '- Valid passport (minimum 6 months validity)\n- 2 passport-size photographs\n- Employment contract/offer letter\n- Educational certificates attested\n- Medical fitness certificate\n- Emirates ID application\n- Bank statement (last 6 months)',
 '1. Employer submits application through PRO\n2. Medical examination at approved center\n3. Emirates ID application submission\n4. Visa stamping on passport\n5. Entry permit issuance',
 '2-3 weeks', 1),

(1, 'Dubai Investor / Golden Visa',
 'Long-term residency visa for investors, entrepreneurs, and outstanding talent. Valid for 5-10 years.',
 '- Valid passport (minimum 6 months validity)\n- Investment proof (property worth AED 2M+)\n- Bank statements (last 12 months)\n- Business license / trade license\n- Medical insurance\n- Clean criminal record certificate\n- Passport-size photographs',
 '1. Eligibility assessment through DLD or relevant authority\n2. Submit investment proof documentation\n3. Medical fitness test\n4. Security clearance\n5. Visa issuance (5-10 year validity)\n6. Emirates ID processing',
 '3-4 weeks', 1),

-- Saudi Arabia (country_id = 2)
(2, 'Saudi Umrah Visa',
 'For Muslims seeking to perform Umrah. Single entry, valid for 30 days.',
 '- Valid passport (minimum 6 months validity)\n- 2 passport-size photographs\n- Confirmed Umrah package/travel agency booking\n- Vaccination certificate (quadrivalent/meningococcal)\n- Mahram proof for women (if applicable)\n- Travel insurance',
 '1. Apply through authorized travel agent\n2. Submit passport and documents\n3. Vaccination verification\n4. Visa processing (3-5 business days)\n5. E-visa issued\n6. Travel during validity period',
 '3-5 business days', 1),

(2, 'Saudi Work Visa',
 'Employment visa for professionals working in Saudi Arabia. Valid for 1-2 years, renewable.',
 '- Valid passport (minimum 6 months validity)\n- Educational degrees attested by MOE Saudi & embassy\n- Employment contract attested\n- Medical examination report\n- Professional certifications (if applicable)\n- Security clearance\n- Blood test and X-ray results',
 '1. Employer files visa application via Qiwa platform\n2. Ministry of Foreign Affairs approval\n3. Document attestation from embassy\n4. Medical examination at approved center\n5. Fingerprinting and biometrics\n6. Visa stamping on passport\n7. Final exit/entry permit',
 '4-6 weeks', 1),

-- United Kingdom (country_id = 3)
(3, 'UK Standard Visitor Visa',
 'For tourism, visiting family/friends, or short business trips. Valid for 6 months.',
 '- Valid passport (minimum 6 months validity)\n- Recent passport-size photograph\n- Cover letter explaining purpose of visit\n- Flight itinerary\n- Accommodation proof\n- Bank statements (last 6 months)\n- Employment letter / proof of ties\n- Travel insurance\n- Visa application fee receipt',
 '1. Complete online application (GOV.UK)\n2. Pay visa fee and book biometric appointment\n3. Visit visa application center for biometrics\n4. Submit supporting documents\n5. Application processing (standard 15 business days)\n6. Passport collection or courier delivery',
 '2-3 weeks', 1),

(3, 'UK Student Visa (Tier 4)',
 'For international students accepted at a UK educational institution. Valid for duration of course.',
 '- Valid passport\n- Confirmation of Acceptance for Studies (CAS) from institution\n- Proof of English language proficiency (IELTS/TOEFL)\n- Academic transcripts and certificates\n- Financial proof (tuition + living expenses for 9 months)\n- ATAS certificate (if required)\n- Tuberculosis (TB) test results\n- Parental consent (if under 18)',
 '1. Receive CAS from UK university\n2. Complete online visa application\n3. Pay Immigration Health Surcharge (IHS)\n4. Book and attend biometric appointment\n5. Submit supporting documents\n6. Processing (standard 3-4 weeks)\n7. Biometric Residence Permit (BRP) collection upon arrival',
 '3-4 weeks', 1),

(3, 'UK Work Visa (Skilled Worker)',
 'For skilled professionals with a job offer from a UK employer. Valid for up to 5 years.',
 '- Valid passport\n- Certificate of Sponsorship (CoS) from employer\n- Job offer letter and employment contract\n- English language proficiency (B1 level)\n- Proof of maintenance funds\n- Educational qualifications\n- Criminal record certificate (if required)\n- Tuberculosis test report',
 '1. Employer obtains Sponsor License (if not already)\n2. Certificate of Sponsorship assigned to employee\n3. Submit skilled worker visa application online\n4. Pay visa fee and IHS surcharge\n5. Book biometric appointment\n6. Attend appointment at visa center\n7. Processing (standard 3-8 weeks)\n8. Decision — visa issued/refused',
 '3-8 weeks', 1)
ON DUPLICATE KEY UPDATE name = VALUES(name);

-- ============================================================
-- 3. PAYMENT METHODS
-- ============================================================
INSERT INTO payment_methods (type, label, bank_name, account_title, account_number, iban, payment_url, is_active) VALUES
('bank', 'Meezan Bank', 'Meezan Bank Limited', 'Visa Services Portal', '1234-567890-001', 'PK36MEZN0012345678900001', NULL, 1),
('bank', 'Bank Al-Habib', 'Bank Al-Habib Limited', 'Visa Services Portal', '9876-543210-001', 'PK24BAHL0098765432100001', NULL, 1),
('payment_link', 'EasyPaisa / JazzCash', NULL, NULL, NULL, NULL, 'https://easypaisa.com.pk/pay/visaportal123', 1)
ON DUPLICATE KEY UPDATE label = VALUES(label);

-- ============================================================
-- 4. SMTP SETTINGS (Default Placeholder)
-- ============================================================
INSERT INTO smtp_settings (id, host, port, username, password, encryption, from_name, from_email) VALUES
(1, 'smtp.gmail.com', 587, 'your-email@gmail.com', 'your-app-password-here', 'tls', 'Visa Portal', 'noreply@visaportal.com')
ON DUPLICATE KEY UPDATE host = VALUES(host);

-- ============================================================
-- 5. DUMMY REQUESTS (for customer@test.com)
-- ============================================================
-- Ensure the customer user exists
-- First, check if customer@test.com exists; if not, create it
INSERT IGNORE INTO users (name, email, phone, password, role, is_active) VALUES
('Test Customer', 'customer@test.com', '+923001234567', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'customer', 1);

-- Get the customer ID (should be the first customer user found)
SET @customer_id = (SELECT id FROM users WHERE email = 'customer@test.com' LIMIT 1);

-- Insert 2 dummy requests for the customer
INSERT INTO requests (customer_id, country_id, visa_type_id, status, created_at, updated_at) VALUES
(@customer_id, 1, 1, 'pending', NOW() - INTERVAL 5 DAY, NOW() - INTERVAL 5 DAY),
(@customer_id, 2, 4, 'quote_sent', NOW() - INTERVAL 3 DAY, NOW() - INTERVAL 1 DAY);
