
CREATE TABLE IF NOT EXISTS inquiries (
  id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
  name text NOT NULL,
  phone text NOT NULL,
  email text NOT NULL,
  project_type text NOT NULL,
  budget text,
  location text NOT NULL,
  message text NOT NULL,
  status text NOT NULL DEFAULT 'new' CHECK (status IN ('new', 'contacted', 'quoted', 'closed')),
  created_at timestamptz NOT NULL DEFAULT now()
);

ALTER TABLE inquiries ENABLE ROW LEVEL SECURITY;

CREATE POLICY "insert_inquiries" ON inquiries
  FOR INSERT TO anon, authenticated
  WITH CHECK (true);

CREATE POLICY "select_inquiries" ON inquiries
  FOR SELECT TO authenticated
  USING (true);

CREATE POLICY "update_inquiries" ON inquiries
  FOR UPDATE TO authenticated
  USING (true)
  WITH CHECK (true);

CREATE POLICY "delete_inquiries" ON inquiries
  FOR DELETE TO authenticated
  USING (true);
