-- Insert email templates for BookBeach
-- Ensure English language exists
INSERT INTO languages (language_name, language_code, is_active) VALUES ('English', 'en', true) ON CONFLICT (language_code) DO NOTHING;

-- Insert Email Verification Template
INSERT INTO email_templates (template_name, subject, html_content, text_content, variables, language_id, is_active) 
SELECT 
    'email_verification',
    'Verify Your BookBeach Account 🏖️',
    '<!DOCTYPE html><html><head><style>body{font-family:Arial,sans-serif;background:#f8f9fa;margin:0;padding:20px}.container{max-width:600px;margin:0 auto;background:#fff;border-radius:12px;overflow:hidden;box-shadow:0 10px 30px rgba(0,0,0,0.1)}.header{background:linear-gradient(135deg,#667eea,#764ba2);color:white;padding:40px;text-align:center}.body{padding:40px}.welcome{font-size:24px;font-weight:600;margin-bottom:20px;text-align:center}.code-box{background:#f8f9fa;border:2px solid #667eea;border-radius:12px;padding:30px;text-align:center;margin:30px 0}.code{font-size:36px;font-weight:bold;letter-spacing:8px;font-family:monospace;background:white;padding:15px;border-radius:8px;border:2px solid #667eea}.warning{background:#fff3cd;border:1px solid #ffeaa7;border-radius:8px;padding:15px;margin:20px 0;color:#856404;text-align:center}.footer{background:#333;color:white;padding:30px;text-align:center}</style></head><body><div class="container"><div class="header"><h1>BookBeach</h1></div><div class="body"><div class="welcome">Welcome to BookBeach! 🏖️</div><p>Hello <strong>{{first_name}}</strong>,</p><p>Thank you for joining BookBeach! Please verify your email using the code below:</p><div class="code-box"><div style="font-size:20px;color:#667eea;margin-bottom:15px">📧 Verification Code</div><div class="code">{{verification_code}}</div></div><div class="warning">⏰ This code expires in {{expiry_minutes}} minutes</div><p>If you didn''t create this account, ignore this email.</p></div><div class="footer"><p>© {{current_year}} BookBeach - Your Gateway to Paradise</p></div></div></body></html>',
    'Hello {{first_name}}, Welcome to BookBeach! Verification code: {{verification_code}}. Expires in {{expiry_minutes}} minutes.',
    '{"first_name": "User name", "verification_code": "6-digit code", "expiry_minutes": "15", "current_year": "2024"}',
    language_id,
    true
FROM languages WHERE language_code = 'en'
ON CONFLICT (template_name) DO UPDATE SET html_content = EXCLUDED.html_content, updated_at = CURRENT_TIMESTAMP;

-- Insert Password Reset Template
INSERT INTO email_templates (template_name, subject, html_content, text_content, variables, language_id, is_active) 
SELECT 
    'password_reset',
    'Reset Your BookBeach Password 🔐',
    '<!DOCTYPE html><html><head><style>body{font-family:Arial,sans-serif;background:#f8f9fa;margin:0;padding:20px}.container{max-width:600px;margin:0 auto;background:#fff;border-radius:12px;overflow:hidden;box-shadow:0 10px 30px rgba(0,0,0,0.1)}.header{background:linear-gradient(135deg,#667eea,#764ba2);color:white;padding:40px;text-align:center}.body{padding:40px}.welcome{font-size:24px;font-weight:600;margin-bottom:20px;text-align:center}.button{display:inline-block;background:linear-gradient(135deg,#667eea,#764ba2);color:white!important;text-decoration:none;padding:15px 30px;border-radius:8px;font-weight:600;margin:20px 0}.warning{background:#fff3cd;border:1px solid #ffeaa7;border-radius:8px;padding:15px;margin:20px 0;color:#856404;text-align:center}.footer{background:#333;color:white;padding:30px;text-align:center}</style></head><body><div class="container"><div class="header"><h1>BookBeach</h1></div><div class="body"><div class="welcome">Reset Your Password 🔐</div><p>Hello <strong>{{first_name}}</strong>,</p><p>We received a request to reset your password. Click below to reset it:</p><div style="text-align:center"><a href="{{reset_url}}" class="button">Reset Password</a></div><div class="warning">⏰ This link expires in {{expiry_hours}} hours</div><p>If you didn''t request this, ignore this email.</p></div><div class="footer"><p>© {{current_year}} BookBeach</p></div></div></body></html>',
    'Hello {{first_name}}, Reset your BookBeach password: {{reset_url}}. Link expires in {{expiry_hours}} hours.',
    '{"first_name": "User name", "reset_url": "Reset URL", "expiry_hours": "24", "current_year": "2024"}',
    language_id,
    true
FROM languages WHERE language_code = 'en'
ON CONFLICT (template_name) DO UPDATE SET html_content = EXCLUDED.html_content, updated_at = CURRENT_TIMESTAMP;

-- Insert Welcome Template
INSERT INTO email_templates (template_name, subject, html_content, text_content, variables, language_id, is_active) 
SELECT 
    'welcome',
    'Welcome to BookBeach! 🎉',
    '<!DOCTYPE html><html><head><style>body{font-family:Arial,sans-serif;background:#f8f9fa;margin:0;padding:20px}.container{max-width:600px;margin:0 auto;background:#fff;border-radius:12px;overflow:hidden;box-shadow:0 10px 30px rgba(0,0,0,0.1)}.header{background:linear-gradient(135deg,#667eea,#764ba2);color:white;padding:40px;text-align:center}.body{padding:40px}.welcome{font-size:24px;font-weight:600;margin-bottom:20px;text-align:center}.success{background:#d4edda;border:1px solid #c3e6cb;border-radius:8px;padding:20px;margin:20px 0;color:#155724;text-align:center}.button{display:inline-block;background:linear-gradient(135deg,#667eea,#764ba2);color:white!important;text-decoration:none;padding:15px 30px;border-radius:8px;font-weight:600;margin:20px 0}.features{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:20px;margin:20px 0}.feature{text-align:center;padding:20px;background:#f8f9fa;border-radius:8px}.footer{background:#333;color:white;padding:30px;text-align:center}</style></head><body><div class="container"><div class="header"><h1>BookBeach</h1></div><div class="body"><div class="welcome">Welcome to BookBeach! 🎉</div><p>Hello <strong>{{first_name}}</strong>,</p><div class="success"><h3>🎊 Account Created!</h3><p>Start booking amazing beach experiences today.</p></div><div style="text-align:center"><a href="{{website_url}}/beaches" class="button">Explore Beaches</a></div><div class="features"><div class="feature"><div style="font-size:48px">🏖️</div><strong>Premium Beaches</strong></div><div class="feature"><div style="font-size:48px">💰</div><strong>Best Prices</strong></div><div class="feature"><div style="font-size:48px">⭐</div><strong>VIP Treatment</strong></div></div></div><div class="footer"><p>© {{current_year}} BookBeach</p></div></div></body></html>',
    'Welcome to BookBeach {{first_name}}! Your account is ready. Start exploring: {{website_url}}/beaches',
    '{"first_name": "User name", "website_url": "https://bookbeach.com", "current_year": "2024"}',
    language_id,
    true
FROM languages WHERE language_code = 'en'
ON CONFLICT (template_name) DO UPDATE SET html_content = EXCLUDED.html_content, updated_at = CURRENT_TIMESTAMP;

-- Insert Company Validation Template
INSERT INTO email_templates (template_name, subject, html_content, text_content, variables, language_id, is_active) 
SELECT 
    'company_validation',
    'Company Under Review - {{company_name}} 🏢',
    '<!DOCTYPE html><html><head><style>body{font-family:Arial,sans-serif;background:#f8f9fa;margin:0;padding:20px}.container{max-width:600px;margin:0 auto;background:#fff;border-radius:12px;overflow:hidden;box-shadow:0 10px 30px rgba(0,0,0,0.1)}.header{background:linear-gradient(135deg,#667eea,#764ba2);color:white;padding:40px;text-align:center}.body{padding:40px}.welcome{font-size:24px;font-weight:600;margin-bottom:20px;text-align:center}.step{margin:15px 0;padding:15px;background:white;border-radius:8px;border-left:4px solid #667eea}.warning{background:#fff3cd;border:1px solid #ffeaa7;border-radius:8px;padding:15px;margin:20px 0;color:#856404}.footer{background:#333;color:white;padding:30px;text-align:center}</style></head><body><div class="container"><div class="header"><h1>BookBeach</h1></div><div class="body"><div class="welcome">Company Under Review 🏢</div><p>Hello <strong>{{first_name}}</strong>,</p><p>Thank you for registering <strong>{{company_name}}</strong> with BookBeach!</p><h3>Validation Process:</h3><div class="step"><strong>Step 1:</strong> Document Review (1-2 days)<br><small>We verify your business registration</small></div><div class="step"><strong>Step 2:</strong> Business Verification (2-3 days)<br><small>We may contact you for more info</small></div><div class="step"><strong>Step 3:</strong> Account Activation<br><small>Full access to business features</small></div><div class="warning">📋 Complete your profile while waiting</div></div><div class="footer"><p>© {{current_year}} BookBeach</p></div></div></body></html>',
    'Hello {{first_name}}, {{company_name}} is under review. We will contact you within 1-2 business days.',
    '{"first_name": "User name", "company_name": "Company name", "current_year": "2024"}',
    language_id,
    true
FROM languages WHERE language_code = 'en'
ON CONFLICT (template_name) DO UPDATE SET html_content = EXCLUDED.html_content, updated_at = CURRENT_TIMESTAMP;

-- Insert Company Approved Template
INSERT INTO email_templates (template_name, subject, html_content, text_content, variables, language_id, is_active) 
SELECT 
    'company_approved',
    'Congratulations! {{company_name}} Approved 🎉',
    '<!DOCTYPE html><html><head><style>body{font-family:Arial,sans-serif;background:#f8f9fa;margin:0;padding:20px}.container{max-width:600px;margin:0 auto;background:#fff;border-radius:12px;overflow:hidden;box-shadow:0 10px 30px rgba(0,0,0,0.1)}.header{background:linear-gradient(135deg,#667eea,#764ba2);color:white;padding:40px;text-align:center}.body{padding:40px}.welcome{font-size:24px;font-weight:600;margin-bottom:20px;text-align:center}.success{background:#d4edda;border:1px solid #c3e6cb;border-radius:8px;padding:20px;margin:20px 0;color:#155724;text-align:center}.button{display:inline-block;background:linear-gradient(135deg,#667eea,#764ba2);color:white!important;text-decoration:none;padding:15px 30px;border-radius:8px;font-weight:600;margin:20px 0}.features{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:20px;margin:20px 0}.feature{text-align:center;padding:20px;background:#f8f9fa;border-radius:8px}.footer{background:#333;color:white;padding:30px;text-align:center}</style></head><body><div class="container"><div class="header"><h1>BookBeach</h1></div><div class="body"><div class="welcome">Company Approved! 🎉</div><p>Hello <strong>{{first_name}}</strong>,</p><div class="success"><h3>✅ {{company_name}} APPROVED</h3><p>Full access to business features granted!</p></div><div style="text-align:center"><a href="{{website_url}}/business/dashboard" class="button">Business Dashboard</a></div><div class="features"><div class="feature"><div style="font-size:48px">🏖️</div><strong>List Beaches</strong></div><div class="feature"><div style="font-size:48px">📊</div><strong>Analytics</strong></div><div class="feature"><div style="font-size:48px">💼</div><strong>Business Tools</strong></div></div></div><div class="footer"><p>© {{current_year}} BookBeach</p></div></div></body></html>',
    'Congratulations {{first_name}}! {{company_name}} has been approved as a BookBeach business partner.',
    '{"first_name": "User name", "company_name": "Company name", "website_url": "https://bookbeach.com", "current_year": "2024"}',
    language_id,
    true
FROM languages WHERE language_code = 'en'
ON CONFLICT (template_name) DO UPDATE SET html_content = EXCLUDED.html_content, updated_at = CURRENT_TIMESTAMP;