-- Migration 006: Email template defaults for review_request and install reminders
-- These templates are stored in company_settings and used by autoEmail.php.
-- The review_request template powers the post-service Google review ask.
-- Install reminder templates (7d/3d/1d) power the extended reminder cadence
-- for service types with extended_reminders=1.

INSERT INTO `company_settings` (`setting_key`, `setting_value`) VALUES
-- Review request template
('tpl_review_request_subject', 'Your feedback matters to us!'),
('tpl_review_request_body', '<p>Hi {{first_name}},</p>
<p>Thank you for choosing {{company_name}} for your recent water service!</p>
<p>We love hearing from our customers. Would you mind taking 20 seconds to tell us how we did?</p>
<p>Clicking the link below opens our official Google page with 5 stars automatically selected - all you have to do is type your thoughts:</p>
<p style="text-align:center;margin:24px 0">
  <a href="{{google_link}}" style="display:inline-block;background:#0d9488;color:#fff;padding:12px 28px;border-radius:6px;text-decoration:none;font-weight:700;font-size:15px">&#x1F449; Click Here to Review Us on Google</a>
</p>
<p>Thank you for supporting a local business!</p>
<p>Best,<br>The {{company_name}} Team<br>&#x1F4DE; {{company_phone}}</p>'),

-- Install reminder 7-day
('tpl_install_reminder_7d_subject', 'Your {{service_type}} is one week away ({{date}})'),
('tpl_install_reminder_7d_body', '<p>Hi {{first_name}},</p>
<p>Just a heads-up that your <strong>{{service_type}}</strong> appointment is <strong>one week away</strong>.</p>
<div style="background:#eff6ff;border:1px solid #bfdbfe;border-radius:8px;padding:16px;margin:16px 0">
<p style="margin:0 0 8px"><strong> Date:</strong> {{date}}</p>
<p style="margin:0 0 8px"><strong> Time:</strong> {{time}}</p>
<p style="margin:0 0 8px"><strong> Service:</strong> {{service_type}}</p>
<p style="margin:0 0 8px"><strong> Technician:</strong> {{technician}}</p>
<p style="margin:0"><strong> Location:</strong> {{address}}</p></div>
<p>A few things that help us get in and out quickly:</p>
<ul style="margin:8px 0 16px 20px;padding:0">
<li>Please clear a path to the install location</li>
<li>Know where your main water shut-off is, in case we need it</li>
<li>Someone 18 or older should be available the day of</li>
</ul>
<p>Need to reschedule? Call us at <strong>{{company_phone}}</strong> as soon as you can.</p>'),

-- Install reminder 3-day
('tpl_install_reminder_3d_subject', 'Your {{service_type}} is in 3 days ({{date}})'),
('tpl_install_reminder_3d_body', '<p>Hi {{first_name}},</p>
<p>Just a heads-up that your <strong>{{service_type}}</strong> appointment is <strong>in 3 days</strong>.</p>
<div style="background:#eff6ff;border:1px solid #bfdbfe;border-radius:8px;padding:16px;margin:16px 0">
<p style="margin:0 0 8px"><strong> Date:</strong> {{date}}</p>
<p style="margin:0 0 8px"><strong> Time:</strong> {{time}}</p>
<p style="margin:0 0 8px"><strong> Service:</strong> {{service_type}}</p>
<p style="margin:0 0 8px"><strong> Technician:</strong> {{technician}}</p>
<p style="margin:0"><strong> Location:</strong> {{address}}</p></div>
<p>A few things that help us get in and out quickly:</p>
<ul style="margin:8px 0 16px 20px;padding:0">
<li>Please clear a path to the install location</li>
<li>Know where your main water shut-off is, in case we need it</li>
<li>Someone 18 or older should be available the day of</li>
</ul>
<p>Need to reschedule? Call us at <strong>{{company_phone}}</strong> as soon as you can.</p>'),

-- Install reminder 1-day
('tpl_install_reminder_1d_subject', 'Your {{service_type}} is tomorrow ({{date}})'),
('tpl_install_reminder_1d_body', '<p>Hi {{first_name}},</p>
<p>Just a heads-up that your <strong>{{service_type}}</strong> appointment is <strong>tomorrow</strong>.</p>
<div style="background:#eff6ff;border:1px solid #bfdbfe;border-radius:8px;padding:16px;margin:16px 0">
<p style="margin:0 0 8px"><strong> Date:</strong> {{date}}</p>
<p style="margin:0 0 8px"><strong> Time:</strong> {{time}}</p>
<p style="margin:0 0 8px"><strong> Service:</strong> {{service_type}}</p>
<p style="margin:0 0 8px"><strong> Technician:</strong> {{technician}}</p>
<p style="margin:0"><strong> Location:</strong> {{address}}</p></div>
<p>A few things that help us get in and out quickly:</p>
<ul style="margin:8px 0 16px 20px;padding:0">
<li>Please clear a path to the install location</li>
<li>Know where your main water shut-off is, in case we need it</li>
<li>Someone 18 or older should be available the day of</li>
</ul>
<p>Need to reschedule? Call us at <strong>{{company_phone}}</strong> as soon as you can.</p>'),

-- Technical difficulties broadcast
('tpl_technical_difficulties_subject', 'Important Service Update - {{company_name}}'),
('tpl_technical_difficulties_body', '<p>Hi {{first_name}},</p>
<p>We are currently experiencing technical difficulties that may affect your scheduled service.</p>
<p><strong>What this means:</strong> {{impact}}</p>
<p><strong>What you need to do:</strong> {{action_required}}</p>
<p>We apologize for any inconvenience and are working to resolve this as quickly as possible. If you have questions, please call us at <strong>{{company_phone}}</strong>.</p>
<p>Thank you for your patience,<br>The {{company_name}} Team</p>')

ON DUPLICATE KEY UPDATE `setting_value` = VALUES(`setting_value`);
