-- Add system control settings to site_settings table
INSERT INTO site_settings (key, value) VALUES
  ('maintenance_mode',         'false'),
  ('registration_open',        'true'),
  ('email_notifications',      'true'),
  ('daily_reports',            'true'),
  ('hero_image',               NULL),
  ('session_timeout_minutes',  '30')
ON CONFLICT (key) DO NOTHING;

-- Add INSERT policy so admins can create new setting rows
CREATE POLICY "Admins can insert site settings"
  ON site_settings FOR INSERT
  TO authenticated
  WITH CHECK (
    EXISTS (SELECT 1 FROM profiles WHERE id = auth.uid() AND role = 'admin')
  );