-- Seed templates for Synculous
-- Designed for ADHD: two-minute-rule entry points, 4-7 steps max,
-- zero-shame language, concrete instructions, realistic durations.
-- Run with: psql -U user -d database -f config/seed_templates.sql

-- Clean slate (idempotent re-seed)
DELETE FROM routine_template_steps;
DELETE FROM routine_templates;


-- ================================================================
-- 1. Morning Launch
-- ================================================================
-- The hardest transition of the day. First step is literally just
-- sitting up — two-minute rule. Each step cues the next physically.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0001-0001-0001-000000000001',
 'Morning Launch',
 'Get from bed to ready. Starts small — just sit up.',
 '☀️', 'Daily Routines', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0001-0001-0001-000000000001', 'a1b2c3d4-0001-0001-0001-000000000001',
 'Sit up', 'Just sit up in bed. Feet on the floor. That counts.', 'generic', 1, 1),
('b2c3d4e5-0001-0001-0002-000000000001', 'a1b2c3d4-0001-0001-0001-000000000001',
 'Water', 'Drink a glass of water. Your brain needs it.', 'generic', 1, 2),
('b2c3d4e5-0001-0001-0003-000000000001', 'a1b2c3d4-0001-0001-0001-000000000001',
 'Face + teeth', 'Splash water on your face. Brush your teeth.', 'generic', 3, 3),
('b2c3d4e5-0001-0001-0004-000000000001', 'a1b2c3d4-0001-0001-0001-000000000001',
 'Get dressed', 'Real clothes on your body. Doesn''t have to be fancy.', 'generic', 3, 4),
('b2c3d4e5-0001-0001-0005-000000000001', 'a1b2c3d4-0001-0001-0001-000000000001',
 'Eat something', 'Even a handful of crackers. Anything with food in it.', 'generic', 5, 5);


-- ================================================================
-- 2. Leaving the House
-- ================================================================
-- The "where are my keys" routine. Externalizes the checklist
-- so working memory doesn't have to hold it.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0002-0001-0001-000000000002',
 'Leaving the House',
 'Everything you need before you walk out the door.',
 '🚪', 'Daily Routines', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0002-0001-0001-000000000002', 'a1b2c3d4-0002-0001-0001-000000000002',
 'Phone + wallet + keys', 'Check your pockets or bag. All three there?', 'generic', 1, 1),
('b2c3d4e5-0002-0001-0002-000000000002', 'a1b2c3d4-0002-0001-0001-000000000002',
 'Check the weather', 'Quick glance. Do you need a jacket or umbrella?', 'generic', 1, 2),
('b2c3d4e5-0002-0001-0003-000000000002', 'a1b2c3d4-0002-0001-0001-000000000002',
 'Grab what you need', 'Bag, lunch, water bottle, charger — whatever applies.', 'generic', 2, 3),
('b2c3d4e5-0002-0001-0004-000000000002', 'a1b2c3d4-0002-0001-0001-000000000002',
 'Quick scan', 'Stove off? Lights? Windows? Pets fed?', 'generic', 1, 4),
('b2c3d4e5-0002-0001-0005-000000000002', 'a1b2c3d4-0002-0001-0001-000000000002',
 'Lock up and go', 'You''re ready. Lock the door behind you.', 'generic', 1, 5);


-- ================================================================
-- 3. Focus Sprint
-- ================================================================
-- ADHD-adapted pomodoro. Starts with environment setup (Barkley:
-- "at point of performance"). Work block is shorter than classic
-- pomodoro because ADHD sustained attention is shorter.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0003-0001-0001-000000000003',
 'Focus Sprint',
 'One focused work block. Set up your space first.',
 '🎯', 'Getting Things Done', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0003-0001-0001-000000000003', 'a1b2c3d4-0003-0001-0001-000000000003',
 'Pick one task', 'Just one. Write it down or say it out loud.', 'generic', 1, 1),
('b2c3d4e5-0003-0001-0002-000000000003', 'a1b2c3d4-0003-0001-0001-000000000003',
 'Set up your space', 'Close extra tabs. Silence phone. Clear your desk.', 'generic', 2, 2),
('b2c3d4e5-0003-0001-0003-000000000003', 'a1b2c3d4-0003-0001-0001-000000000003',
 'Work', 'Just the one task. If you get pulled away, come back.', 'timer', 20, 3),
('b2c3d4e5-0003-0001-0004-000000000003', 'a1b2c3d4-0003-0001-0001-000000000003',
 'Break', 'Stand up. Stretch. Water. Look at something far away.', 'timer', 5, 4);


-- ================================================================
-- 4. Wind Down
-- ================================================================
-- Sleep prep. Designed around the actual problem: screens are
-- stimulating, the brain won't stop, and the bed isn't "sleepy"
-- enough without a transition.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0004-0001-0001-000000000004',
 'Wind Down',
 'Transition from awake-brain to sleep-brain.',
 '🌙', 'Daily Routines', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0004-0001-0001-000000000004', 'a1b2c3d4-0004-0001-0001-000000000004',
 'Screens away', 'Plug your phone in across the room. TV off.', 'generic', 1, 1),
('b2c3d4e5-0004-0001-0002-000000000004', 'a1b2c3d4-0004-0001-0001-000000000004',
 'Dim the lights', 'Overhead off. Lamp or nightlight only.', 'generic', 1, 2),
('b2c3d4e5-0004-0001-0003-000000000004', 'a1b2c3d4-0004-0001-0001-000000000004',
 'Teeth + face', 'Brush teeth, wash face. Quick is fine.', 'generic', 3, 3),
('b2c3d4e5-0004-0001-0004-000000000004', 'a1b2c3d4-0004-0001-0001-000000000004',
 'Get in bed', 'Pajamas on, blankets up. You''re horizontal now.', 'generic', 2, 4),
('b2c3d4e5-0004-0001-0005-000000000004', 'a1b2c3d4-0004-0001-0001-000000000004',
 'Quiet time', 'Read, listen to something calm, or just breathe.', 'timer', 10, 5);


-- ================================================================
-- 5. Quick Tidy
-- ================================================================
-- Not a full cleaning session. Designed to be completable even on
-- a bad executive function day. Each step is one area, one action.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0005-0001-0001-000000000005',
 'Quick Tidy',
 'A fast sweep through the house. Not deep cleaning — just enough.',
 '✨', 'Getting Things Done', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0005-0001-0001-000000000005', 'a1b2c3d4-0005-0001-0001-000000000005',
 'Trash round', 'Grab a bag. Walk through every room. Toss what''s trash.', 'timer', 3, 1),
('b2c3d4e5-0005-0001-0002-000000000005', 'a1b2c3d4-0005-0001-0001-000000000005',
 'Dishes', 'Everything into the dishwasher or sink. Wipe the counter.', 'timer', 5, 2),
('b2c3d4e5-0005-0001-0003-000000000005', 'a1b2c3d4-0005-0001-0001-000000000005',
 'Put things back', 'Anything out of place goes back where it lives.', 'timer', 5, 3),
('b2c3d4e5-0005-0001-0004-000000000005', 'a1b2c3d4-0005-0001-0001-000000000005',
 'Surfaces', 'Quick wipe on kitchen counter, bathroom sink, one table.', 'timer', 3, 4);


-- ================================================================
-- 6. Body Reset
-- ================================================================
-- For when basic hygiene feels hard. No judgment. Every step is
-- the minimum viable version — just enough to feel a little better.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0006-0001-0001-000000000006',
 'Body Reset',
 'Basic care for your body. Even partial counts.',
 '🚿', 'Health & Body', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0006-0001-0001-000000000006', 'a1b2c3d4-0006-0001-0001-000000000006',
 'Shower or washcloth', 'Full shower or a warm washcloth on face, pits, bits. Both work.', 'generic', 5, 1),
('b2c3d4e5-0006-0001-0002-000000000006', 'a1b2c3d4-0006-0001-0001-000000000006',
 'Teeth', 'Brush for as long as you can. Even 30 seconds matters.', 'generic', 2, 2),
('b2c3d4e5-0006-0001-0003-000000000006', 'a1b2c3d4-0006-0001-0001-000000000006',
 'Deodorant', 'Apply it. Future you says thanks.', 'generic', 1, 3),
('b2c3d4e5-0006-0001-0004-000000000006', 'a1b2c3d4-0006-0001-0001-000000000006',
 'Clean clothes', 'Swap into something fresh. Doesn''t need to match.', 'generic', 2, 4),
('b2c3d4e5-0006-0001-0005-000000000006', 'a1b2c3d4-0006-0001-0001-000000000006',
 'Water + snack', 'Drink something. Eat something. Your body is running on empty.', 'generic', 2, 5);


-- ================================================================
-- 7. Unstuck
-- ================================================================
-- For when you're paralyzed and can't start anything. Pure
-- two-minute-rule: the smallest possible actions to build momentum.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0007-0001-0001-000000000007',
 'Unstuck',
 'Can''t start anything? Start here. Tiny steps, real momentum.',
 '🔓', 'Getting Things Done', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0007-0001-0001-000000000007', 'a1b2c3d4-0007-0001-0001-000000000007',
 'Stand up', 'That''s it. Just stand. You can sit back down after.', 'generic', 1, 1),
('b2c3d4e5-0007-0001-0002-000000000007', 'a1b2c3d4-0007-0001-0001-000000000007',
 'Move to a different spot', 'Walk to another room. Change your scenery.', 'generic', 1, 2),
('b2c3d4e5-0007-0001-0003-000000000007', 'a1b2c3d4-0007-0001-0001-000000000007',
 'Drink water', 'Fill a glass. Drink it slowly.', 'generic', 1, 3),
('b2c3d4e5-0007-0001-0004-000000000007', 'a1b2c3d4-0007-0001-0001-000000000007',
 'Name one thing', 'Say out loud: "The next thing I will do is ___."', 'generic', 1, 4),
('b2c3d4e5-0007-0001-0005-000000000007', 'a1b2c3d4-0007-0001-0001-000000000007',
 'Do two minutes of it', 'Set a timer. Just two minutes. Stop after if you want.', 'timer', 2, 5);


-- ================================================================
-- 8. Evening Reset
-- ================================================================
-- End-of-day prep so tomorrow morning isn't harder than it needs
-- to be. Externalizes "things to remember" before sleep.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0008-0001-0001-000000000008',
 'Evening Reset',
 'Set tomorrow up to be a little easier.',
 '🌆', 'Daily Routines', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0008-0001-0001-000000000008', 'a1b2c3d4-0008-0001-0001-000000000008',
 'Quick kitchen pass', 'Dishes in the sink. Wipe the counter. Done.', 'timer', 5, 1),
('b2c3d4e5-0008-0001-0002-000000000008', 'a1b2c3d4-0008-0001-0001-000000000008',
 'Lay out tomorrow', 'Pick clothes for tomorrow. Put them where you''ll see them.', 'generic', 3, 2),
('b2c3d4e5-0008-0001-0003-000000000008', 'a1b2c3d4-0008-0001-0001-000000000008',
 'Bag check', 'Pack your bag for tomorrow. Keys, wallet, whatever you need.', 'generic', 2, 3),
('b2c3d4e5-0008-0001-0004-000000000008', 'a1b2c3d4-0008-0001-0001-000000000008',
 'Brain dump', 'Write down anything still in your head. Paper, phone, whatever. Get it out.', 'generic', 3, 4),
('b2c3d4e5-0008-0001-0005-000000000008', 'a1b2c3d4-0008-0001-0001-000000000008',
 'Charge devices', 'Phone, headphones, laptop — plug them in now.', 'generic', 1, 5);


-- ================================================================
-- 9. Move Your Body
-- ================================================================
-- Not "exercise." Movement. The entry point is putting shoes on,
-- not "work out for 30 minutes." Anything beyond standing counts.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0009-0001-0001-000000000009',
 'Move Your Body',
 'Not a workout plan. Just movement. Any amount counts.',
 '🏃', 'Health & Body', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0009-0001-0001-000000000009', 'a1b2c3d4-0009-0001-0001-000000000009',
 'Shoes on', 'Put on shoes you can move in. This is the commitment step.', 'generic', 1, 1),
('b2c3d4e5-0009-0001-0002-000000000009', 'a1b2c3d4-0009-0001-0001-000000000009',
 'Step outside', 'Open the door. Stand outside for a second. Feel the air.', 'generic', 1, 2),
('b2c3d4e5-0009-0001-0003-000000000009', 'a1b2c3d4-0009-0001-0001-000000000009',
 'Move for 10 minutes', 'Walk, jog, dance, stretch — whatever your body wants.', 'timer', 10, 3),
('b2c3d4e5-0009-0001-0004-000000000009', 'a1b2c3d4-0009-0001-0001-000000000009',
 'Cool down', 'Slow walk or gentle stretching. Let your heart rate settle.', 'timer', 3, 4),
('b2c3d4e5-0009-0001-0005-000000000009', 'a1b2c3d4-0009-0001-0001-000000000009',
 'Water', 'Drink a full glass. You earned it.', 'generic', 1, 5);


-- ================================================================
-- 10. Sunday Reset
-- ================================================================
-- Weekly prep. Slightly longer, but broken into small concrete
-- chunks. Prevents the "where did the week go" spiral.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0010-0001-0001-000000000010',
 'Sunday Reset',
 'Set up the week ahead so Monday doesn''t ambush you.',
 '📋', 'Getting Things Done', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0010-0001-0001-000000000010', 'a1b2c3d4-0010-0001-0001-000000000010',
 'Check the calendar', 'Open your calendar. What''s happening this week? Anything you need to prepare for?', 'generic', 3, 1),
('b2c3d4e5-0010-0001-0002-000000000010', 'a1b2c3d4-0010-0001-0001-000000000010',
 'Laundry', 'Start a load. You can fold it later — just get it in the machine.', 'generic', 3, 2),
('b2c3d4e5-0010-0001-0003-000000000010', 'a1b2c3d4-0010-0001-0001-000000000010',
 'Restock check', 'Meds, groceries, toiletries — anything running low?', 'generic', 3, 3),
('b2c3d4e5-0010-0001-0004-000000000010', 'a1b2c3d4-0010-0001-0001-000000000010',
 'Tidy living space', 'Flat surfaces first. Then floor. Good enough is good enough.', 'timer', 10, 4),
('b2c3d4e5-0010-0001-0005-000000000010', 'a1b2c3d4-0010-0001-0001-000000000010',
 'Plan meals', 'Even "Monday: leftovers, Tuesday: pasta" counts. Don''t overthink it.', 'generic', 5, 5),
('b2c3d4e5-0010-0001-0006-000000000010', 'a1b2c3d4-0010-0001-0001-000000000010',
 'Rest', 'Done. The week is a little more ready for you now.', 'generic', 1, 6);


-- ================================================================
-- 11. Cooking a Meal
-- ================================================================
-- Not "meal prep for the week." One meal. Broken down so the
-- activation energy is low and the sequence is externalized.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0011-0001-0001-000000000011',
 'Cook a Meal',
 'One meal, start to finish. Just follow the steps.',
 '🍳', 'Health & Body', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0011-0001-0001-000000000011', 'a1b2c3d4-0011-0001-0001-000000000011',
 'Pick something to make', 'Choose one thing. Keep it simple. Eggs, pasta, a sandwich — anything.', 'generic', 1, 1),
('b2c3d4e5-0011-0001-0002-000000000011', 'a1b2c3d4-0011-0001-0001-000000000011',
 'Get ingredients out', 'Pull everything onto the counter before you start.', 'generic', 2, 2),
('b2c3d4e5-0011-0001-0003-000000000011', 'a1b2c3d4-0011-0001-0001-000000000011',
 'Prep', 'Chop, measure, open cans — get everything ready to cook.', 'generic', 5, 3),
('b2c3d4e5-0011-0001-0004-000000000011', 'a1b2c3d4-0011-0001-0001-000000000011',
 'Cook', 'Heat it, combine it, let it do its thing.', 'timer', 15, 4),
('b2c3d4e5-0011-0001-0005-000000000011', 'a1b2c3d4-0011-0001-0001-000000000011',
 'Eat', 'Sit down. Eat the food. You made this.', 'generic', 10, 5),
('b2c3d4e5-0011-0001-0006-000000000011', 'a1b2c3d4-0011-0001-0001-000000000011',
 'Rinse dishes', 'Just rinse and stack. Full cleaning can wait.', 'generic', 2, 6);


-- ================================================================
-- 12. Errand Run
-- ================================================================
-- Externalizes the "I have errands but I keep not doing them"
-- problem. Forces the plan into concrete sequential steps.

INSERT INTO routine_templates (id, name, description, icon, category, created_by_admin) VALUES
('a1b2c3d4-0012-0001-0001-000000000012',
 'Errand Run',
 'Get out, do the things, come home. One trip.',
 '🛒', 'Errands', true);

INSERT INTO routine_template_steps (id, template_id, name, instructions, step_type, duration_minutes, position) VALUES
('b2c3d4e5-0012-0001-0001-000000000012', 'a1b2c3d4-0012-0001-0001-000000000012',
 'Write the list', 'Every stop, every item. Write it all down right now.', 'generic', 3, 1),
('b2c3d4e5-0012-0001-0002-000000000012', 'a1b2c3d4-0012-0001-0001-000000000012',
 'Plan the route', 'Put the stops in order so you''re not zigzagging.', 'generic', 2, 2),
('b2c3d4e5-0012-0001-0003-000000000012', 'a1b2c3d4-0012-0001-0001-000000000012',
 'Grab essentials', 'Keys, wallet, phone, bags, list. Ready?', 'generic', 2, 3),
('b2c3d4e5-0012-0001-0004-000000000012', 'a1b2c3d4-0012-0001-0001-000000000012',
 'Do the errands', 'Follow the list. Check things off as you go.', 'generic', 30, 4),
('b2c3d4e5-0012-0001-0005-000000000012', 'a1b2c3d4-0012-0001-0001-000000000012',
 'Put things away', 'Groceries away, returns sorted, bags emptied. Then you''re done.', 'generic', 5, 5);
