USE nirvaan;

/* ---------------- Article categories ---------------- */
INSERT INTO cms_categories (slug,name,seo_title,sort_order) VALUES
 ('mens-health','Men''s health','Men''s sexual health articles — doctor reviewed',10),
 ('womens-health','Women''s health','Women''s sexual health articles — doctor reviewed',20),
 ('relationships','Relationships','Intimacy and relationship articles',30),
 ('myths','Myths and facts','Common myths about sexual health, checked by doctors',40)
ON DUPLICATE KEY UPDATE name = VALUES(name);

/* ---------------- Assessment question banks ----------------
   Bands never name a condition. The engine rejects diagnostic copy,
   so this content is written as "where you sit" plus a next step.
   Options carrying a `flag` raise a support notice regardless of score.
------------------------------------------------------------- */

UPDATE free_tools SET
  intro_html = '<p>Five questions about the last four weeks. There are no right answers, and nothing here is stored against your name.</p>',
  config_json = JSON_OBJECT(
    'intro','Five questions about the last four weeks.',
    'questions', JSON_ARRAY(
      JSON_OBJECT('id','q1','text','Over the last four weeks, how satisfied have you felt with your sex life overall?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Very satisfied','value',0),
          JSON_OBJECT('label','Mostly satisfied','value',1),
          JSON_OBJECT('label','Mixed','value',2),
          JSON_OBJECT('label','Mostly dissatisfied','value',3),
          JSON_OBJECT('label','Very dissatisfied','value',4))),
      JSON_OBJECT('id','q2','text','How often have you felt confident going into a sexual situation?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Almost always','value',0),
          JSON_OBJECT('label','Often','value',1),
          JSON_OBJECT('label','Sometimes','value',2),
          JSON_OBJECT('label','Rarely','value',3),
          JSON_OBJECT('label','Almost never','value',4))),
      JSON_OBJECT('id','q3','text','How often have worries about your body or performance been on your mind?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Not at all','value',0),
          JSON_OBJECT('label','A few days','value',1),
          JSON_OBJECT('label','More than half the days','value',3),
          JSON_OBJECT('label','Nearly every day','value',4,'flag','distress'))),
      JSON_OBJECT('id','q4','text','Has this affected how you are with a partner, or your willingness to start something?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Not at all','value',0),
          JSON_OBJECT('label','A little','value',1),
          JSON_OBJECT('label','Quite a lot','value',3),
          JSON_OBJECT('label','I have been avoiding it entirely','value',4))),
      JSON_OBJECT('id','q5','text','Have you ever talked to a doctor about any of this?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Yes, and it helped','value',0),
          JSON_OBJECT('label','Yes, but it did not go anywhere','value',1),
          JSON_OBJECT('label','No, but I have wanted to','value',2),
          JSON_OBJECT('label','No, and the idea puts me off','value',2)))),
    'bands', JSON_ARRAY(
      JSON_OBJECT('max',4,'label','Things look steady','cta','none',
        'copy','Nothing in your answers stands out. Keep the free reading around if you want to understand a topic better, and come back any time something changes.'),
      JSON_OBJECT('max',9,'label','A few things are on your mind','cta','browse',
        'copy','Some of what you described is common and often shifts with sleep, stress, alcohol and how things are going with a partner. Reading first is a reasonable place to start, and a short conversation is there if you would rather just ask someone.'),
      JSON_OBJECT('max',14,'label','This is taking up real space','cta','consult',
        'copy','Your answers suggest this is affecting your confidence and your choices, not just an occasional off day. That is worth a conversation with someone qualified rather than more searching. The first few minutes cost nothing.'),
      JSON_OBJECT('max',99,'label','Worth talking to someone soon','cta','consult',
        'copy','What you have described is weighing on you across most areas the questions covered. People wait years on this, usually out of embarrassment, and almost always say afterwards that the conversation was easier than the waiting.')),
    'flags', JSON_OBJECT(
      'distress', JSON_OBJECT(
        'title','One more thing',
        'copy','You mentioned this is on your mind nearly every day. Persistent worry deserves attention on its own terms, separate from anything else here. If it is affecting your sleep or your mood more broadly, a doctor is the right person to tell.'))
  )
WHERE slug = 'mens-sexual-wellbeing-check';

UPDATE free_tools SET
  intro_html = '<p>Five questions about the last four weeks. There are no right answers, and nothing here is stored against your name.</p>',
  config_json = JSON_OBJECT(
    'intro','Five questions about the last four weeks.',
    'questions', JSON_ARRAY(
      JSON_OBJECT('id','q1','text','Over the last four weeks, how satisfied have you felt with your sex life overall?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Very satisfied','value',0),
          JSON_OBJECT('label','Mostly satisfied','value',1),
          JSON_OBJECT('label','Mixed','value',2),
          JSON_OBJECT('label','Mostly dissatisfied','value',3),
          JSON_OBJECT('label','Very dissatisfied','value',4))),
      JSON_OBJECT('id','q2','text','Have you experienced discomfort or pain during or after sex?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Never','value',0),
          JSON_OBJECT('label','Occasionally','value',2),
          JSON_OBJECT('label','Often','value',3,'flag','physical'),
          JSON_OBJECT('label','Almost every time','value',4,'flag','physical'))),
      JSON_OBJECT('id','q3','text','How has your interest in sex been compared with what feels normal for you?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','About the same','value',0),
          JSON_OBJECT('label','Slightly lower','value',1),
          JSON_OBJECT('label','Much lower','value',3),
          JSON_OBJECT('label','It has gone entirely','value',4))),
      JSON_OBJECT('id','q4','text','How often have worries about this been on your mind?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Not at all','value',0),
          JSON_OBJECT('label','A few days','value',1),
          JSON_OBJECT('label','More than half the days','value',3),
          JSON_OBJECT('label','Nearly every day','value',4,'flag','distress'))),
      JSON_OBJECT('id','q5','text','Do you feel able to talk about this with your partner, if you have one?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Yes, easily','value',0),
          JSON_OBJECT('label','With effort','value',1),
          JSON_OBJECT('label','Not really','value',3),
          JSON_OBJECT('label','Not at all, or it does not feel safe to','value',4,'flag','safety')))),
    'bands', JSON_ARRAY(
      JSON_OBJECT('max',4,'label','Things look steady','cta','none',
        'copy','Nothing in your answers stands out. The free reading is there if you want to understand a topic better, and you can come back any time something changes.'),
      JSON_OBJECT('max',9,'label','A few things are on your mind','cta','browse',
        'copy','Some of what you described is common and often shifts with stress, sleep, contraception, life stage and how things are going with a partner. Reading first is reasonable, and a short conversation is there if you would rather just ask someone.'),
      JSON_OBJECT('max',14,'label','This is taking up real space','cta','consult',
        'copy','Your answers suggest this is affecting you across several areas rather than occasionally. That is worth a conversation with someone qualified. You can choose a woman doctor and stay anonymous throughout.'),
      JSON_OBJECT('max',99,'label','Worth talking to someone soon','cta','consult',
        'copy','What you have described is weighing on you across most of what the questions covered. Many women wait a long time on this because it feels awkward to raise. It does not have to be a long conversation to be a useful one.')),
    'flags', JSON_OBJECT(
      'physical', JSON_OBJECT(
        'title','Pain is worth raising directly',
        'copy','Pain during or after sex is a physical symptom, and it is one doctors take seriously. It is not something to push through or wait out. Mention it early in the conversation.'),
      'distress', JSON_OBJECT(
        'title','One more thing',
        'copy','You mentioned this is on your mind nearly every day. Persistent worry deserves attention on its own terms. If it is affecting your sleep or your mood more broadly, tell a doctor that part too.'),
      'safety', JSON_OBJECT(
        'title','If something does not feel safe',
        'copy','You indicated it does not feel safe to talk to your partner about this. If any part of your relationship feels unsafe, that matters more than anything else on this page. In India you can reach the national women''s helpline on 181, or Tele-MANAS on 14416, at any hour.'))
  )
WHERE slug = 'womens-sexual-wellbeing-check';

UPDATE free_tools SET
  intro_html = '<p>Four quick questions about how anxiety shows up for you. Two minutes.</p>',
  config_json = JSON_OBJECT(
    'intro','Four questions about how anxiety shows up for you.',
    'questions', JSON_ARRAY(
      JSON_OBJECT('id','q1','text','Do your worries start before anything has happened?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','No','value',0),
          JSON_OBJECT('label','Sometimes','value',2),
          JSON_OBJECT('label','Almost always','value',4))),
      JSON_OBJECT('id','q2','text','Is it different when you are alone compared with when you are with someone?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','No difference','value',0),
          JSON_OBJECT('label','Somewhat different','value',2),
          JSON_OBJECT('label','Completely different','value',3))),
      JSON_OBJECT('id','q3','text','Have you started avoiding situations because of how you might feel?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Not at all','value',0),
          JSON_OBJECT('label','Occasionally','value',2),
          JSON_OBJECT('label','Often','value',3),
          JSON_OBJECT('label','I avoid them entirely now','value',4,'flag','distress'))),
      JSON_OBJECT('id','q4','text','How much of your day does this occupy?',
        'options', JSON_ARRAY(
          JSON_OBJECT('label','Barely any','value',0),
          JSON_OBJECT('label','It crosses my mind','value',1),
          JSON_OBJECT('label','A fair amount','value',3),
          JSON_OBJECT('label','Most of it','value',4,'flag','distress')))),
    'bands', JSON_ARRAY(
      JSON_OBJECT('max',3,'label','Anxiety is not driving this','cta','none',
        'copy','Your answers do not point to anxiety being the main thread. If something is still bothering you, that is worth raising with a doctor on its own.'),
      JSON_OBJECT('max',8,'label','Anxiety is part of the picture','cta','browse',
        'copy','The pattern you described — worry starting early, and easing in some situations more than others — is one that responds well to talking it through. Reading first is fine; a short conversation gets you further faster.'),
      JSON_OBJECT('max',99,'label','Anxiety looks like the main thread','cta','consult',
        'copy','Your answers point strongly at anxiety rather than anything physical, especially the difference between situations and the avoidance. This is the kind of thing that improves with the right conversation and does not usually improve by waiting.')),
    'flags', JSON_OBJECT(
      'distress', JSON_OBJECT(
        'title','This is costing you a lot',
        'copy','You described avoiding situations entirely, or this occupying most of your day. That is a heavy load to carry quietly. Please talk to someone — a doctor here, your own GP, or Tele-MANAS on 14416.'))
  )
WHERE slug = 'performance-anxiety-check';

/* ---------------- SEO for the free tools ---------------- */
INSERT INTO seo_meta (entity_type,entity_id,route,meta_title,meta_desc,robots,answer_summary,sitemap_priority,sitemap_freq)
VALUES
 ('tool',0,'/tools/','Free, private sexual health self-checks — Nirvaan',
  'Short self-assessments for men and women. No account, no cost, nothing stored unless you ask.',
  'index,follow',
  'Nirvaan offers free, anonymous sexual health self-assessments for men and women. They take about two minutes, need no account, and return an orientation band and next step rather than a diagnosis.',
  0.8,'monthly'),
 ('tool',0,'/tools/mens-sexual-wellbeing-check','Free men''s sexual wellbeing self-check — Nirvaan',
  'A private five-question self-check for men. No account needed. Takes two minutes.',
  'index,follow',
  'A free five-question self-check for men covering satisfaction, confidence, worry and avoidance over the past four weeks. It returns a band and a suggested next step, not a diagnosis.',
  0.8,'monthly'),
 ('tool',0,'/tools/womens-sexual-wellbeing-check','Free women''s sexual wellbeing self-check — Nirvaan',
  'A private five-question self-check for women. No account needed. Takes two minutes.',
  'index,follow',
  'A free five-question self-check for women covering satisfaction, discomfort, interest, worry and communication with a partner. It returns a band and a suggested next step, not a diagnosis.',
  0.8,'monthly'),
 ('tool',0,'/tools/performance-anxiety-check','Free performance anxiety self-check — Nirvaan',
  'Four questions to see whether anxiety is the main thread. Private and free.',
  'index,follow',
  'A free four-question self-check that helps distinguish anxiety-driven difficulty from other causes, based on when worry starts, whether it varies by situation, and how much avoidance it causes.',
  0.8,'monthly')
ON DUPLICATE KEY UPDATE meta_title = VALUES(meta_title), meta_desc = VALUES(meta_desc);

/* ---------------- Extra admin roles for testing ---------------- */
INSERT INTO admin_users (full_name,email,password_hash,role) VALUES
 ('Ops Reviewer','ops@nirvaan.in','$2y$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewKyDPHSKuHFRy8m','ops'),
 ('Finance','finance@nirvaan.in','$2y$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewKyDPHSKuHFRy8m','finance'),
 ('Content Editor','content@nirvaan.in','$2y$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewKyDPHSKuHFRy8m','content')
ON DUPLICATE KEY UPDATE role = VALUES(role);
